Skip to content

feat(packs): add config pack for settings, secrets and vaults - #650

Merged
dmealing merged 10 commits into
mainfrom
fm/mo-pack-a1-config
Nov 25, 2026
Merged

dmealing merged 10 commits into
mainfrom
fm/mo-pack-a1-config

Conversation

@dmealing

@dmealing dmealing commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

What Changed

  • Adds the independent packs/config pack (@metaobjectsdev/pack-config, provider metaobjects-config, version 0.1.0, preview, private and unpublished). It declares object.settings (scalar field settings only), the optional field attributes @secret, @envName and @phase (runtime | build), and vault.infisical at the document root with scope.env children (@project, @env) and an optional @defaultScope. Core gains no vocabulary and no version change. This PR is the TypeScript port only.
  • Adds three generators: envExampleFile() (.env.example), keyManifestFile() (keys.manifest.json) and keysAxiTomlFile() (.keys-axi.toml, in the format keys-axi reads). No secret value reaches their output. Model problems the loader cannot see (env name collisions, malformed @envName, secrets with @default, array settings, bad @defaultScope, vaults with no scope, and similar) fail the run as one ConfigModelError that lists every problem. The pack carries its own conformance fixtures, vocabulary pin, CHANGELOG.md and README, and packs/README.md gains a row for it. The lockfile gains the workspace entry.
  • Changes scripts/check-pack-boundary.ts so a core file stem such as metaobjects-config.ts (core's own config module, and its .schema.json and .test.ts files) no longer matches the config pack id. That is the only change to the gate. Any other dotted word after the id still fails. A new test in scripts/packs.test.ts covers it.

Known limitations

  • TypeScript only. Other ports fail to load a model that uses the pack, with ERR_UNKNOWN_SUBTYPE or ERR_UNKNOWN_ATTR.
  • Core's meta gen skip fingerprint (gen-fingerprint.ts) does not hash a non-engine @metaobjectsdev/* config import. A generator edit in a source-linked pack can therefore leave stale output. This is a separate core task, not fixed here. It must land before the first in-repo or source-linked pack consumer.
  • meta gen runs no generator over a model with no objects, so a vault-only model writes no .keys-axi.toml. The pack README documents this.
  • The systems and delivery packs are untouched. The deploy script that copies secrets to a platform, and the Railway and Cloudflare emitters, are later work.

No-mistakes gate runs for this PR: 2.

Validation

Risk Assessment

✅ Low: Self-contained, unpublished preview pack with no core vocabulary or version change; earlier-round fixes are in the current code, and the only core-side edit (the pack-boundary file-stem exemption) is narrow and covered by a new test.

Testing

Baseline command passed at the target commit. This turn drove the README wiring live through the real meta gen CLI in disposable scratch projects. S1 passed: .env.example, keys.manifest.json and .keys-axi.toml land at the project root, with secrets by name only and nothing under src/generated. S2 passed: a model with six settings and vault problems fails once, exit 1, listing all six, with no files written. S3 passed: a misplaced @secret on object.value warns once per run naming Token.value, not the settings field, and the unextended abstract base's bad @envName is rejected. S4 (keys-axi wiring) is untested: a single read-only keys-axi where probe reached the operator's configured keystore with a synthetic project name and returned PROJECT_NOT_FOUND, which indicates the toml's default environment and scope were read, but no disposable keystore was available for a full run; no further keys-axi calls were made. Scratch projects were removed; evidence copied to the evidence directory.

  • Live validation: ✅ go - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
S1 README wiring: meta gen with the README config writes .env.example, keys.manifest.json and .keys-axi.toml at the project root (scratch project, synthetic settings and vault), nothing under src/gene… ✅ pass live artifacts config-pack-live/.env.example, keys.manifest.json, .keys-axi.toml; CLI printed gen[3]: .env.example,new / keys.manifest.json,new / .keys-axi.toml,new, exit 0; no src/ directory created
S2 adversarial: a model with settings and vault problems fails closed with one ConfigModelError listing every problem and writes no file ✅ pass live artifact config-pack-live/S2-bad-model-gen-output.txt: gen failed: [env-example] config pack: 6 problem(s), exit 1, output directory empty
S3 guard: @secret/@envName/@phase on a field outside a settings group warns once per run naming the field, and an unextended abstract settings base is still validated ✅ pass live artifact config-pack-live/S3-misplaced-warning-gen-output.txt: one acme::app::Token.value: @secret only mean something on a field of an object.settings warning, no warning for settings field Api.key…
S4 keys-axi wiring: keys-axi reads the generated .keys-axi.toml so keys-axi run needs no project flag ⏸️ untested no Tried a read-only keys-axi probe in the scratch project. It reached the operator's configured keystore, not a disposable one, with a synthetic project name, which is outside the sandbox boundary; that…
Evidence: S1 generated .env.example from README wiring
# @generated by @metaobjectsdev/pack-config (env-example) — hand edits are kept by a three-way merge on regeneration; meta verify --codegen checks only the generated parts.
# Every setting the application reads. Secret settings are listed by name only.

# ── Database (acme::app::Database) ──
# The primary database.
# DATABASE_URL: string, required, secret: the value lives in the vault — Connection URL.
DATABASE_URL=
# DATABASE_USERNAME: string, required
DATABASE_USERNAME=
# DB_POOL_SIZE: int, optional
DB_POOL_SIZE=10

# ── LlmProvider (acme::app::LlmProvider) ──
# LLM_PROVIDER_API_KEY: string, required, secret: the value lives in the vault
LLM_PROVIDER_API_KEY=
# LLM_PROVIDER_MODEL: string, optional
LLM_PROVIDER_MODEL="a model name"
# LLM_PROVIDER_TRACE: boolean, optional
LLM_PROVIDER_TRACE=false

# ── Build (acme::app::Build) ──
# BUILD_COMMIT_SHA: string, optional, build-time
BUILD_COMMIT_SHA=
Evidence: S1 generated .keys-axi.toml from README wiring
# @generated by @metaobjectsdev/pack-config (keys-axi-toml) — hand edits are kept by a three-way merge on regeneration; meta verify --codegen checks only the generated parts.
# From vault.infisical acme::app::keys.
backend = "infisical"
scope = "acme-app"
default_environment = "dev"

# dev
[environments.dev]
scope = "acme-app"

# production
[environments.prod]
scope = "acme-app-prod"
Evidence: S1 generated keys.manifest.json from README wiring
{
  "generatedBy": "@metaobjectsdev/pack-config (key-manifest)",
  "settings": [
    {
      "envName": "BUILD_COMMIT_SHA",
      "setting": "acme::app::Build.commitSha",
      "type": "string",
      "required": false,
      "secret": false,
      "phase": "build"
    },
    {
      "envName": "DATABASE_URL",
      "setting": "acme::app::Database.url",
      "type": "string",
      "required": true,
      "secret": true,
      "phase": "runtime",
      "description": "Connection URL."
    },
    {
      "envName": "DATABASE_USERNAME",
      "setting": "acme::app::Database.username",
      "type": "string",
      "required": true,
      "secret": false,
      "phase": "runtime"
    },
    {
      "envName": "DB_POOL_SIZE",
      "setting": "acme::app::Database.poolSize",
      "type": "int",
      "required": false,
      "secret": false,
      "phase": "runtime",
      "default": "10"
    },
    {
      "envName": "LLM_PROVIDER_API_KEY",
      "setting": "acme::app::LlmProvider.apiKey",
      "type": "string",
      "required": true,
      "secret": true,
      "phase": "runtime"
    },
    {
      "envName": "LLM_PROVIDER_MODEL",
      "setting": "acme::app::LlmProvider.model",
      "type": "string",
      "required": false,
      "secret": false,
      "phase": "runtime",
      "default": "a model name"
    },
    {
      "envName": "LLM_PROVIDER_TRACE",
      "setting": "acme::app::LlmProvider.trace",
      "type": "boolean",
      "required": false,
      "secret": false,
      "phase": "runtime",
      "default": "false"
    }
  ],
  "vaults": [
    {
      "name": "keys",
      "key": "acme::app::keys",
      "product": "infisical",
      "defaultScope": "dev",
      "scopes": [
        {
          "name": "dev",
          "project": "acme-app",
          "env": "dev"
        },
        {
          "name": "production",
          "project": "acme-app-prod",
          "env": "prod"
        }
      ]
    }
  ]
}
Evidence: S2 adversarial model gen output (fail closed, one error)
meta: gen failed: [env-example] config pack: 6 problem(s) in the model:
  - acme::app::Database.url: a @secret setting may not declare @default (its value belongs in the vault)
  - acme::app::Database.pool-size: the derived environment variable name "DATABASE_POOL-SIZE" is not valid (upper case letters, digits and _, not starting with a digit); set @envName
  - acme::app::Database.mode: @envName "not-valid" is not an environment variable name (upper case letters, digits and _, not starting with a digit)
  - acme::app::Database.tags: a setting holds one value; @isArray is not supported
  - acme::app::Other.b: environment variable DUP is also acme::app::Other.a
  - acme::app::keys: @defaultScope "nope" names no scope.env of this vault (dev)
Evidence: S3 misplaced-attribute warning gen output
meta: [env-example] @metaobjectsdev/pack-config: acme::app::Token.value: @secret only mean something on a field of an object.settings; here nothing reads them
meta: 1 wired generator(s) matched nothing and wrote no file: keys-axi-toml. That is often correct — a generator whose metadata this model does not declare has nothing to emit. It is reported because a run that emitted nothing and a run that did the work otherwise look identical.
gen[2]{file,status}:
  .env.example,new
  keys.manifest.json,new
summary: 2 written
help[1]: typecheck the generated code with `npx tsc`
antiPatterns:
  status: ran
  total: 0
  rows: []
warnings[2]: "[env-example] @metaobjectsdev/pack-config: acme::app::Token.value: @secret only mean something on a field of an object.settings; here nothing reads them","1 wired generator(s) matched nothing and wrote no file: keys-axi-toml. That is often correct — a generator whose metadata this model does not declare has nothing to emit. It is reported because a run that emitted nothing and a run that did the work otherwise look identical."
  • Outcome: 🔧 1 issue found → auto-fixed ✅ across 2 runs (22m0s)

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

🔧 **Test** - 1 issue found → auto-fixed ✅
  • ⚠️ live validation verdict: inconclusive (0 of 3 scenarios were driven live against the product); untested: S1 through S3b: meta gen with the config pack wired via top-level outDir produces expected output, S4: README Wiring snippet run through meta gen, keys-axi secrets wiring
  • Live validation: ⚠️ inconclusive - 0 of 3 scenarios driven live against the product
Scenario Result Live Evidence
S1 through S3b: meta gen with the config pack wired via top-level outDir produces expected output ⏸️ untested no Rejected payload named this scenario group only in testing_summary. No live=true result or evidence was recorded, so a pass cannot be supported.
S4: README Wiring snippet run through meta gen ⏸️ untested no Rejected payload claimed a live failure (meta gen crash) in testing_summary but recorded no live=true result or evidence. A fail cannot be supported; the claim is not carried as a finding.
keys-axi secrets wiring ⏸️ untested no Rejected payload states this was untested by design. No live attempt was recorded.
  • scripts/ci-local.sh --affected --strict-toolchains
  • built meta CLI gen against scratch synthetic projects

🔧 Fix applied.
✅ Re-checked - no issues remain.

  • Live validation: ✅ go - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
S1 README wiring: meta gen with the README config writes .env.example, keys.manifest.json and .keys-axi.toml at the project root (scratch project, synthetic settings and vault), nothing under src/gene… ✅ pass live artifacts config-pack-live/.env.example, keys.manifest.json, .keys-axi.toml; CLI printed gen[3]: .env.example,new / keys.manifest.json,new / .keys-axi.toml,new, exit 0; no src/ directory created
S2 adversarial: a model with settings and vault problems fails closed with one ConfigModelError listing every problem and writes no file ✅ pass live artifact config-pack-live/S2-bad-model-gen-output.txt: gen failed: [env-example] config pack: 6 problem(s), exit 1, output directory empty
S3 guard: @secret/@envName/@phase on a field outside a settings group warns once per run naming the field, and an unextended abstract settings base is still validated ✅ pass live artifact config-pack-live/S3-misplaced-warning-gen-output.txt: one acme::app::Token.value: @secret only mean something on a field of an object.settings warning, no warning for settings field Api.key…
S4 keys-axi wiring: keys-axi reads the generated .keys-axi.toml so keys-axi run needs no project flag ⏸️ untested no Tried a read-only keys-axi probe in the scratch project. It reached the operator's configured keystore, not a disposable one, with a synthetic project name, which is outside the sandbox boundary; that…
  • scripts/ci-local.sh --affected --strict-toolchains
  • bun {run-worktree}/server/typescript/packages/cli/dist/bin/meta.js gen in a scratch project (under /mnt/scratch) with metaobjects.config.ts copied from packs/config/README.md Wiring, a settings + vault model, linked @metaobjectsdev packages (S1)
  • Adversarial model via meta gen with secret @default, derived invalid env name, bad @envName, array setting, duplicate env name, and unknown @defaultScope (S2)
  • Misplaced @secret on object.value field plus settings @secret via meta gen, and an unextended abstract settings base with bad @envName (S3)
  • bun test on packs/config/typescript/test/generators.test.ts (11 pass, includes the README-wiring runGen test and the once-per-run warning test)
  • Read-only keys-axi --help and one keys-axi where DATABASE_URL probe in the scratch project (S4, partial; see reason)
  • Broad regression: configured scripts/ci-local.sh --affected --strict-toolchains baseline, which passed at target commit; no source changed this turn
⚠️ **Document** - 1 info
  • ℹ️ packs/README.md:11 - The pack.json field table omits description. All four pack.json files (config, systems, delivery, railway) carry it, and scripts/check-pack-manifests.ts does not reject it. Previously declined in document round 1 (packs-readme-stale); still true in current code. Not fixed here, per that decision.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

The first independent pack, packs/config (metaobjects-config, 0.1.0 preview,
unpublished, TypeScript only):

- object.settings: a settings group whose fields are the settings (scalar
  field subtypes only); no source, so no table, query or route.
- @secret, @envName and @phase (runtime | build): optional attributes on every
  field subtype, read on settings.
- vault.infisical at the document root, with scope.env children (@project,
  @env) and an optional @DefaultScope.
- Generators: envExampleFile (.env.example), keyManifestFile
  (keys.manifest.json) and keysAxiTomlFile (.keys-axi.toml). Names only: the
  model holds no secret value. Problems the loader cannot see (a variable name
  used twice, a malformed @envName, a secret with a default, an array setting,
  a bad default scope, two scopes on one store environment, a vault with no
  scope) fail the run, all listed.

The provider registers metamodel/config.json through the public provider
contract; a test holds that lowering to core's own. Pinned vocabulary leaves
core alone; five load fixtures run through the TypeScript pack-conformance
entry point.

check-pack-boundary: a pack id followed by a file extension is a file name,
not the id (core's metaobjects-config.ts is not the config pack), with a test.
- An abstract settings group is a base: read through the groups that extend it,
  never emitted under its own name.
- Vaults are read inside the project's scope, as settings are.
- Setting attributes put on a non-settings field warn once per run, from
  whichever config generator runs first.
- keys-axi-toml problems are ConfigModelErrors like the model's others.
- scope.env declares min 1 (the generators enforce it; the loader does not
  count child rules).
- Reuse core's FIELD_ATTR_* / DOC_ATTR_DESCRIPTION constants and
  GENERATED_EDIT_NOTE: hand edits are three-way merged, so the header no
  longer says "do not edit".
- check-pack-boundary: a file-name tail (.test.ts, .schema.json) after a pack
  id is a file stem; an id followed by another dotted word still trips.
@dmealing
dmealing merged commit 4536993 into main Nov 25, 2026
11 checks passed
@dmealing
dmealing deleted the fm/mo-pack-a1-config branch November 25, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant