Skip to content

feat(metadata): add business-rules operations and lifecycles - #610

Merged
dmealing merged 15 commits into
mainfrom
fm/mo-rules-core-vocab
Nov 20, 2026
Merged

dmealing merged 15 commits into
mainfrom
fm/mo-rules-core-vocab

Conversation

@dmealing

@dmealing dmealing commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

What Changed

  • Registers the experimental business-rules vocabulary in every port: api.operational with operation.command and operation.query, an optional binding.rest, and transition.action as a child of field.enum. States, the initial and terminal states, and each transition's derived command need no extra vocabulary. The loader refuses malformed operations and lifecycles with eleven new ERR_* codes, each pinned by a fixtures/conformance/error-rules-* case. The shape may still change in a MINOR until generated services run on it.
  • Adds a rules gate to verify in every port except the Rust preview (unreachable states, transitions that can never fire, unused permissions) and four settings in .metaobjects/config.json (rules.permissions.names, rules.lifecycle.commands, rules.lifecycle.create, verify.lifecycle.unreachable). Derived permission names include the owning package and entity, so two entities' cancel transitions never share a grant. A lifecycle on an entity with no source loads and is inert.
  • Adds ADR-0066 (operations, permission points and lifecycles) and ADR-0067 (layering and the service seam, amending ADR-0045). Nothing is generated from the vocabulary yet. The branch also carries the work merged from main: the Rust preview port, ADR-0063 to ADR-0065, and the 1.3.0 items in the changelog.
Validation

Risk Assessment

