Repository navigation
feat(codegen-ts): add rules-names and contract-types generators - #638
Merged
Merged
Conversation
rulesNamesFile() writes one rules.names.ts per metadata package that declares a lifecycle or an operation (ADR-0067 layer 0): each lifecycle's states, initial and terminal states and transitions, the commands derived from unclaimed transitions, the declared operations, the permissions they ask about and the business errors, as as-const values and literal unions. The names come from the derivations meta verify's rules gate checks, now shared in metadata (core/transition/commands.ts) and read by both the gate and the generator's engine walk (codegen-ts rules-walk.ts). The generator is ejectable, TypeScript-only for now, and silent for a model without the rules vocabulary.
…nce scenario (L-TS-3) ObjectManager.guardedUpdate makes a lifecycle transition's write in one statement: UPDATE ... SET state = :to WHERE key = :id AND state IN (:from) [AND condition]. The condition grammar is attr.expression's CHECK subset, compiled to new not/compare/nullTest WhereClause kinds on all three bundled drivers; the in-memory driver follows SQL three-valued logic. fixtures/persistence-conformance/queries/guarded-update.yaml holds every store driver to it. TypeScript runs it; Java, Kotlin, C# and Python defer it to their own rules-layer rows.
contractTypes() writes ADR-0067's contract types layer: the shapes a caller and a service exchange, with no persistence mapping in them. Every module imports zod only. - <Entity>.contract.ts: the read schema and type, the create and update schemas, and the typed create and patch inputs. - <Projection>.contract.ts: the read shape. - The value modules those shapes reach, byte-identical to the entity generator's, so the two collapse into one file when both run. - <pkg>/operations.contract.ts: each declared operation's input, output and business errors. - errors.contract.ts: the shell and contract wire codes, their HTTP statuses, and the error bodies. The field schemas come from the entity generator's own renderers, and the tests hold each entity's contract read type equal to the entity file's on postgres, sqlite and mysql. Two exceptions are named in the test: a TPH base, and a physical-only jsonb column. What it covers is the engine walk (contract-walk.ts), so the generator is ejectable. It is TypeScript-only for now, and it moves no existing generator's output.
…fixtures sum L-TS-3 added a persistence scenario and moved the table's persistence row to 68, but the prose sum under "Orphaned fixtures" still said 67, which the site counts gate refuses.
… as a server language (G1) The assembler now also runs at build time, once per stack a port's own agent-docs command serves: each server language alone and Java with Kotlin, each with no client, React, React with TanStack or Angular (28 stacks). The result is committed at agent-context-shipped/: a manifest listing each stack's files by project path, and each distinct file once under files/, named by its content hash (101 files, about 1.1 MB). A port's package embeds the tree; its command finds the stack by id, pins the guide links to its release tag with one text replacement, and writes the files, so a C#, JVM, Python or Rust project needs no Node for them (1.3.0 design call 17, ADR-0033 Amendment 1). agent-context-shipped/README.md is the contract. - sdk: buildShippedAgentContext(), materializeShippedStack(), shippedStackId() and shippedTreeFiles(), and scripts/build-shipped-agent-context.ts (writes only changed bytes; --check exits 1 naming each stale file). - shipped.test.ts: the committed tree is byte-for-byte what the build writes; every stack, materialized as a port would, equals assemble() for it with the release ref; the shared agent-context-conformance goldens come out of the tree unchanged; an unshipped stack is refused, naming the shipped ones. - Rust: SERVER_LANGS gains rust; `--server rust` (alias rs) is accepted and a root Cargo.toml detects it; servers/rust.meta.json and templates/loops/rust.md give the cargo meta gen loop and the cargo meta verify step; a rust case joins fixtures/agent-context-conformance. Libraries now list Rust among their ports, and the manifest gate checks the copy Rust's build.rs embeds (server/rust/metaobjects/data/library). - The lane map routes agent-context-shipped/ to every lane.
…or] / filter[and] combinators (R0) The list-query contract (ADR-0068) made search and the combinators cross-port, but openapi.json still listed only the per-field filter parameters. The integration check exempted those names so it would not refuse them. - search: offered when the row has a field the runtime searches. That is a @filterable text rule with like in its band and no format (isSearchField, which mirrors runtime-ts searchFields). The description names those fields. - filter[or] and filter[and]: one deepObject parameter each, offered when the list has any filter. A branch nests, which a parameter schema cannot spell, so the description gives the grammar and the five-level cap. - 400 invalid_id is now listed on item GET and DELETE. The routes already answered it, and the list-query lane found the gap as soon as the document checked it. A new contract case, list-query, documents the list-query model. The list-query lane runs openApiCheck like the other generated lanes. The check now accepts a key under a deepObject parameter, and takes the names a scenario sends to show they are ignored (the cb cache-buster), in place of the blanket exemption. contract-behaviours holds the document to runtime-ts's own parser: - the searched fields equal searchFields over the generated allowlist; - the combinator grammar parses to the stated depth and fails one level past it; - a list with no filter offers neither. Goldens regenerated. The CONFORMANCE.md count of contract cases is recounted from disk: 22, which was already stale at 19 on main.
…n after rebasing onto main The audit skill's calibration and capability-checklist references changed on main (#634), after G1 built agent-context-shipped/ and added the rust agent-context case. The rebuilt tree and the rust golden take that text; the other five cases already had it.
…alid_id on update
The TypeScript runner maps an entity row's timestamp from MySQL's naive DATETIME text onto the corpus' wire form, and applies the engine mapping to single-row results (get, create, update, roundtrip) as well as lists. Python's per-engine skip now honours the port-wide EXPECTED_FAILURES, so the deferral of guarded-update to L-PY-2 holds on MySQL too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Changed
rules-names(per-package constants for lifecycle states, transitions, derived commands, operations, permissions and business errors, built from a new rules walk) andcontract-types(read, create and update shapes, operation inputs and outputs, and wire error bodies, built from a new contract walk). The OpenAPI document now describes the list query contract (?searchwhere a row has text fields,filter[or]/filter[and]combinators) and the400 invalid_idresponse on item routes. Expected OpenAPI fixtures are updated to match.ObjectManager.guardedUpdate, which moves a row's state field in one statement only when the row is in one of thefromstates and an optional@conditionholds. It returnsnullwhen nothing matches. The persistence driver gainsnot,compareandnullTestwhere clauses and an optional updatekeyclause for MySQL read-back. The sharedop: guardedUpdatepersistence scenario (fixtures/persistence-conformance/queries/guarded-update.yaml) runs through the TypeScript runner on Postgres and MySQL; the runner maps MySQL DATETIME text to the canonical form on the actual side. Ports that have not built the operation defer the scenario by name.shipped.ts, with a committedagent-context-shipped/manifest and content-addressed files) for each server language set and client choice, so non-TypeScript ports copy the files instead of re-assembling them. Rust is accepted as a server language (--server rust, detected fromCargo.toml), with a newagent-context/servers/rust.meta.jsonand a Rust loop template. Adds Rust agent-context conformance expectations.Evidence. Live evidence was inconclusive for a tooling reason (the evidence agent ran only its own structured-output schema check, no scenario of this change); local CI (
scripts/ci-local.sh --affected, 8 lanes) passed and is the evidence. The guarded-update scenario was also run by hand on MySQL (TypeScript MySQL query lane 28/0), SQLite (25/0) and Postgres.Gate runs: 2. The first run was aborted at its document step, because two test-runner fixes (MySQL DATETIME mapping, Python's per-engine deferral) were code that step could not apply. They were committed by hand, and the second run passed.
Validation
Risk Assessment
✅ Low: The change is additive and matches the stated intent. I found no concrete defect in the driver, runner, OpenAPI, generator or shipped-context code I read. I did not read the docs and fixture prose and the generated shipped-context tree, and I ran no tests.
Testing
Only a diagnostic structured-output call was made. No product scenario was driven, no commands were run, and no live validation was performed in this run.
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
scripts/ci-local.sh --affected --strict-toolchainsdiagnostic call only🔧 **Document** - 1 issue found → auto-fixed ✅
agent-context/templates/always-on.md.mustache:14- The always-on agent file says 'Java, Kotlin, C# and Python projects need Node too' and omits Rust, which this branch adds as an agent-context server language (agent-context/servers/rust.meta.json). The same sentence is asserted in server/typescript/packages/sdk/test/agent-context/assemble.test.ts:128 and baked into fixtures/agent-context-conformance/*/expected and agent-context-shipped/. It is runtime-loaded agent prompt text, so I did not reword it. Fix: add Rust to the template sentence, update the assemble test, and rebuild the shipped tree and the expected fixtures.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.