Repository navigation
Conversation
… routes (#566) * fix(python): generated routes hand the repository only the validated input (1.2.1) The generated FastAPI create, PATCH and PUT handlers validated the body against <Entity>Create / <Entity>Patch and then passed the RAW body to the repository. Pydantic ignores undeclared keys and the input models leave out server-owned fields, so a client-sent id, a readOnly field and a made-up field such as isAdmin all reached the write. Security fix. Each handler (plain and TPH per-subtype) now rebinds dto to the keys the input model validated, at every depth, before any repository call, as the TypeScript routes do. Undeclared and non-settable keys are dropped silently, never 400'd, so a client sending an extra harmless field keeps working; values stay the body's own, so repositories see the same value types as in 1.2.0. Python package version 1.2.1 only; CHANGELOG entry under Security. Regression gate: tests/integration/test_generated_router_validated_input.py. * no-mistakes(document): python routes pass only validated input * no-mistakes(lint): regenerate showcase site payload for PyPI 1.2.1
…2.x security) (#568) * fix: generated create routes store only client-settable fields (1.2.x security) Python 1.2.1 stopped its generated routes from handing raw request input to the repository. The same audit found related create-path holes in 1.2.0 in the other four ports; this closes each in its own idiom. Server-owned values are dropped silently, never answered with 400. - Java (codegen-spring): create strips a generated id, readOnly and derived fields; a TPH per-subtype create also strips the body discriminator and sibling-subtype fields. - Kotlin (codegen-kotlin): create skips readOnly/derived columns; a TPH per-subtype create writes only the route subtype's own columns. - C# (MetaObjects.Codegen): every readOnly property shape gets a private setter; create resets a generated id, the TPH discriminator and M:N navigations before Add. - TypeScript (codegen-ts): the update schema omits primary-key fields, so PUT/PATCH can no longer re-key a row with an assigned key. Proof: new shared api-contract scenarios (core + TPH input-server-owned, TPH foreign discriminator) and a readOnly `role` field in secret-fields, run in every port's generated lane and the reference lanes; a new `unset` assertion key in all five harnesses. In-memory test repositories now store what they are handed, so the scenarios fail on the 1.2.0 generators. Proposed versions (not published): npm 1.2.2, NuGet 1.2.2, Maven 8.2.2; PyPI unchanged at 1.2.1. metamodelVersion unchanged. * fix: keep a @required readOnly field creatable in C# and Java generated create Pre-gate review follow-ups to the 1.2.x create-input patch: - C#: the required-key check skips readOnly fields (the private setter never binds them), and create validation ignores a violation naming only a @required readOnly member, as Java's SERVER_OWNED_ON_CREATE does. - Java: the create-validation server-owned set covers every DTO component, so a nulled readOnly or derived value-object column no longer 400s. - TypeScript: drop the now-dead PK guard in the update-schema nullable arm and list the PK rule in updateSchemaFields' doc comment. * no-mistakes(review): apply reviewer inline fixes * no-mistakes(review): Kotlin readOnly create fix + C# reset skip * no-mistakes(document): docs: finish stale corpus counts from input fix
…ases from release branches (#578) * fix(csharp): a frozen node's memoized reads are safe across threads MetaData.Cached stored derived reads in a plain Dictionary. A loaded model is shared across threads, so two concurrent first reads of one node could corrupt it, and every later read then threw "Operations that change non-concurrent collections must have exclusive access". The cache is now a ConcurrentDictionary; a racing first read keeps the first stored value. Brought onto release/1.2 from main's fix (a266a51) for the 1.2.2 patch. * feat(release): cut a patch from a release/<major>.<minor> maintenance branch release.mjs and finish-release.mjs refused any branch but main, so a patch on a line main has moved past could not go through its own guarded scripts. Both now accept release/<major>.<minor> as well (one shared rule in scripts/lib/release-branch.mjs): the version must be on that branch's own line, every push goes to that branch, and finish-release's sync check compares HEAD with origin/<branch>. Every other gate is unchanged. docs/RELEASING.md gains the maintenance-branch section, including that the site deploys from the newest vN.N.N tag wherever it was cut. * no-mistakes(review): gate latest-regression before npm publish; clean unpushed-branch die * no-mistakes(review): refuse an rc of an already-shipped version * no-mistakes(document): docs: fix RELEASING.md main-only release claims
The ts-fast lane (and so --quick, --only ts and the no-mistakes Test step) ran the full Stryker pass over all six metadata files on every run: 10-45 minutes of CPU per gate round on a loaded host, most of that step's wall time. The step now diffs the stryker.conf.mjs `mutate` list against the merge base with the base branch (MO_CI_MUTATION_BASE, else origin/$GITHUB_BASE_REF, else whichever of origin/main and origin/release/* HEAD is closest to) and runs `stryker run --mutate` on only the changed files. When none changed it prints a SKIP naming the base. When no base resolves, or stryker.conf.mjs itself changed, it says so and runs the full pass. Thresholds and concurrency are unchanged; the list stays in stryker.conf.mjs only. The full pass stays: the flagless run's mutation lane, a new `--only mutation` section for release prep and on demand, and conformance.yml (tags, nightly, dispatch) via MO_CI_MUTATION_SCOPE=full. Stryker's sandbox goes under DEV_SCRATCH when that names a directory, and is removed afterwards.
…chet (ADR-0063) Generators own their layout; formatters become test oracles only (ADR-0063). This change lands the foundation and converts no generator, so generated output is unchanged. - spec/code-writer.md: the shared writer contract (lines and blocks, blank-line requests, snippets, fit-or-break lists, output form, and the TypeScript dialect's import collection). - fixtures/writer-conformance/: 40 cases (30 core, 10 TypeScript), the 35th shared corpus. - CodeWriter and TsWriter (codegen-ts/src/writer/), at 120 columns, exported from the package root and the engine entry and listed in eject.engineSurface. TsWriter accepts ts-poet Code fragments and collects their imports, so generators can convert one function at a time. - Layout ratchet: an AST walk (ts.createSourceFile) over generator source that flags newline and indentation literals, newline joins and repeat-built indentation, resolving same-file constants. It has its own catch/pass cases. The allowlist names all 74 unconverted files with reasons, fails on stale entries and may only shrink against the merge base.
…classing (ADR-0063) CodeWriter and TsWriter keep no private members: their steps are protected methods (piece, breakAt, fits, writeHeader, writeImports, writeImport, orderModules), so a subclass overrides one and keeps the rest. ADR-0063 item 7 and spec/code-writer.md state that reference generators take the same shape, one overridable method per piece of output, and that these methods are not a stability contract. A test shows a subclass overriding orderModules.
* feat(codegen): skip gen when nothing changed, in every port (ADR-0062) - gen builds a key from the loaded model (each root node in canonical effective form, rolled up per package) plus the generators' identity (built engine code, config, owned generators, templates, declared extra inputs, project config, output-changing flags), before anything renders. When it matches the last successful run and every generated file still holds that run's bytes, gen renders and writes nothing. --force (Maven: -Dmetaobjects.force=true) turns it off; a generator that cannot declare its inputs opts out (cache: false or the port's equivalent). - verify --codegen always renders in CI; locally it may answer "no drift" from the key and the manifest, --full forces a render. When it renders, every port compares in memory: no rendered temp tree (Java/Kotlin now capture through GeneratedFileWriter). - The hash manifest is loaded once and written once per run, only when it changed (TypeScript, Python, C#). Identical bytes are never rewritten in any port. Python gen no longer reports unchanged files as written. - TypeScript runs git merge-file only for a file edited by hand, and deletes its temporaries in a finally, under $DEV_SCRATCH when set. - fixtures/codegen-skip-conformance/cases.json: 25 shared cases run by every port. * test(python): non-prompt targets rewrite nothing and save no manifest when unchanged Two targets, four generators: a forced run over unchanged output keeps every mtime and saves no manifest; a first run saves it once. Also corrects a stale comment in verify --codegen, which renders in memory. * no-mistakes(review): apply reviewer inline fixes * no-mistakes(review): Track unrecorded outputs in the skip key * no-mistakes(review): Track outside-root outputs in TS skip key * no-mistakes(review): Store no skip key after refused orphan sweep * no-mistakes(review): Hash YAML sources when docs-site is wired * no-mistakes(document): document gen skip and in-memory verify * no-mistakes(document): document gen skip in llms mirror * no-mistakes(lint): Update corpora count to 35 in site payload and AGENTS.md * test(agent-context): regenerate conformance expected copies The skill references in agent-context/ now describe verify --codegen as rendering in memory. Refresh the byte-for-byte expected mirrors to match.
…oundation-1-2 # Conflicts: # CHANGELOG.md # spec/decisions/README.md
…and a thrown merge leaves no temp file #585 added the fast path and per-merge temp cleanup; these decideAndWrite-level tests pin the two cases it left untested: an unedited file regenerates with META_GEN_GIT pointing at a missing binary (so any spawn would throw) and advances its snapshot and hash, and a merge that throws GitMissingError leaves nothing in mergeTempDir(). Clean merge and conflict are re-asserted at the same level.
…t ratchet release/1.2 brought in src/model-hash.ts (ADR-0062), which joins sorted lines with a newline to feed sha256. That text is hash input, never a file, so it is exempt like overwrite-policy.ts rather than an unconverted generator.
…d corpora) Both branches moved the corpus count from 34 to 35, so the merge kept 35. With both corpora present the count is 36.
Member
Author
|
This work moved to #587, which targets 1.3.0 on |
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
CodeWriterandTsWritertocodegen-tsand exported both, with the engine surface and generator registry fixture updated.CodeWriterbuilds output in memory. It owns indentation, treats blank lines as requests (collapsed, and dropped at file start and end, after an opener and before a closer), normalizes line endings, and prints a list on one line when it fits, otherwise one item per line with a trailing comma.TsWriteradds import collection and sorting, doc comments, and a 120-column default, and accepts existingCodefragments so generators can convert one at a time. Both classes are non-final with overridable methods, so adopters can extend reference generators by subclassing. No generator is converted and generated output is unchanged.ADR-0063(generators own layout; formatters are test oracles only; overridable methods may change between minor versions) andspec/code-writer.mddescribe the design. The newfixtures/writer-conformance/corpus holds 41 JSON cases, run bywriter-conformance.test.ts.writer-ts.test.tscoversTsWriter, including a subclass overriding one method.joinandjoinCodecalls with a newline separator, andrepeatcalls that build indentation. It resolves same-file constants, soconst NL = "\n"cannot hide a violation. It has its own positive and negative cases. Its allowlist lists every unconverted generator file with a written reason, and a test fails if an allowlisted file no longer needs its entry.AGENTS.md,CHANGELOG.mdanddocs/CONFORMANCE.mdare updated to match.Validation
After validation
This PR took one no-mistakes run. These commits came after it:
release/1.2, which brings in feat(codegen): skip gen when nothing changed, in every port #585 (gen skip, ADR-0062). The conflicts inCHANGELOG.mdandspec/decisions/README.mdwere both-sides additions and kept both.no-mistakes axi triage --post-mergejudged the resolution docs-only, so no new run was needed.b6dec3694from the merge fast-path lane as019f921a4. It is tests only, with no production lines: an unedited file never spawnsgit merge-fileand its hash advances, and a thrown merge leaves no temp file (codegen-ts/test/overwrite-policy/merge-fastpath.test.ts).codegen-ts/src/model-hash.ts(from feat(codegen): skip gen when nothing changed, in every port #585) in the layout ratchet's allowlist. It joins sorted lines with a newline to build the text the gen skip key hashes. That text is never written to a file, so likeoverwrite-policy.tsit is exempt, not an unconverted generator. The ratchet caught it on the merge, as intended.docs/CONFORMANCE.md,AGENTS.mdand the site payload say 36.scripts/ci-local.sh --quickwas run after the merge. Every gate passed except the site payload one, which was only the stale count. After the count commit, that gate (bun test scripts/siteandbuild-site-payload.ts --check) passed, and the pre-push build and typecheck were clean.Risk Assessment
✅ Low: The fix round is a small, correct reorder of the line-break check in put() plus one matching fixture case and a case-count doc update. No generator uses the writer yet, so no generated output changes.
Testing
I ran the real writer through a driver script, and ran the real ratchet against deliberately bad generator source. Thescripts/ci-local.shbaseline had already passed before I started. - TsWriter (live): one realistic TS file mixing ts-poetCodefragments and collected imports came out sorted, had no trailing whitespace, and ended in a single newline. It compiled with no syntax diagnostics, and a long call broke one argument per line with trailing commas. - Error codes (live):line("a;\n"),"a;\r\n","\n", a bare\rand an interior newline all throwERR_WRITER_NEWLINE_IN_LINE. Unclosed block, unbalanced close and import conflict also throw their documented codes. - Subclassing (live): a subclass overridingwriteHeaderand another overridingfitsboth changed the output, as the extension-by-subclassing requirement asks. - Ratchet (live):analyzeSourcecaught a newline hidden behind a chain of constants and an indentation.repeat. It ignored comments and writer-based code. I appended hand-typed layout to a clean generator file (src/reference/callable.ts) and the real ratchet test failed, naming the file and lines. After I reverted, it passed again and the worktree is clean. - Regression:codegen-tsbun testpassed (3000 tests, 0 failures).scripts/ci-local.sh --quickpassed (ts build and typecheck, TypeScript conformance, ts unit suites, hygiene gates, mutation on changed files). - Not run: the C#, Java, Kotlin and Python lanes of the flaglessci-local.sh. The change is TypeScript-only and converts no generator. A mixedcall(..., [props()])that is too long for one line prints asz.object(then{on its own line, rather thanz.object({. This follows spec/code-writer.md as written and is not a defect, but you may want a "hug" rule later; I raised it as an info finding.Evidence: writer live driver output
Evidence: ratchet analyzer driver output
Evidence: ratchet failing on injected hand-typed layout
Evidence: codegen-ts full suite
Evidence: ci-local --quick
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
server/typescript/packages/codegen-ts/src/writer/code-writer.ts:227-put()tests for a line break only afterflat(piece).trimEnd(). A trailing line break is stripped before theERR_WRITER_NEWLINE_IN_LINEcheck. Sow.line("a;\n"),w.line("a;\r\n")andw.line("\n")do not throw: the first two writea;, and the last becomes a blank-line request. spec/code-writer.md says line text containing a line break (\n,\r\nor\r) isERR_WRITER_NEWLINE_IN_LINE, with no trailing exception. The common hand-typed form, a template literal ending in\n, passes silently instead of being refused. The other ports' writers will implement the spec as written, so they would throw on input this one accepts. The existing caseerror-newline-in-lineonly covers an interior break ("a;\nb;"), so the gap is untested. Fix: runANY_LINE_BREAK.teston the untrimmedflat(piece)beforetrimEnd(), and add a fixture case with a trailing newline. The same check also coversTsWriter.code/pieceinput routed throughline()(src/writer/ts-writer.ts:129-140), since it all goes throughput.🔧 Fix applied.
✅ Re-checked - no issues remain.
call()whose only argument is aprops()literal that is too long for one line prints asz.object(then{on its own line, instead of the idiomaticz.object({. This follows the spec as written (the last list breaks one item per line), so it is not a defect. If the later conversions should read as a formatter would write them, a hug rule for a sole object or array argument would fix it.scripts/ci-local.sh --only ts-fast --only ts-unit --strict-toolchainsbun testin server/typescript/packages/codegen-ts, for writer-conformance, writer-ts and layout-ratchet tests (100 pass)bun <evidence>/drive.ts: live TsWriter/CodeWriter driver for output shape, newline refusal, error codes, subclass overridesbun <evidence>/ratchet-drive.ts: analyzeSource on constant indirection, comments, writer code, indentation repeatInjected hand-typed layout into src/reference/callable.ts and ranbun test test/layout-ratchet.test.ts: it failed as intended. Reverted, passed again.bun testin server/typescript/packages/codegen-ts (3000 pass, 0 fail)scripts/ci-local.sh --quick(exit 0)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.