✅ Low: The files I read (C# and Python RulesCheck, the Java header, and the Rust loader and provider diffs) match the TS reference on checks, messages and the no-source-inert rule, and I found no behavioural defect; I did not read most listed fixture and test files for content.

Testing

Drove the real meta CLI against a disposable scratch project under {tmp-dir}, built from the rules-check and conformance fixtures, and removed it afterwards. Three scenarios, all live with pass results: advise-mode verify emits the three derived-name warnings with owner-qualified names (acme::purchasing.PurchaseRequest.submit, acme::purchasing.decide, acme::purchasing.requestSummary), matching the fixture's expected.json; require-mode verify turns them into errors and exits 1; loader refuses a lifecycle on a read-only source with ERR_TRANSITION_NOT_ON_ENTITY and exits 1. The sourceless-lifecycle-inert case was not driven here (scenario cap of three); it is covered by the baseline rules-check conformance run. Spec and generated-doc wording changes are documentation only and were checked by the baseline run, not live. Overall: pass, no findings.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Advise-mode verify on a model with declared and derived operations/transitions reports owner-qualified derived permission names (local CLI, synthetic fixture input) ✅ pass live rules-verify-advise.txt; bun server/typescript/packages/cli/bin/meta.ts verify --templates in scratch project
Require-mode verify turns the derived-name findings into errors and fails the gate (adversarial: policy boundary) ✅ pass live rules-verify-require.txt; same CLI with rules.permissions.names=require
A lifecycle on an entity whose source is read-only is refused at load (adversarial: writable-source guard) ✅ pass live rules-loader-readonly-source-refusal.txt; loader error from fixtures/conformance/error-rules-lifecycle-readonly-source input
Evidence: Advise-mode verify output (3 derived-name warnings, owner-qualified)
meta: meta verify — no template.* nodes found; the template gate had nothing to check.
meta: meta verify — rules: 4 operation(s), 1 lifecycle(s) with 5 transition(s).
meta:   WARN_PERMISSION_DERIVED_NAME [acme::purchasing::PurchaseRequest.status.submit]: the command derived from transition "submit" of "PurchaseRequest" has no @permission, so it asks the policy about the derived name "acme::purchasing.PurchaseRequest.submit", which changes if the transition is renamed. Declare @permission, or @public: true.
meta:   WARN_PERMISSION_DERIVED_NAME [acme::purchasing::Purchasing.decide]: operation.command "decide" has no @permission, so it asks the policy about the derived name "acme::purchasing.decide", which changes if the operation is renamed. Declare @permission, or @public: true.
meta:   WARN_PERMISSION_DERIVED_NAME [acme::purchasing::Purchasing.requestSummary]: operation.query "requestSummary" has no @permission, so it asks the policy about the derived name "acme::purchasing.requestSummary", which changes if the operation is renamed. Declare @permission, or @public: true.
meta: meta verify — not run: schema (--db <url>), codegen (--codegen), deps (--deps), replay (--replay)
verify[7]{gate,ran,ok}:
  templates,true,true
  schema,false,true
  codegen,false,true
  deps,false,true
  requirements,true,true
  rules,true,true
  replay,false,true
exitCode: 0
summary: "3 gate(s) ran, all clean; 3 rules finding(s)"
help[1]: "3 business-rules finding(s) — see rules.rows[]; each names a lifecycle state or transition nothing can reach, a lifecycle that cannot move, or a permission name the model derived instead of declaring"
antiPatterns:
  status: ran
  total: 0
  rows: []
requirements:
  status: ran
  total: 0
  rows: []
overlays:
  status: ran
  total: 0
  rows: []
names:
  status: ran
  total: 0
  rows: []
deprecations:
  status: ran
  total: 0
  rows: []
fields:
  status: ran
  total: 0
  rows: []
rules:
  status: ran
  total: 3
  rows[3]{code,path,severity,source,message}:
    WARN_PERMISSION_DERIVED_NAME,"acme::purchasing::PurchaseRequest.status.submit",warn,gate,"the command derived from transition \"submit\" of \"PurchaseRequest\" has no @permission, so it asks the policy about the derived name \"acme::purchasing.PurchaseRequest.submit\", which changes if the transition is renamed. Declare @permission, or @public: true."
    WARN_PERMISSION_DERIVED_NAME,"acme::purchasing::Purchasing.decide",warn,gate,"operation.command \"decide\" has no @permission, so it asks the policy about the derived name \"acme::purchasing.decide\", which changes if the operation is renamed. Declare @permission, or @public: true."
    WARN_PERMISSION_DERIVED_NAME,"acme::purchasing::Purchasing.requestSummary",warn,gate,"operation.query \"requestSummary\" has no @permission, so it asks the policy about the derived name \"acme::purchasing.requestSummary\", which changes if the operation is renamed. Declare @permission, or @public: true."
rulesCounts:
  operations: 4
  lifecycles: 1
  transitions: 5
notRepresented[2]: "per-gate drift detail for every gate but schema (which template variable drifted, which generated file differs, which migration failed to replay) — printed as text on stderr; this payload carries each gate's pass/fail verdict, and the schema gate's differences in schemaDrift",the loader's own warnings and the agent-context/manifest advisories — printed as text on stderr
Evidence: Require-mode verify output (same findings as errors, exit 1)
meta: meta verify — no template.* nodes found; the template gate had nothing to check.
meta: meta verify — rules: 4 operation(s), 1 lifecycle(s) with 5 transition(s).
meta:   WARN_PERMISSION_DERIVED_NAME [acme::purchasing::PurchaseRequest.status.submit]: the command derived from transition "submit" of "PurchaseRequest" has no @permission, so it asks the policy about the derived name "acme::purchasing.PurchaseRequest.submit", which changes if the transition is renamed. Declare @permission, or @public: true.
meta:   WARN_PERMISSION_DERIVED_NAME [acme::purchasing::Purchasing.decide]: operation.command "decide" has no @permission, so it asks the policy about the derived name "acme::purchasing.decide", which changes if the operation is renamed. Declare @permission, or @public: true.
meta:   WARN_PERMISSION_DERIVED_NAME [acme::purchasing::Purchasing.requestSummary]: operation.query "requestSummary" has no @permission, so it asks the policy about the derived name "acme::purchasing.requestSummary", which changes if the operation is renamed. Declare @permission, or @public: true.
meta: meta verify — rules: 3 error(s).
meta: meta verify — not run: schema (--db <url>), codegen (--codegen), deps (--deps), replay (--replay)
verify[7]{gate,ran,ok}:
  templates,true,true
  schema,false,true
  codegen,false,true
  deps,false,true
  requirements,true,true
  rules,true,false
  replay,false,true
exitCode: 1
summary: 1 of 3 gate(s) failed (rules); 3 rules finding(s)
help[2]: the failing gate's drift DETAIL is printed as text on stderr — this payload carries the verdict only,"3 business-rules finding(s) — see rules.rows[]; each names a lifecycle state or transition nothing can reach, a lifecycle that cannot move, or a permission name the model derived instead of declaring"
antiPatterns:
  status: ran
  total: 0
  rows: []
requirements:
  status: ran
  total: 0
  rows: []
overlays:
  status: ran
  total: 0
  rows: []
names:
  status: ran
  total: 0
  rows: []
deprecations:
  status: ran
  total: 0
  rows: []
fields:
  status: ran
  total: 0
  rows: []
rules:
  status: ran
  total: 3
  rows[3]{code,path,severity,source,message}:
    WARN_PERMISSION_DERIVED_NAME,"acme::purchasing::PurchaseRequest.status.submit",error,gate,"the command derived from transition \"submit\" of \"PurchaseRequest\" has no @permission, so it asks the policy about the derived name \"acme::purchasing.PurchaseRequest.submit\", which changes if the transition is renamed. Declare @permission, or @public: true."
    WARN_PERMISSION_DERIVED_NAME,"acme::purchasing::Purchasing.decide",error,gate,"operation.command \"decide\" has no @permission, so it asks the policy about the derived name \"acme::purchasing.decide\", which changes if the operation is renamed. Declare @permission, or @public: true."
    WARN_PERMISSION_DERIVED_NAME,"acme::purchasing::Purchasing.requestSummary",error,gate,"operation.query \"requestSummary\" has no @permission, so it asks the policy about the derived name \"acme::purchasing.requestSummary\", which changes if the operation is renamed. Declare @permission, or @public: true."
rulesCounts:
  operations: 4
  lifecycles: 1
  transitions: 5
notRepresented[2]: "per-gate drift detail for every gate but schema (which template variable drifted, which generated file differs, which migration failed to replay) — printed as text on stderr; this payload carries each gate's pass/fail verdict, and the schema gate's differences in schemaDrift",the loader's own warnings and the agent-context/manifest advisories — printed as text on stderr
Evidence: Loader refusal of lifecycle on read-only source (ERR_TRANSITION_NOT_ON_ENTITY)
meta: failed to load metadata: ERR_TRANSITION_NOT_ON_ENTITY: object.entity "PurchaseRequest" has a lifecycle (transitions on "status") and a source, but no writable one; a transition is a guarded update of a stored row. (An entity with no source at all may carry a lifecycle: it is inert until a source is added.)
  in meta.purchasing.json at $['metadata.root'].children[0]['object.entity']
error: "failed to load metadata: object.entity \"PurchaseRequest\" has a lifecycle (transitions on \"status\") and a source, but no writable one; a transition is a guarded update of a stored row. (An entity with no source at all may carry a lifecycle: it is inert until a source is added.)"
code: ERR_TRANSITION_NOT_ON_ENTITY
files[1]: meta.purchasing.json
jsonPath: "$['metadata.root'].children[0]['object.entity']"
hint: fix the metadata error above and re-run

Pipeline

Validated in one no-mistakes run, with five review fix rounds inside it.

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 4 issues (2 warnings, 2 infos)
  • ℹ️ server/python/src/metaobjects/loader/validate_rules.py:44 - Module docstring rule O5 omits the reserved-code check the code enforces. The code rejects reserved @errors codes via _RESERVED_CODES, and the spec, TS, C# and Java headers all list it. Add ", or is one the route answers itself" to O5.
  • ⚠️ server/java/metadata/src/main/java/com/metaobjects/api/Lifecycles.java:286 - Java projectionBaseEntity dedupes entity owners with owners.contains(ext.owner()), which calls MetaData.equals. That method compares children, type, subType and name structurally (MetaData.java:1977). The TypeScript, C# and Python references and Java's own borrowedKeyEntities compare by identity. Trace: a projection whose fields extend a::Customer.x and b::Customer.y, where the two entities are structurally equal, collapses to one owner. The method then returns that entity instead of null, so a projection base that should be ambiguous derives a target. This is a wrong-value-without-error path, and equals is also a deep recursive comparison on every call. Fix: use the existing containsIdentity(owners, ext.owner()). Same invariant: no other contains on MetaData in this file; entityLineage and lifecycleTransitionsOf already use containsIdentity.
  • ⚠️ server/typescript/packages/sdk/src/config.ts:413 - rules.lifecycle.create (initial | any) is registered, validated and carried in all ports' config readers. The config.ts doc comment says it "is validated and has no effect yet, since no service shell reads it". The stated intent (Q1, Q2, Q5, the layering ruling, the two 2026-11-13 rulings) lists no such setting. Nothing in this change reads it, and fixtures/rules-check-conformance/lifecycle-create-any only checks that it parses. It is a config key that promises behavior nobody enforces. Smallest honest remedy: remove the key from RULES_LIFECYCLE_CREATE and the rules.lifecycle.create reader in every port, and add it back when a shell reads it. The remedy changes the config contract and the fixtures, so it needs authorization. Sites: server/typescript/packages/sdk/src/config.ts:413, server/typescript/packages/metadata/src/rules-settings.ts, server/python/src/metaobjects/rules_settings.py (RULES_LIFECYCLE_CREATE), server/python/src/metaobjects/config/neutral_config.py (_RULES_BLOCKS), server/csharp/MetaObjects/Config/NeutralConfig.cs (ReadRules create), server/java/metadata/src/main/java/com/metaobjects/config/NeutralConfig.java, fixtures/rules-check-conformance/lifecycle-create-any.

🔧 Fix applied.
2 issues (1 warning, 1 info) still open:

  • ⚠️ server/typescript/packages/sdk/src/config.ts:413 - rules.lifecycle.create (initial | any) is registered, validated and carried in all ports' config readers. The config.ts doc comment says it "is validated and has no effect yet, since no service shell reads it". The stated intent (Q1, Q2, Q5, the layering ruling, the two 2026-11-13 rulings) lists no such setting. Nothing in this change reads it, and fixtures/rules-check-conformance/lifecycle-create-any only checks that it parses. It is a config key that promises behavior nobody enforces. Smallest honest remedy: remove the key from RULES_LIFECYCLE_CREATE and the rules.lifecycle.create reader in every port, and add it back when a shell reads it. The remedy changes the config contract and the fixtures, so it needs authorization. Sites: server/typescript/packages/sdk/src/config.ts:413, server/typescript/packages/metadata/src/rules-settings.ts, server/python/src/metaobjects/rules_settings.py (RULES_LIFECYCLE_CREATE), server/python/src/metaobjects/config/neutral_config.py (_RULES_BLOCKS), server/csharp/MetaObjects/Config/NeutralConfig.cs (ReadRules create), server/java/metadata/src/main/java/com/metaobjects/config/NeutralConfig.java, fixtures/rules-check-conformance/lifecycle-create-any.
  • ℹ️ spec/metamodel/api.json:65 - The binding.rest description says "(setting api.operationPaths chooses the :verb style)". No port registers or reads that setting. The TS config schema (server/typescript/packages/sdk/src/config.ts, api is a strictObject allowing only pagination and unknownFields) would reject it as an unknown key. The CHANGELOG lists the four new settings as rules.permissions.names, rules.lifecycle.commands, rules.lifecycle.create and verify.lifecycle.unreachable, and api.operationPaths is not among them. An adopter who follows the generated reference docs gets a config error. Remove the parenthetical, or add the setting in every port's config reader. Same text, so also fix: server/csharp/MetaObjects/SpecMetamodel/api.json:65, server/python/src/metaobjects/spec_metamodel/api.json:65, server/typescript/packages/metadata/src/core/api/api-definition.embedded.ts:145, fixtures/registry-conformance/expected-registry.json:115, fixtures/metamodel-docs/expected/types/binding.md:27, fixtures/metamodel-docs/expected/INDEX.md:32, site-reference/types/binding.html and site-reference/index.html.

🔧 Fix applied.
2 issues (1 warning, 1 info) still open:

  • ⚠️ server/typescript/packages/sdk/src/config.ts:413 - rules.lifecycle.create (initial | any) is registered, validated and carried in all ports' config readers. The config.ts doc comment says it "is validated and has no effect yet, since no service shell reads it". The stated intent (Q1, Q2, Q5, the layering ruling, the two 2026-11-13 rulings) lists no such setting. Nothing in this change reads it, and fixtures/rules-check-conformance/lifecycle-create-any only checks that it parses. It is a config key that promises behavior nobody enforces. Smallest honest remedy: remove the key from RULES_LIFECYCLE_CREATE and the rules.lifecycle.create reader in every port, and add it back when a shell reads it. The remedy changes the config contract and the fixtures, so it needs authorization. Sites: server/typescript/packages/sdk/src/config.ts:413, server/typescript/packages/metadata/src/rules-settings.ts, server/python/src/metaobjects/rules_settings.py (RULES_LIFECYCLE_CREATE), server/python/src/metaobjects/config/neutral_config.py (_RULES_BLOCKS), server/csharp/MetaObjects/Config/NeutralConfig.cs (ReadRules create), server/java/metadata/src/main/java/com/metaobjects/config/NeutralConfig.java, fixtures/rules-check-conformance/lifecycle-create-any.
  • ℹ️ fixtures/metamodel-docs/expected/types/operation.md - The @permission description on operation.base contradicts itself. It says the permission is "never derived from the operation's name: a rename would silently move access", then says that when @permission is absent "the shell uses the derived name &lt;package&gt;.&lt;operation&gt;". The 2026-11-13 ruling, docs/features/business-rules.md and the WARN_PERMISSION_DERIVED_NAME message all say it IS derived and that verify advises or requires an explicit one. A reader of the generated reference gets two opposite statements. Reword the first sentence, for example "an explicit name is a stable key into grant data: a derived name moves when the operation is renamed". The same text sits in every copy of the registry description: spec/metamodel/api.json, server/csharp/MetaObjects/SpecMetamodel/api.json, server/python/src/metaobjects/spec_metamodel/api.json, server/typescript/packages/metadata/src/core/api/api-definition.embedded.ts, fixtures/registry-conformance/expected-registry.json, fixtures/metamodel-docs/expected/types/operation.md and site-reference/types/operation.html. Fix the spec once and regenerate the ports' copies and the two generated pages.

🔧 Fix applied.
7 issues (2 warnings, 5 infos) still open:

  • ⚠️ server/typescript/packages/sdk/src/config.ts:413 - rules.lifecycle.create (initial | any) is registered, validated and carried in all ports' config readers. The config.ts doc comment says it "is validated and has no effect yet, since no service shell reads it". The stated intent (Q1, Q2, Q5, the layering ruling, the two 2026-11-13 rulings) lists no such setting. Nothing in this change reads it, and fixtures/rules-check-conformance/lifecycle-create-any only checks that it parses. It is a config key that promises behavior nobody enforces. Smallest honest remedy: remove the key from RULES_LIFECYCLE_CREATE and the rules.lifecycle.create reader in every port, and add it back when a shell reads it. The remedy changes the config contract and the fixtures, so it needs authorization. Sites: server/typescript/packages/sdk/src/config.ts:413, server/typescript/packages/metadata/src/rules-settings.ts, server/python/src/metaobjects/rules_settings.py (RULES_LIFECYCLE_CREATE), server/python/src/metaobjects/config/neutral_config.py (_RULES_BLOCKS), server/csharp/MetaObjects/Config/NeutralConfig.cs (ReadRules create), server/java/metadata/src/main/java/com/metaobjects/config/NeutralConfig.java, fixtures/rules-check-conformance/lifecycle-create-any.
  • ⚠️ spec/metamodel/api.json - Several registry descriptions of the new vocabulary describe the generated service shell in the present tense as if it shipped: operation.command ("the generated shell around it loads the row, checks the permission and the current state, runs the body, and makes the guarded update in one transaction"), operation @Permission ("the permission name the generated shell asks the project's policy about", "the shell uses the derived name"), operation @public ("The shell calls no permission check"), operation.command @errors ("the shell refuses an undeclared one"), and in spec/metamodel/transition.json transition @Permission and @public ("the derived command ... asks the policy", "the derived command calls no permission check") and transition.action ("Each transition becomes a guarded update ..., its own command ..., its own permission point and its own wire error"). No shell or derived command is generated in this change: ADR-0066 and docs/features/business-rules.md say nothing is generated from this vocabulary yet. A reader of the generated reference is told behaviour exists that does not. Reword each to state the contract the shell will honour and that no shell is generated yet; sweep both description sets for any other claim of shipped behaviour that is not shipped. Same text sits in every copy of the registry description (each port's embedded or copied metamodel, fixtures/registry-conformance/expected-registry.json, fixtures/metamodel-docs/expected, site-reference); fix the spec once, carry it to every copy byte-identically, and regenerate the generated pages.
  • ℹ️ metaobjects/meta.requirements.yaml:1348 - The transitionAction requirement says a transition sits "on a field of an entity with a writable source". The 2026-11-13 ruling, ADR-0066 §2 and rule L2 say an entity with no source at all is allowed: its lifecycle loads and is inert. Only a read-only source (a concrete entity with a source that is not writable) is refused with ERR_TRANSITION_NOT_ON_ENTITY. The ledger statement overstates the rule. Reword to say a lifecycle on an entity with a source needs a writable one, and a sourceless entity's lifecycle is inert.
  • ℹ️ server/csharp/MetaObjects/Loader/ValidationPasses.Rules.cs:11 - Header comment says an operation failing O2 or O3 "is not checked for O4 or O5". The code skips O4 and B1 (it returns before them) and checks O5 first. The TS reference and the Rust header both say "O4 or B1". Change "O5" to "B1".
  • ℹ️ spec/metamodel/api.json:20 - The api.operational rules text says "Two declared bindings may not share a method and path (ERR_BINDING_PATH_MISMATCH)" with no scope. The check is per API: checkApiRoutes(ops, sink) runs inside the per-API loop in server/typescript/packages/metadata/src/loader/rules-validation.ts (around line 376), and the rule header, the binding.rest @path description and the ERROR-CODES entry all say "of one API". The versioned-APIs case (v1 and v2 declaring the same route) is legal, and api.operational itself says versioned APIs may declare the same operation side by side. A reader of the generated reference could conclude that two APIs cannot share a route. Add "of one API" to the sentence. The same text sits in server/csharp/MetaObjects/SpecMetamodel/api.json, server/python/src/metaobjects/spec_metamodel/api.json, server/typescript/packages/metadata/src/core/api/api-definition.embedded.ts, fixtures/registry-conformance/expected-registry.json, fixtures/metamodel-docs/expected/types/api.md, fixtures/metamodel-docs/expected/INDEX.md and site-reference/types/api.html. Edit the spec once, copy it to each port, and regenerate the two generated pages.
  • ℹ️ fixtures/codegen-noop/rules/README.md:10 - README says the with/ model "is the positive conformance fixture fixtures/conformance/rules-purchase-request/". The two are not the same: with/meta.purchasing.json puts @permission: purchasing.review on the reject transition, and the conformance input does not. The pair is also described as differing "ONLY by the business-rules vocabulary", which holds, but the copy claim is wrong. Reword to "derived from" or drop the claim. The inert tests do not depend on the two files being identical, so this is documentation only.
  • ℹ️ server/java/codegen-kotlin/src/test/kotlin/com/metaobjects/generator/kotlin/RulesInertTest.kt:112 - The doc comment on apiDocs says "A served report has a generated API to document (its row, table, list route and allowlist); a sourceless one has none.". It was copied from the reporting inert test and does not describe this fixture, which has no report. Replace it with a comment about the api-docs surface of the with/without model pair.

🔧 Fix applied.
3 issues (2 warnings, 1 info) still open:

  • ⚠️ server/typescript/packages/sdk/src/config.ts:413 - rules.lifecycle.create (initial | any) is registered, validated and carried in all ports' config readers. The config.ts doc comment says it "is validated and has no effect yet, since no service shell reads it". The stated intent (Q1, Q2, Q5, the layering ruling, the two 2026-11-13 rulings) lists no such setting. Nothing in this change reads it, and fixtures/rules-check-conformance/lifecycle-create-any only checks that it parses. It is a config key that promises behavior nobody enforces. Smallest honest remedy: remove the key from RULES_LIFECYCLE_CREATE and the rules.lifecycle.create reader in every port, and add it back when a shell reads it. The remedy changes the config contract and the fixtures, so it needs authorization. Sites: server/typescript/packages/sdk/src/config.ts:413, server/typescript/packages/metadata/src/rules-settings.ts, server/python/src/metaobjects/rules_settings.py (RULES_LIFECYCLE_CREATE), server/python/src/metaobjects/config/neutral_config.py (_RULES_BLOCKS), server/csharp/MetaObjects/Config/NeutralConfig.cs (ReadRules create), server/java/metadata/src/main/java/com/metaobjects/config/NeutralConfig.java, fixtures/rules-check-conformance/lifecycle-create-any.
  • ℹ️ server/java/metadata/src/main/java/com/metaobjects/loader/RulesValidation.java:52 - Header comment says an operation whose target fails O2 or O3 "is not checked for O4 or O5". The code (and the TS reference, Rust, C# and ADR-0066) skip O4 and B1; O5 (@errors) runs before the target is derived and is never skipped. Round 4's fix (review-2) corrected "O5" to "B1" only in the C# header and left this sibling behind. Same stale wording remains at: server/python/src/metaobjects/loader/validate_rules.py:13 ("not checked for O4 or O5"). Change both to "O4 or B1".
  • ⚠️ fixtures/requirement-harness/typescript/requirement-harness.test.ts:80 - Stale generated harness comments after the round-4 fix. That round (review-1) reworded the transitionAction requirement statement in metaobjects/meta.requirements.yaml:1345 to "…on a field of an entity; an entity with a source needs a writable one, and the lifecycle of an entity with no source is inert…". It did not regenerate the harness. Every port's harness still prints the old text "…on a field of an entity with a writable source; the field's default is the initial state…". scripts/generate-requirement-harness.ts emits // ${title} — ${statement} and ci-local.sh gate_requirement_harness runs it with --check, so the drift gate fails. The round-4 fix introduced the defect by editing the ledger without the generated copies. Fix: rerun bun scripts/generate-requirement-harness.ts to rewrite all five copies. Sibling sites carrying the same stale line: fixtures/requirement-harness/python/test_requirement_harness.py:80, fixtures/requirement-harness/java/RequirementHarnessTest.java:85, fixtures/requirement-harness/kotlin/RequirementHarnessTest.kt:85, fixtures/requirement-harness/csharp/RequirementHarnessTests.cs:71.

🔧 Fix applied.
4 issues (2 warnings, 2 infos) still open:

  • ⚠️ server/typescript/packages/sdk/src/config.ts:413 - rules.lifecycle.create (initial | any) is registered, validated and carried in all ports' config readers. The config.ts doc comment says it "is validated and has no effect yet, since no service shell reads it". The stated intent (Q1, Q2, Q5, the layering ruling, the two 2026-11-13 rulings) lists no such setting. Nothing in this change reads it, and fixtures/rules-check-conformance/lifecycle-create-any only checks that it parses. It is a config key that promises behavior nobody enforces. Smallest honest remedy: remove the key from RULES_LIFECYCLE_CREATE and the rules.lifecycle.create reader in every port, and add it back when a shell reads it. The remedy changes the config contract and the fixtures, so it needs authorization. Sites: server/typescript/packages/sdk/src/config.ts:413, server/typescript/packages/metadata/src/rules-settings.ts, server/python/src/metaobjects/rules_settings.py (RULES_LIFECYCLE_CREATE), server/python/src/metaobjects/config/neutral_config.py (_RULES_BLOCKS), server/csharp/MetaObjects/Config/NeutralConfig.cs (ReadRules create), server/java/metadata/src/main/java/com/metaobjects/config/NeutralConfig.java, fixtures/rules-check-conformance/lifecycle-create-any.
  • ℹ️ server/java/metadata/src/main/java/com/metaobjects/loader/RulesValidation.java:52 - Header comment says an operation whose target fails O2 or O3 "is not checked for O4 or O5". The code (and the TS reference, Rust, C# and ADR-0066) skip O4 and B1; O5 (@errors) runs before the target is derived and is never skipped. Round 4's fix (review-2) corrected "O5" to "B1" only in the C# header and left this sibling behind. Same stale wording remains at: server/python/src/metaobjects/loader/validate_rules.py:13 ("not checked for O4 or O5"). Change both to "O4 or B1".
  • ⚠️ fixtures/requirement-harness/typescript/requirement-harness.test.ts:80 - Stale generated harness comments after the round-4 fix. That round (review-1) reworded the transitionAction requirement statement in metaobjects/meta.requirements.yaml:1345 to "…on a field of an entity; an entity with a source needs a writable one, and the lifecycle of an entity with no source is inert…". It did not regenerate the harness. Every port's harness still prints the old text "…on a field of an entity with a writable source; the field's default is the initial state…". scripts/generate-requirement-harness.ts emits // ${title} — ${statement} and ci-local.sh gate_requirement_harness runs it with --check, so the drift gate fails. The round-4 fix introduced the defect by editing the ledger without the generated copies. Fix: rerun bun scripts/generate-requirement-harness.ts to rewrite all five copies. Sibling sites carrying the same stale line: fixtures/requirement-harness/python/test_requirement_harness.py:80, fixtures/requirement-harness/java/RequirementHarnessTest.java:85, fixtures/requirement-harness/kotlin/RequirementHarnessTest.kt:85, fixtures/requirement-harness/csharp/RequirementHarnessTests.cs:71.
  • ℹ️ server/csharp/MetaObjects/Core/Transition/RulesCheck.cs:27 - Header comment says the permission check runs "per concrete entity". The code uses CommandEntities, which also requires a source (LifecycleIsLive). The TS reference header says "concrete entity that has a source" and carries the paragraph on derived permission names including their owner. The C# header lacks that paragraph. The Python header has the same stale sentence at server/python/src/metaobjects/rules_check.py:28 and lacks the same paragraph. Code behaviour matches across TS, C#, Python and Java; only the comments lag. Fix: copy the TS wording into both headers.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Advise-mode verify on a model with declared and derived operations/transitions reports owner-qualified derived permission names (local CLI, synthetic fixture input) ✅ pass live rules-verify-advise.txt; bun server/typescript/packages/cli/bin/meta.ts verify --templates in scratch project
Require-mode verify turns the derived-name findings into errors and fails the gate (adversarial: policy boundary) ✅ pass live rules-verify-require.txt; same CLI with rules.permissions.names=require
A lifecycle on an entity whose source is read-only is refused at load (adversarial: writable-source guard) ✅ pass live rules-loader-readonly-source-refusal.txt; loader error from fixtures/conformance/error-rules-lifecycle-readonly-source input
  • scripts/ci-local.sh --affected --strict-toolchains
  • bun server/typescript/packages/cli/bin/meta.ts verify --templates (advise mode, scratch project from fixtures/rules-check-conformance/permission-names-advise)
  • bun server/typescript/packages/cli/bin/meta.ts verify --templates (require mode, same input with rules.permissions.names=require)
  • bun server/typescript/packages/cli/bin/meta.ts verify --templates (loader refusal, input from fixtures/conformance/error-rules-lifecycle-readonly-source)
  • Compared CLI diagnostics against fixtures/rules-check-conformance/permission-names-advise/expected.json (3 WARN_PERMISSION_DERIVED_NAME, summary operations 4 / lifecycles 1 / transitions 5)
  • Baseline: scripts/ci-local.sh --affected --strict-toolchains (already passed at target commit; not re-run, no source changed in this turn)
⚠️ **Document** - 1 info
  • ℹ️ docs/features/cli.md:67 - Follow-up (out of scope): the bare-verify default gate list is restated in several places: docs/features/cli.md, docs/features/migrations-and-drift.md, agent-context/skills/metaobjects-verify/SKILL.md, agent-context/skills/metaobjects-fit-assessment/references/capability-sheet.md and docs/features/templates-and-payloads.md (partly). This change had to edit four copies of one fact. Proposed follow-up: keep the full list in cli.md only and reduce the others to pointers. The agent-context copies are mirrored into fixtures/agent-context-conformance, so that consolidation needs the fixture mirrors regenerated in the same change.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…(ADR-0063, ADR-0064)

Operations, permission points and lifecycles become declarable beside the
entities, in all five ports, checked when they load and by verify. Nothing
is generated from them yet: a model with this vocabulary generates exactly
the code the same model generates without it.

Vocabulary (expected-registry.json, metamodelVersion stays 1.3):
- api.operational, operation.command, operation.query, binding.rest, with
  the base subtypes not authorable (ADR-0054).
- @inputRef, @outputRef, @many (query only), @objectref, @transitions,
  @Permission, @public, @errors on operations; @method, @path on bindings.
- transition.action as a child of field.enum, with @from, @to, @condition,
  @Permission, @public; transition.timed reserved.

Loader rules L1-L7, P1, O0-O5 and B1 raise ten new codes in every port, pinned
by fixtures/conformance (error-rules-*, rules-*). Java's addChild now carries
ERR_CHILD_NOT_ALLOWED on the refusal it already made, as the other ports do.

verify runs a rules gate in every port, held to the new
fixtures/rules-check-conformance corpus (13 cases): unreachable states,
an initial state that is terminal, unreachable transitions and derived
permission names. It reads rules.permissions.names, rules.lifecycle.create,
rules.lifecycle.commands and verify.lifecycle.unreachable from config.json;
every absent key behaves as before, and a mistake is refused.

A requirement's implementedBy can name an operation or a transition, and the
generated requirement test carries its unit.

Docs: ADR-0063, ADR-0064, ADR-0045 Amendment 1, the compatibility policy,
docs/features/business-rules.md, CONFORMANCE.md, the requirements ledger
and the CHANGELOG [Unreleased] entry.
…oles (ADR-0063)

The independent check of the business-rules vocabulary found it would publish
as covered metamodel with holes a lifecycle could fall through. This change
labels it experimental and fixes what the check ran into, in all five ports.

Experimental: the compatibility policy, the CHANGELOG entry,
docs/features/business-rules.md, ADR-0063, ADR-0064 and the registry
descriptions say the shape may change in a MINOR, including removals and
renames, until generated services run on it in an adopter estate.

Lifecycles:
- A transition belongs to the entity that declares its field and to the
  entities extending it, never to one whose field merely extends the
  lifecycle field (a status history table has no lifecycle).
- An inheritor that redeclares a lifecycle field without extending it is
  refused with the new ERR_LIFECYCLE_REDECLARED (L10).
- An empty @from (L8) and an array lifecycle field (L9) are refused.

Names and operations:
- Transition and operation names compare without case: reserved names in any
  case (L5, O0), two transitions of one entity (L6) and two operations of one
  API (O6).
- An @errors code may not be one the route answers itself (O5).
- Two declared bindings of one API may not share a method and path (B2).
- An input derives a target only when it borrows each key field of exactly one
  entity exactly once; part of a composite key or one key borrowed twice
  derives nothing (O2).

verify:
- Claims are keyed by transition node, so a command whose target is an
  abstract base claims each child's inherited transition.
- New WARN_TRANSITION_PERMISSION_SHADOWED for a transition @Permission or
  @public that no derived command reads. The shadowed permission is dropped
  from the purchase-request fixtures and the docs example.

Ports: C# anchors the @errors pattern with \z; Java checks @method before the
O1-O3 short-circuit and refuses "rules": null and "verify": null.
rules.lifecycle.create is documented as having no effect yet.

ADR-0063 records, per remaining case, why it loads: route collisions involving
a derived path are the transport generator's to refuse, and a duplicated
operation or API merges under the loader's general rule (pinned by a
requirement-check case).

Fixtures: 11 new fixtures/conformance cases (553), 2 new rules-check cases (15),
1 new requirement-check case (49).
… lifecycles (ADR-0063)

The captain's rulings on the independent check's two held calls, in all five ports.

Permission names (call 1):
- A derived permission name includes its owner. A transition's derived
  command asks about <package>.<Entity>.<transition>, so Order.cancel and
  Invoice.cancel no longer share a grant. A declared operation keeps
  <package>.<operation>.
- Operation names are unique per package across its APIs (O6, was per API).
  One operation declared identically in two APIs is the same operation and is
  not refused, so a versioned API can sit beside its successor (ADR-0064 §2).
  An identical declaration has the same name, subtype, referenced shapes,
  transitions, errors, permission, public and many; the bindings may differ.
- A @Permission must be a dotted identifier path (new rule P2,
  ERR_BAD_ATTR_VALUE). A package prefix may use "::", so a derived name can be
  declared as it is.

Sourceless lifecycles (call 2):
- A lifecycle on an entity with no source loads and is inert, like everything
  else on a sourceless entity (#248). L2 now applies only once the entity has
  a source, declared or inherited, and none of them is writable. verify
  checks the lifecycle's states and skips its permission points. A library's
  core layer can declare its lifecycles.

Fixtures:
- error-rules-lifecycle-no-source becomes the positive
  rules-lifecycle-no-source.
- New loader cases: error-rules-lifecycle-readonly-source,
  error-rules-operation-name-across-apis, error-rules-permission-shape,
  rules-operation-name-two-packages, rules-operation-versioned-apis
  (fixtures/conformance: 558).
- New rules-check case: sourceless-lifecycle-inert (16). Four rules-check
  expectations now name the owner-qualified derived name.

Java runs its rules pass before the primary-source pass, as the other ports
do, so a lifecycle on a read-only-sourced entity reports L2 and then the
source error in the same order everywhere.

ADR text from the issues #570-576 design pass (#572): ADR-0064 §4 states that
every write operation runs in one transaction with its hooks (load and lock
the row, before hook, validate and stamp, write, after hook, write-event
hook), that stores without interactive transactions refuse hooks, and that
CRUD hooks run inside the operation's transaction; ADR-0063 §7 names the
package's write-event hook. These settings and ERR_STORE_NO_INTERACTIVE_TX are
designed, not implemented: nothing in 1.3.0 reads them.
…rules-core-vocab

Union-resolves the config readers in all five ports: the ADR-0063 rules and
verify.lifecycle settings sit beside main's api block. Main's init now writes
verify.handEdits, so every port's verify reader accepts and validates it beside
verify.lifecycle, and the TypeScript schema folds the two verify blocks into one.
Both sides added a conformance corpus (rules-check, foreign-key-index), so the
stated total is 41; the site payload is regenerated from the merged tree.
… changelog) into fm/mo-rules-core-vocab

Main took ADR-0063, ADR-0064 and ADR-0065, so the business-rules ADR is now
ADR-0066 and the layering and service-seam ADR is ADR-0067; every reference
this branch added is renumbered. Counts: 574 metamodel fixtures, 43 corpora,
157 expected requirement warnings. The requirement harness and the site
payload are regenerated.
…rt (ADR-0066)

The Rust preview port registers api.*, operation.*, binding.* and transition.*
and runs the same loader rules as the other five ports, with the same messages.
It stays byte-identical on registry-conformance and passes the whole metamodel
corpus (574 of 574, ledger empty; minPassing raised from 526).

- providers: the api and transition families, and api as a root child.
- loader: @inputRef and @outputRef are reference-bearing, except on a transition.
- validate/rules.rs: the rules pass (L1 to L10, P1, P2, O0 to O6, B1, B2), run
  after reporting as the reference does.
- config: the rules block and verify.lifecycle.unreachable are read and
  validated strictly.
- codegen: a rules_inert test holds the entity generator to byte-identical
  output with and without the vocabulary.

Rust has no verify, so the rules gate does not run there; the docs say so.

Also fixes a Python verify-rules test that compared gen output as well as
verify output, which differs once an unchanged run skips (ADR-0064).
…n the same-operation check

Two operations of one package that both carry a list or map where a name
belongs are not the same operation in the TypeScript reference, which
compares such values by identity. The Rust port compared them by value and
so skipped the name-collision error (O6) for that already-broken model.
…r widening

The declared-function check accepts Postgres's implicit numeric widening, so an
integer argument onto a bigint parameter is no longer a finding. The live-Postgres
test still asserted that it was, and has failed on main since that change. It now
pins the widened call as clean and uses a text parameter for the unrelated-type case.
@dmealing
dmealing merged commit 8ed960d into main Nov 20, 2026
10 checks passed
@dmealing
dmealing deleted the fm/mo-rules-core-vocab branch November 20, 2026 02:20
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