Repository navigation
feat(mongo-family): port contract spaces - #494
Conversation
📝 WalkthroughWalkthroughCentralizes reviewer output to a single per-round artifact ( ChangesAgent skills & iteration contract
Contract-space & migration multi-space
Mongo marker/runner/adapter/family
Integration tests, examples, and artifacts
Sequence DiagramsequenceDiagram
participant Orch as Orchestrator
participant Runner as MongoRunner
participant Marker as MarkerOps
participant DB as MongoDB
Orch->>Runner: executeAcrossSpaces([app, ext])
rect rgba(100, 150, 200, 0.5)
note right of Runner: App space iteration
Runner->>Runner: space = 'app'
Runner->>Runner: projectSchemaToSpace(schema, 'app')
Runner->>DB: apply per-space ops
Runner->>Marker: readMarker(db, 'app')
Marker->>DB: query _id:'app'
DB-->>Marker: doc
Marker-->>Runner: marker
Runner->>Marker: updateMarker(db, 'app', ...)
Marker->>DB: CAS update on _id:'app'
DB-->>Marker: ok
Marker-->>Runner: success
end
rect rgba(150, 100, 200, 0.5)
note right of Runner: Extension space iteration
Runner->>Runner: space = 'cipherstash'
Runner->>Runner: projectSchemaToSpace(schema, 'cipherstash')
Runner->>DB: apply per-space ops
Runner->>Marker: readMarker(db, 'cipherstash')
Marker->>DB: query _id:'cipherstash'
DB-->>Marker: doc/null
Marker-->>Runner: marker
Runner->>Marker: updateMarker(db, 'cipherstash', ...)
Marker->>DB: CAS update on _id:'cipherstash'
DB-->>Marker: ok
Marker-->>Runner: success
end
Runner-->>Orch: ok(perSpaceResults)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
|
@prisma-next/mongo-runtime
@prisma-next/family-mongo
@prisma-next/sql-runtime
@prisma-next/family-sql
@prisma-next/extension-arktype-json
@prisma-next/extension-cipherstash
@prisma-next/middleware-telemetry
@prisma-next/mongo
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/extension-postgis
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/sqlite
@prisma-next/target-mongo
@prisma-next/adapter-mongo
@prisma-next/driver-mongo
@prisma-next/contract
@prisma-next/utils
@prisma-next/config
@prisma-next/errors
@prisma-next/framework-components
@prisma-next/operations
@prisma-next/ts-render
@prisma-next/contract-authoring
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/emitter
@prisma-next/migration-tools
prisma-next
@prisma-next/vite-plugin-contract-emit
@prisma-next/mongo-codec
@prisma-next/mongo-contract
@prisma-next/mongo-value
@prisma-next/mongo-contract-psl
@prisma-next/mongo-contract-ts
@prisma-next/mongo-emitter
@prisma-next/mongo-schema-ir
@prisma-next/mongo-query-ast
@prisma-next/mongo-orm
@prisma-next/mongo-query-builder
@prisma-next/mongo-lowering
@prisma-next/mongo-wire
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder
@prisma-next/target-postgres
@prisma-next/target-sqlite
@prisma-next/adapter-postgres
@prisma-next/adapter-sqlite
@prisma-next/driver-postgres
@prisma-next/driver-sqlite
commit: |
There was a problem hiding this comment.
Actionable comments posted: 8
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
packages/2-mongo-family/9-family/src/core/control-instance.ts (1)
148-174:⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift
schemaVerify()is still contract-space blind.This path always verifies against the full introspected schema. After a multi-space apply, any direct verify of a non-app space has to drop to
strict: falseto suppress sibling collections, so strict extension-space verification is still unavailable outsideexecuteAcrossSpaces. Please thread aspace/projection through this API, or route callers through the aggregate verifier instead.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/2-mongo-family/9-family/src/core/control-instance.ts` around lines 148 - 174, schemaVerify currently always verifies against the full introspected schema, which breaks strict/extension-space checks for non-app spaces; update schemaVerify(options) to accept an optional space (or projection) and apply that projection to the introspected IR before calling verifyMongoSchema, or alternatively route callers to the aggregate verifier used by executeAcrossSpaces. Concretely: add an optional space?: string (or projection) field to the schemaVerify options, after const liveIR = await introspectSchema(db) compute a projectedIR by filtering/mapping liveIR to only include collections/entities in the requested space, then pass projectedIR (not liveIR) into verifyMongoSchema; keep existing behavior when space is undefined by passing the full liveIR, and ensure callers that need multi-space aggregation use the executeAcrossSpaces/aggregate verifier path instead.packages/3-mongo-target/1-mongo-target/src/core/mongo-runner.ts (1)
241-295:⚠️ Potential issue | 🟠 Major | 🏗️ Heavy liftMulti-space apply still leaks partial progress.
execute()persists the marker and ledger as soon as one space verifies. WhenexecuteAcrossSpaces()composes these executions sequentially, a later failure leaves earlier spaces committed — which is exactly the resume path the new tests lock in. That breaks the all-or-nothing contract-space apply semantics described in ADR 212 and makes partial advancement part of the observable API. Either defer marker/ledger writes until the aggregate completes, or give Mongo an explicit weaker contract instead of silently diverging.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/3-mongo-target/1-mongo-target/src/core/mongo-runner.ts` around lines 241 - 295, The per-space execute() is writing markers and ledger entries immediately (see markerOps.updateMarker, markerOps.initMarker and markerOps.writeLedgerEntry in mongo-runner.ts), which leaks partial progress for multi-space aggregates; change the implementation so marker/ledger writes are deferred when called from executeAcrossSpaces(): add an option/flag (e.g., deferMarkerWrites or commitMarkers) to execute()/verify flow and, when true, skip calling markerOps.updateMarker/initMarker/writeLedgerEntry and instead return the intended marker/ledger payloads to the caller; then modify executeAcrossSpaces() to collect those payloads across all spaces and only call markerOps.* once the entire aggregate succeeds (or perform a CAS-style commit for all), preserving the existing immediate-write behavior when deferMarkerWrites is false so single-space callers are unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.agents/skills/drive-orchestrate-plan/agents/reviewer.md:
- Around line 7-9: Update the top-level role description to match the Heartbeats
section by making the writable files consistent: either add
wip/heartbeats/reviewer.txt to the list of writable files alongside
reviews/code-review.md in the opening description, or remove the heartbeat write
requirement from the Heartbeats section; ensure the terms "only file it writes"
and the Heartbeats requirement reference the same set of writable artifacts
(check the header block and the Heartbeats paragraph in reviewer.md) and keep
the wording verdict-first, terse, single-artifact if you choose to retain the
original intent.
- Around line 210-213: Update the "Files modified" requirement in reviewer.md to
resolve the contradiction: change the rule that currently mandates listing only
`code-review.md` to explicitly exempt operational heartbeat files like
`wip/heartbeats/reviewer.txt` or alter the rule to require two categories
(durable writes and operational writes) so both `code-review.md` and heartbeat
files can be reported separately; ensure you update the wording around "Files
modified" and the `## Round notes` guidance so it references the new exemption
or the two-list format and include the exact filenames `code-review.md` and
`wip/heartbeats/reviewer.txt` in the new text for clarity.
In `@docs/architecture` docs/adrs/ADR 212 - Contract spaces.md:
- Around line 214-215: Update the documentation text to reference the canonical
package export path '@prisma-next/migration-tools/spaces' instead of the
non-canonical '@prisma-next/migration-tools/exports/spaces'; keep the listed
producer-side helper names (planAllSpaces, concatenateSpaceApplyInputs,
verifyContractSpaces, emitContractSpaceArtefacts, gatherDiskContractSpaceState,
detectSpaceContractDrift) intact and just change the package path so readers
import the helpers from the correct shared-plane package name.
In
`@packages/1-framework/3-tooling/cli/test/utils/contract-space-seed-phase.mongo.test.ts`:
- Around line 13-38: Remove all transient planning artefact identifiers from the
file header comment (the tokens "T4.1", "T4.2", "T4.3", "TC-12", "TC-13", and
"AC6") and replace them with plain-language descriptions of the test assertions:
state that the seed phase for a Mongo-shaped contract should produce the three
on-disk artefacts, that the read helpers (readContractSpaceContract,
readContractSpaceHeadRef, listContractSpaceDirectories) round-trip the written
values, and that re-running the seed phase with no contract changes yields
byte-identical artefacts; keep the rest of the contextual explanation about
Mongo-shaped input and canonicalisation unchanged.
In `@packages/1-framework/3-tooling/migration/src/aggregate/loader.ts`:
- Around line 340-345: The loop that records claimers pushes the same
member.spaceId multiple times if extractStorageElementNames(member.contract)
returns duplicate names; update the logic in the block using
extractStorageElementNames and elementClaimedBy so you first deduplicate the
extracted element names (e.g., convert elements to a Set or otherwise remove
duplicates) before iterating and adding member.spaceId, thereby preventing false
self-collisions in disjointnessViolation; apply the same deduplication change to
the analogous block handling lines 380-391.
In `@packages/2-mongo-family/9-family/src/core/mongo-target-descriptor.ts`:
- Around line 102-104: The inline comment in mongo-target-descriptor.ts
references a transient project artifact path
`projects/contract-spaces-mongo-port/spec.md`; remove that projects/...
reference and replace it with a durable doc link or package README (for example
point only to the existing durable doc `docs/architecture/.../10. MongoDB
Family.md` or an ADR/package README). Update the comment in
mongo-target-descriptor.ts (the comment block that currently mentions
`projects/contract-spaces-mongo-port/spec.md`) so it no longer references
transient project artifacts, keeping any remaining explanatory text but linking
exclusively to durable documentation.
In `@packages/3-mongo-target/1-mongo-target/src/core/marker-ledger.ts`:
- Around line 41-45: The comment in marker-ledger.ts that documents canonical
post-port shape references a transient milestone ID "T1.2"; remove that artifact
and replace it with a neutral description of the upgrade step (e.g., "see
readMarker's caller-side upgrade pass") so durable source comments do not
include milestone/task IDs—locate the comment near the readMarker reference and
update the text accordingly.
In `@test/integration/test/mongo/codec-rehydration-guardrail.test.ts`:
- Around line 26-49: The block comment for TC-18 (the "codec-rehydration
guardrail" test) contains transient milestone/acceptance codes ("NFR5 / AC11");
remove those references and rewrite the comment to describe the constraint
directly (e.g., explain the intent that rehydrated ops must carry all
codec-related bytes so apply-time never requires codec runtime lookup), keeping
the rest of the explanation about serializeMongoOps, re-parsing JSON, and
running against MongoFamilyInstance unchanged; ensure the revised comment
mentions the observable behavior (what the test verifies) rather than project
artifact codes.
---
Outside diff comments:
In `@packages/2-mongo-family/9-family/src/core/control-instance.ts`:
- Around line 148-174: schemaVerify currently always verifies against the full
introspected schema, which breaks strict/extension-space checks for non-app
spaces; update schemaVerify(options) to accept an optional space (or projection)
and apply that projection to the introspected IR before calling
verifyMongoSchema, or alternatively route callers to the aggregate verifier used
by executeAcrossSpaces. Concretely: add an optional space?: string (or
projection) field to the schemaVerify options, after const liveIR = await
introspectSchema(db) compute a projectedIR by filtering/mapping liveIR to only
include collections/entities in the requested space, then pass projectedIR (not
liveIR) into verifyMongoSchema; keep existing behavior when space is undefined
by passing the full liveIR, and ensure callers that need multi-space aggregation
use the executeAcrossSpaces/aggregate verifier path instead.
In `@packages/3-mongo-target/1-mongo-target/src/core/mongo-runner.ts`:
- Around line 241-295: The per-space execute() is writing markers and ledger
entries immediately (see markerOps.updateMarker, markerOps.initMarker and
markerOps.writeLedgerEntry in mongo-runner.ts), which leaks partial progress for
multi-space aggregates; change the implementation so marker/ledger writes are
deferred when called from executeAcrossSpaces(): add an option/flag (e.g.,
deferMarkerWrites or commitMarkers) to execute()/verify flow and, when true,
skip calling markerOps.updateMarker/initMarker/writeLedgerEntry and instead
return the intended marker/ledger payloads to the caller; then modify
executeAcrossSpaces() to collect those payloads across all spaces and only call
markerOps.* once the entire aggregate succeeds (or perform a CAS-style commit
for all), preserving the existing immediate-write behavior when
deferMarkerWrites is false so single-space callers are unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 932eb652-a48d-4d59-8cea-2b101d40ccc0
⛔ Files ignored due to path filters (3)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlprojects/contract-spaces-mongo-port/plan.mdis excluded by!projects/**projects/contract-spaces-mongo-port/spec.mdis excluded by!projects/**
📒 Files selected for processing (43)
.agents/skills/drive-orchestrate-plan/SKILL.md.agents/skills/drive-orchestrate-plan/agents/implementer.md.agents/skills/drive-orchestrate-plan/agents/reviewer.md.agents/skills/drive-orchestrate-plan/templates/delegate-implement.md.agents/skills/drive-orchestrate-plan/templates/delegate-review.mddocs/architecture docs/adrs/ADR 212 - Contract spaces.mddocs/architecture docs/subsystems/10. MongoDB Family.mddocs/architecture docs/subsystems/6. Ecosystem Extensions & Packs.mddocs/architecture docs/subsystems/7. Migration System.mdpackages/1-framework/1-core/framework-components/src/control/control-migration-types.tspackages/1-framework/3-tooling/cli/test/utils/contract-space-seed-phase.mongo.test.tspackages/1-framework/3-tooling/migration/src/aggregate/loader.tspackages/1-framework/3-tooling/migration/src/aggregate/project-schema-to-space.tspackages/1-framework/3-tooling/migration/test/aggregate/loader.test.tspackages/1-framework/3-tooling/migration/test/aggregate/project-schema-to-space.test.tspackages/2-mongo-family/9-family/package.jsonpackages/2-mongo-family/9-family/src/core/control-instance.tspackages/2-mongo-family/9-family/src/core/control-types.tspackages/2-mongo-family/9-family/src/core/mongo-target-descriptor.tspackages/2-mongo-family/9-family/src/exports/control.tspackages/2-mongo-family/9-family/test/control-instance.descriptor-self-consistency.test.tspackages/2-mongo-family/9-family/vitest.config.tspackages/3-mongo-target/1-mongo-target/src/core/marker-ledger.tspackages/3-mongo-target/1-mongo-target/src/core/mongo-runner.tspackages/3-mongo-target/1-mongo-target/src/exports/control.tspackages/3-mongo-target/1-mongo-target/test/marker-ledger.test.tspackages/3-mongo-target/2-mongo-adapter/src/core/runner-deps.tspackages/3-mongo-target/2-mongo-adapter/test/mongo-runner.schema-verify.integration.test.tspackages/3-mongo-target/2-mongo-adapter/test/mongo-runner.test.tstest/integration/test/cli.mongo-db-sign.e2e.test.tstest/integration/test/cli.mongo-db-verify.e2e.test.tstest/integration/test/contract-space-fixture-mongo/README.mdtest/integration/test/contract-space-fixture-mongo/constants.tstest/integration/test/contract-space-fixture-mongo/contract.tstest/integration/test/contract-space-fixture-mongo/control.tstest/integration/test/contract-space-fixture-mongo/descriptor.test.tstest/integration/test/contract-space-fixture-mongo/migrations.tstest/integration/test/mongo/aggregate-e2e.test.tstest/integration/test/mongo/codec-rehydration-guardrail.test.tstest/integration/test/mongo/db-verify-sign.test.tstest/integration/test/mongo/family-read-marker-per-space.test.tstest/integration/test/mongo/migration-e2e.test.tstest/integration/test/mongo/multi-space-runner.test.ts
68ae172 to
65f5fff
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (3)
.agents/skills/drive-orchestrate-plan/agents/reviewer.md (2)
210-211:⚠️ Potential issue | 🟠 Major | ⚡ Quick win“Files modified” rule still conflicts with mandatory heartbeat writes.
The return shape mandates listing only
code-review.md, while the protocol requires writingwip/heartbeats/reviewer.txt. Please explicitly exclude heartbeat files from this list (or split durable vs operational writes) to avoid an impossible reporting rule.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.agents/skills/drive-orchestrate-plan/agents/reviewer.md around lines 210 - 211, Update the rule text that requires listing "code-review.md" so it explicitly excludes ephemeral heartbeat files (e.g., "wip/heartbeats/reviewer.txt") or split the return into two lists (durable files and operational/heartbeat files); locate the rule wording around the "Files modified" bullet in reviewer.md and change it to either: "must list code-review.md (and only durable files; exclude wip/heartbeats/*)" or add a separate "Operational writes" section that allows heartbeat entries, ensuring the rule no longer forces an impossible single-list return that would include heartbeat files.
7-8:⚠️ Potential issue | 🟠 Major | ⚡ Quick winWritable-file contract is internally inconsistent.
Line 7-Line 8 says the agent writes only
reviews/code-review.md, but Line 15 also requires heartbeat writes towip/heartbeats/reviewer.txt. Please make the opening constraint explicitly match the heartbeat exception so the protocol is not self-contradictory.Also applies to: 15-15
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.agents/skills/drive-orchestrate-plan/agents/reviewer.md around lines 7 - 8, Update the writable-file contract in .agents/skills/drive-orchestrate-plan/agents/reviewer.md so the opening constraint explicitly permits the heartbeat exception: change the sentence that currently states the agent writes only `reviews/code-review.md` to state it writes only `reviews/code-review.md` (and, as an exception, heartbeat files under `wip/heartbeats/`, e.g. `wip/heartbeats/reviewer.txt`); ensure the same clarification appears where the contract is referenced near the line that mentions `wip/heartbeats/reviewer.txt` so the two statements are consistent.packages/1-framework/3-tooling/cli/test/utils/contract-space-seed-phase.mongo.test.ts (1)
13-38:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winRemove transient planning IDs from the file header comment.
Line 14 and Line 32-37 still include milestone/task/AC tokens (
T4.*,TC-*,AC6). Please replace them with plain-language test intent.As per coding guidelines, "Source-code comments must not reference transient project artifacts including ... milestone-task IDs ... [and] milestone-named acceptance criteria."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/1-framework/3-tooling/cli/test/utils/contract-space-seed-phase.mongo.test.ts` around lines 13 - 38, Remove the transient planning IDs from the file header comment: delete tokens like "T4.*", "TC-*", and "AC6" and replace them with plain-language descriptions of the test intent (e.g., describe that the file verifies the Mongo-shaped contract is accepted, artifact generation, read/round-trip helpers, and idempotent re-seeding) so the top comment in this test file is free of milestone/task/acceptance IDs; update the sentences that currently read "T4.1 (TC-12): ...", "T4.2: ...", and "T4.3 (TC-13 / AC6): ..." to equivalent human-readable intent statements within the same header comment block.
🧹 Nitpick comments (2)
packages/1-framework/3-tooling/cli/test/utils/contract-space-seed-phase.mongo.test.ts (1)
117-118: ⚡ Quick winPrefer direct assertions over defensive/optional access in test invariants.
Since these values are expected to exist after setup, avoid
if (!record) throw ...and?.access; assert presence, then use non-null access for clearer failures.Suggested cleanup
- const [record] = out.seeded; - if (!record) throw new Error('unreachable'); + const record = out.seeded[0]!; @@ - expect(headRef?.hash).toBe(headHash); - expect(headRef?.invariants).toEqual(['inv:a', 'inv:b']); + expect(headRef).toBeDefined(); + expect(headRef!.hash).toBe(headHash); + expect(headRef!.invariants).toEqual(['inv:a', 'inv:b']); @@ - expect(second.seeded[0]?.action).toBe('unchanged'); + expect(second.seeded[0]!.action).toBe('unchanged');As per coding guidelines, "Prefer assertions over defensive checks when data is guaranteed to be valid ... Remove optional chaining ... for properties that are guaranteed to exist."
Also applies to: 146-147, 176-176
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/1-framework/3-tooling/cli/test/utils/contract-space-seed-phase.mongo.test.ts` around lines 117 - 118, Replace defensive runtime checks with direct test assertions: instead of guarding extraction with "if (!record) throw ..." and using optional chaining on guaranteed values (e.g., the destructured const [record] = out.seeded and subsequent property access), assert presence using the test assertion utility (e.g., expect(record).toBeDefined() or equivalent) and then access properties directly (remove ?.). Apply the same change for the other occurrences mentioned (the checks around lines handling out.seeded at the second and third locations), updating the tests that reference record and other guaranteed values to assert existence first and then use non-null property access.packages/3-mongo-target/1-mongo-target/test/marker-ledger.test.ts (1)
575-590: 💤 Low valueTest is misplaced in the
readAllMarkersdescribe block.This test exercises
readMarker(db, 'marker')behavior, notreadAllMarkers. The test logic is correct (verifying that a legacy doc withoutspacefield is not interpreted as the marker for a space named'marker'), but it belongs in thereadMarkerdescribe block or the legacy upgrade suite for clarity.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/3-mongo-target/1-mongo-target/test/marker-ledger.test.ts` around lines 575 - 590, The test titled "a non-app `readMarker(space)` for a space id colliding with the legacy `_id: \"marker\"` returns null..." is in the `readAllMarkers` describe block but exercises `readMarker(db, 'marker')`; move this it(...) block out of the `readAllMarkers` describe and into the `readMarker` describe (or the legacy upgrade suite) so the test context matches the exercised function (`readMarker`) and keep the existing assertion logic unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@packages/1-framework/3-tooling/migration/src/aggregate/project-schema-to-space.ts`:
- Around line 57-67: The checks that branch to pruneRecord for
tables/collections use typeof === 'object' which also matches arrays, so update
the conditions in project-schema-to-space.ts to exclude arrays (e.g. change
"typeof schemaObj.tables === 'object' && schemaObj.tables !== null" to also
require "!Array.isArray(schemaObj.tables)"); do the same for the collections
record branch and the analogous block around lines 88-95. This preserves the
fallback behavior by ensuring arrays hit the Array.isArray branches
(pruneCollectionsArray) or fall through unchanged instead of being treated as
records by pruneRecord.
---
Duplicate comments:
In @.agents/skills/drive-orchestrate-plan/agents/reviewer.md:
- Around line 210-211: Update the rule text that requires listing
"code-review.md" so it explicitly excludes ephemeral heartbeat files (e.g.,
"wip/heartbeats/reviewer.txt") or split the return into two lists (durable files
and operational/heartbeat files); locate the rule wording around the "Files
modified" bullet in reviewer.md and change it to either: "must list
code-review.md (and only durable files; exclude wip/heartbeats/*)" or add a
separate "Operational writes" section that allows heartbeat entries, ensuring
the rule no longer forces an impossible single-list return that would include
heartbeat files.
- Around line 7-8: Update the writable-file contract in
.agents/skills/drive-orchestrate-plan/agents/reviewer.md so the opening
constraint explicitly permits the heartbeat exception: change the sentence that
currently states the agent writes only `reviews/code-review.md` to state it
writes only `reviews/code-review.md` (and, as an exception, heartbeat files
under `wip/heartbeats/`, e.g. `wip/heartbeats/reviewer.txt`); ensure the same
clarification appears where the contract is referenced near the line that
mentions `wip/heartbeats/reviewer.txt` so the two statements are consistent.
In
`@packages/1-framework/3-tooling/cli/test/utils/contract-space-seed-phase.mongo.test.ts`:
- Around line 13-38: Remove the transient planning IDs from the file header
comment: delete tokens like "T4.*", "TC-*", and "AC6" and replace them with
plain-language descriptions of the test intent (e.g., describe that the file
verifies the Mongo-shaped contract is accepted, artifact generation,
read/round-trip helpers, and idempotent re-seeding) so the top comment in this
test file is free of milestone/task/acceptance IDs; update the sentences that
currently read "T4.1 (TC-12): ...", "T4.2: ...", and "T4.3 (TC-13 / AC6): ..."
to equivalent human-readable intent statements within the same header comment
block.
---
Nitpick comments:
In
`@packages/1-framework/3-tooling/cli/test/utils/contract-space-seed-phase.mongo.test.ts`:
- Around line 117-118: Replace defensive runtime checks with direct test
assertions: instead of guarding extraction with "if (!record) throw ..." and
using optional chaining on guaranteed values (e.g., the destructured const
[record] = out.seeded and subsequent property access), assert presence using the
test assertion utility (e.g., expect(record).toBeDefined() or equivalent) and
then access properties directly (remove ?.). Apply the same change for the other
occurrences mentioned (the checks around lines handling out.seeded at the second
and third locations), updating the tests that reference record and other
guaranteed values to assert existence first and then use non-null property
access.
In `@packages/3-mongo-target/1-mongo-target/test/marker-ledger.test.ts`:
- Around line 575-590: The test titled "a non-app `readMarker(space)` for a
space id colliding with the legacy `_id: \"marker\"` returns null..." is in the
`readAllMarkers` describe block but exercises `readMarker(db, 'marker')`; move
this it(...) block out of the `readAllMarkers` describe and into the
`readMarker` describe (or the legacy upgrade suite) so the test context matches
the exercised function (`readMarker`) and keep the existing assertion logic
unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 269ad31d-acd4-4ba6-9e9a-a1f411b4a2ad
⛔ Files ignored due to path filters (2)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlprojects/contract-spaces-mongo-port/plan.mdis excluded by!projects/**
📒 Files selected for processing (29)
.agents/skills/drive-orchestrate-plan/SKILL.md.agents/skills/drive-orchestrate-plan/agents/implementer.md.agents/skills/drive-orchestrate-plan/agents/reviewer.md.agents/skills/drive-orchestrate-plan/templates/delegate-implement.md.agents/skills/drive-orchestrate-plan/templates/delegate-review.mddocs/architecture docs/adrs/ADR 212 - Contract spaces.mddocs/architecture docs/subsystems/10. MongoDB Family.mddocs/architecture docs/subsystems/6. Ecosystem Extensions & Packs.mddocs/architecture docs/subsystems/7. Migration System.mdpackages/1-framework/1-core/framework-components/src/control/control-migration-types.tspackages/1-framework/3-tooling/cli/test/utils/contract-space-seed-phase.mongo.test.tspackages/1-framework/3-tooling/migration/src/aggregate/loader.tspackages/1-framework/3-tooling/migration/src/aggregate/project-schema-to-space.tspackages/1-framework/3-tooling/migration/test/aggregate/loader.test.tspackages/1-framework/3-tooling/migration/test/aggregate/project-schema-to-space.test.tspackages/2-mongo-family/9-family/package.jsonpackages/2-mongo-family/9-family/src/core/control-instance.tspackages/2-mongo-family/9-family/src/core/control-types.tspackages/2-mongo-family/9-family/src/core/mongo-target-descriptor.tspackages/2-mongo-family/9-family/src/exports/control.tspackages/2-mongo-family/9-family/test/control-instance.descriptor-self-consistency.test.tspackages/2-mongo-family/9-family/vitest.config.tspackages/3-mongo-target/1-mongo-target/src/core/marker-ledger.tspackages/3-mongo-target/1-mongo-target/src/core/mongo-runner.tspackages/3-mongo-target/1-mongo-target/src/exports/control.tspackages/3-mongo-target/1-mongo-target/test/marker-ledger.test.tspackages/3-mongo-target/2-mongo-adapter/src/core/runner-deps.tspackages/3-mongo-target/2-mongo-adapter/test/mongo-runner.schema-verify.integration.test.tspackages/3-mongo-target/2-mongo-adapter/test/mongo-runner.test.ts
✅ Files skipped from review due to trivial changes (6)
- packages/2-mongo-family/9-family/package.json
- packages/2-mongo-family/9-family/src/exports/control.ts
- docs/architecture docs/subsystems/6. Ecosystem Extensions & Packs.md
- .agents/skills/drive-orchestrate-plan/templates/delegate-implement.md
- docs/architecture docs/subsystems/7. Migration System.md
- packages/2-mongo-family/9-family/vitest.config.ts
🚧 Files skipped from review as they are similar to previous changes (15)
- packages/3-mongo-target/1-mongo-target/src/exports/control.ts
- packages/3-mongo-target/2-mongo-adapter/src/core/runner-deps.ts
- .agents/skills/drive-orchestrate-plan/agents/implementer.md
- packages/1-framework/3-tooling/migration/src/aggregate/loader.ts
- packages/2-mongo-family/9-family/src/core/control-types.ts
- packages/3-mongo-target/2-mongo-adapter/test/mongo-runner.schema-verify.integration.test.ts
- packages/1-framework/3-tooling/migration/test/aggregate/project-schema-to-space.test.ts
- packages/2-mongo-family/9-family/test/control-instance.descriptor-self-consistency.test.ts
- packages/1-framework/3-tooling/migration/test/aggregate/loader.test.ts
- .agents/skills/drive-orchestrate-plan/templates/delegate-review.md
- packages/3-mongo-target/1-mongo-target/src/core/mongo-runner.ts
- packages/2-mongo-family/9-family/src/core/mongo-target-descriptor.ts
- .agents/skills/drive-orchestrate-plan/SKILL.md
- docs/architecture docs/adrs/ADR 212 - Contract spaces.md
- packages/3-mongo-target/1-mongo-target/src/core/marker-ledger.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@examples/retail-store/migrations/app/20260513T0508_backfill_product_status/migration.ts`:
- Around line 85-88: The current dataTransform call uses check: { source:
existingProductsWithoutStatus } which treats zero matching rows as a precheck
failure; change the check to a custom precheck function that queries
existingProductsWithoutStatus and returns success when the query yields zero
rows (so “nothing left to backfill” is treated as success) and otherwise returns
the list to process; specifically update the dataTransform invocation for
'backfill-product-status' to replace the simple check.source with a function or
check object that inspects existingProductsWithoutStatus and returns an
empty-result-success rather than failing, keeping backfillRun unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: abbbb79c-d53f-471a-8ea6-649e905fa16a
📒 Files selected for processing (21)
examples/retail-store/migrations/app/20260513T0505_initial/end-contract.d.tsexamples/retail-store/migrations/app/20260513T0505_initial/end-contract.jsonexamples/retail-store/migrations/app/20260513T0505_initial/migration.jsonexamples/retail-store/migrations/app/20260513T0505_initial/migration.tsexamples/retail-store/migrations/app/20260513T0505_initial/ops.jsonexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/end-contract.d.tsexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/end-contract.jsonexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/migration.jsonexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/migration.tsexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/ops.jsonexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/start-contract.d.tsexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/start-contract.jsonexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/end-contract.d.tsexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/end-contract.jsonexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/migration.jsonexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/migration.tsexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/ops.jsonexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/start-contract.d.tsexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/start-contract.jsonexamples/retail-store/test/manual-migration.test.tsexamples/retail-store/test/migration-chain.test.ts
✅ Files skipped from review due to trivial changes (11)
- examples/retail-store/migrations/app/20260513T0507_add_product_category_index/ops.json
- examples/retail-store/migrations/app/20260513T0507_add_product_category_index/migration.ts
- examples/retail-store/migrations/app/20260513T0507_add_product_category_index/migration.json
- examples/retail-store/migrations/app/20260513T0508_backfill_product_status/end-contract.d.ts
- examples/retail-store/migrations/app/20260513T0508_backfill_product_status/start-contract.json
- examples/retail-store/migrations/app/20260513T0508_backfill_product_status/end-contract.json
- examples/retail-store/migrations/app/20260513T0508_backfill_product_status/migration.json
- examples/retail-store/migrations/app/20260513T0508_backfill_product_status/start-contract.d.ts
- examples/retail-store/migrations/app/20260513T0505_initial/end-contract.d.ts
- examples/retail-store/migrations/app/20260513T0507_add_product_category_index/end-contract.d.ts
- examples/retail-store/migrations/app/20260513T0507_add_product_category_index/start-contract.d.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- examples/retail-store/test/manual-migration.test.ts
…viewer to scan for them; document Cursor Multitask Mode
Three connected changes pulled into one commit because they describe one
policy: transient project planning IDs (T1.1, TC-7, AC4, P3 R2,
CKPT-2, etc.) must not leak into source code, comments, test names, or
hash fixtures, and the iteration loop must catch them at review time
rather than after merge.
1. New rule `.agents/rules/no-transient-project-ids-in-code.mdc`. A
focused, always-applied companion to `doc-maintenance.mdc`. Names
the specific token classes that are forbidden in code (task IDs,
test-case IDs, AC/FR/NFR IDs, phase/round/checkpoint IDs,
`projects/<x>/...` paths, prose attributions to the plan,
ID-named hash fixtures), explains the failure mode (transient IDs
rot silently — once the plan is renumbered or deleted at close-out,
the comment is dangling), and lists the stable references that
stay allowed (Linear ticket IDs, ADR numbers, durable docs paths).
Includes a paste-ready scan command the implementer can run on
their `+` diff before declaring a task done.
2. Reviewer protocol update in
`.agents/skills/drive-orchestrate-plan/agents/reviewer.md`. Adds
step 7 to the round workflow ("Scan for transient project IDs
leaking into code") and a dedicated `## Transient ID scan` section
with the procedure: extract the round plan IDs from `plan.md` and
`spec.md`, scan the round `+` diff for them and the structural
patterns that catch IDs missed in step 1, file every hit as a
`must-fix` finding. Adds a zero-hits clause to the
`SATISFIED` acceptance bar so the scan is enforced rather than
advisory. Adds an anti-pattern entry naming the protocol breach
(skipping the scan).
3. Implementer protocol update in
`.agents/skills/drive-orchestrate-plan/agents/implementer.md`.
Adds a `## No transient project IDs in code` section with the
high-frequency leakage shapes (test names, JSDoc, hash fixtures,
`projects/<this-project>/...` paths, prose attributions) and the
self-scan command to run before declaring a task done. Clarifies
that commit messages and PR descriptions are out-of-band of the
source-tree ban — task IDs are useful there for traceability but
forbidden inside source files.
4. Multitasking guidance in
`.agents/skills/drive-orchestrate-plan/SKILL.md`. New `##
Multitasking the loop (Cursor IDE)` section: when the user is in
Multitask Mode, both implementer and reviewer round delegations
set `run_in_background: true`, and the orchestrator uses the
wait window for productive prep (pre-stage the next delegation
prompt, prepare R<N+1> implementer scoping, drain unrelated user
questions). Explicitly forbids polling the backgrounded subagent,
forbids running two persistent subagents of the same role in
parallel (the loop is sequential per role even when each call
is backgrounded), and reaffirms heartbeats as the canonical
"stuck?" signal — backgrounding makes them more important, not
less. Wires the multitasking hook into loop steps 2 and 5 and
adds a behavioural rule to the cross-cutting invariants list.
Refs: TML-2408
Refs: PR #494
Signed-off-by: Will Madden <[email protected]>
The Mongo family is being shipped with multi-space markers as part of this PR; we have no production users on the prior single-doc shape, and the no-backward-compat-shims rule says we should not pre-pay maintenance for hypothetical legacy state. Removes the LEGACY_MARKER_ID constant, the duplicate-key error code, the upgrade/sweep helpers, the markerCollection type widener, and the entire legacy-upgrade test describe block. readMarker collapses to a single non-branching aggregate. readAllMarkers keeps the defensive `space` filter as a guard against malformed/manually-inserted docs (now framed as exactly that, not as legacy handling). Surfaced by review feedback on PR #494. Signed-off-by: Will Madden <[email protected]>
… docs Two narrow corrections surfaced in PR #494 review: - mongo-target-descriptor.ts had a comment block pointing at `projects/contract-spaces-mongo-port/spec.md`, which the no-transient- project-ids-in-code rule (the rule introduced in 7c915a2) explicitly forbids. Replaced with the durable equivalents: subsystem 10 (MongoDB Family § Contract spaces) and ADR 212. - ADR 212 listed the producer-side helpers as imported from `@prisma-next/migration-tools/exports/spaces`. The codebase imports them from `@prisma-next/migration-tools/spaces` per the no-`/exports/`- in-imports convention; documenting the canonical name avoids leading readers to a non-canonical path. Signed-off-by: Will Madden <[email protected]>
|
Triage of CodeRabbit's review-body items (the ones that don't have inline threads): Will-address items posted as commits
Already-resolved by deletion
Not addressing in this PR
|
…viewer to scan for them; document Cursor Multitask Mode
Three connected changes pulled into one commit because they describe one
policy: transient project planning IDs (T1.1, TC-7, AC4, P3 R2,
CKPT-2, etc.) must not leak into source code, comments, test names, or
hash fixtures, and the iteration loop must catch them at review time
rather than after merge.
1. New rule `.agents/rules/no-transient-project-ids-in-code.mdc`. A
focused, always-applied companion to `doc-maintenance.mdc`. Names
the specific token classes that are forbidden in code (task IDs,
test-case IDs, AC/FR/NFR IDs, phase/round/checkpoint IDs,
`projects/<x>/...` paths, prose attributions to the plan,
ID-named hash fixtures), explains the failure mode (transient IDs
rot silently — once the plan is renumbered or deleted at close-out,
the comment is dangling), and lists the stable references that
stay allowed (Linear ticket IDs, ADR numbers, durable docs paths).
Includes a paste-ready scan command the implementer can run on
their `+` diff before declaring a task done.
2. Reviewer protocol update in
`.agents/skills/drive-orchestrate-plan/agents/reviewer.md`. Adds
step 7 to the round workflow ("Scan for transient project IDs
leaking into code") and a dedicated `## Transient ID scan` section
with the procedure: extract the round plan IDs from `plan.md` and
`spec.md`, scan the round `+` diff for them and the structural
patterns that catch IDs missed in step 1, file every hit as a
`must-fix` finding. Adds a zero-hits clause to the
`SATISFIED` acceptance bar so the scan is enforced rather than
advisory. Adds an anti-pattern entry naming the protocol breach
(skipping the scan).
3. Implementer protocol update in
`.agents/skills/drive-orchestrate-plan/agents/implementer.md`.
Adds a `## No transient project IDs in code` section with the
high-frequency leakage shapes (test names, JSDoc, hash fixtures,
`projects/<this-project>/...` paths, prose attributions) and the
self-scan command to run before declaring a task done. Clarifies
that commit messages and PR descriptions are out-of-band of the
source-tree ban — task IDs are useful there for traceability but
forbidden inside source files.
4. Multitasking guidance in
`.agents/skills/drive-orchestrate-plan/SKILL.md`. New `##
Multitasking the loop (Cursor IDE)` section: when the user is in
Multitask Mode, both implementer and reviewer round delegations
set `run_in_background: true`, and the orchestrator uses the
wait window for productive prep (pre-stage the next delegation
prompt, prepare R<N+1> implementer scoping, drain unrelated user
questions). Explicitly forbids polling the backgrounded subagent,
forbids running two persistent subagents of the same role in
parallel (the loop is sequential per role even when each call
is backgrounded), and reaffirms heartbeats as the canonical
"stuck?" signal — backgrounding makes them more important, not
less. Wires the multitasking hook into loop steps 2 and 5 and
adds a behavioural rule to the cross-cutting invariants list.
Refs: TML-2408
Refs: PR #494
Signed-off-by: Will Madden <[email protected]>
The Mongo family is being shipped with multi-space markers as part of this PR; we have no production users on the prior single-doc shape, and the no-backward-compat-shims rule says we should not pre-pay maintenance for hypothetical legacy state. Removes the LEGACY_MARKER_ID constant, the duplicate-key error code, the upgrade/sweep helpers, the markerCollection type widener, and the entire legacy-upgrade test describe block. readMarker collapses to a single non-branching aggregate. readAllMarkers keeps the defensive `space` filter as a guard against malformed/manually-inserted docs (now framed as exactly that, not as legacy handling). Surfaced by review feedback on PR #494. Signed-off-by: Will Madden <[email protected]>
… docs Two narrow corrections surfaced in PR #494 review: - mongo-target-descriptor.ts had a comment block pointing at `projects/contract-spaces-mongo-port/spec.md`, which the no-transient- project-ids-in-code rule (the rule introduced in 7c915a2) explicitly forbids. Replaced with the durable equivalents: subsystem 10 (MongoDB Family § Contract spaces) and ADR 212. - ADR 212 listed the producer-side helpers as imported from `@prisma-next/migration-tools/exports/spaces`. The codebase imports them from `@prisma-next/migration-tools/spaces` per the no-`/exports/`- in-imports convention; documenting the canonical name avoids leading readers to a non-canonical path. Signed-off-by: Will Madden <[email protected]>
b52a0d6 to
79b3d26
Compare
|
Returning to correct the framing of my earlier reply — it was incomplete and undersold what's actually planned. The accurate framing: this isn't an option-A-vs-B trade-off the spaces port chose to defer. The framework lacks a typed primitive for storage topology — the structural backbone of "what named things does this contract claim?" independent of family — and that primitive is being introduced as
TML-2459 also lists TML-2408 as a strict-precedence prerequisite (so this PR lands first, with the duck-typed helper, and the IR class flip absorbs it). Landing an interim typed shape here would introduce a third on-disk shape — neither today's flat So: stopgap, known layering violation, deliberate sequencing. JSDoc updated to record this and point at TML-2459 so the next reader doesn't reach the same conclusion and rewrite it under their own initiative. No follow-up Linear issue needed — TML-2459 already covers it. |
24a90fa to
c03dfe9
Compare
All acceptance criteria for the Mongo contract-spaces port are satisfied on this branch (PR #494) and verified end-to-end against the live test suite: - AC1 MongoControlExtensionDescriptor.contractSpace + descriptor self-consistency wired in createMongoFamilyInstance - AC2 Marker docs keyed by {_id: <spaceId>, space: <spaceId>} (legacy upgrade clause from FR4 deliberately dropped during execution; no production users on the legacy single-doc shape, upgrade path was unnecessary scope) - AC3 readMarker / readAllMarkers per-space; executeAcrossSpaces accepts >= 2 perSpaceOptions - AC4 Resumable per-space failure semantics (multi-space-runner test) - AC5 Disjointness + sibling-pruning generalised for collections - AC6 Pinned per-space contract.json / contract.d.ts / refs/head.json - AC7 Aggregate apply + per-space verify drift isolation (e2e) - AC8 Existing Mongo baseline preserved - AC9 Subsystem 10 § Contract spaces + Subsystem 7 cross-reference - AC10 All validation gates green at PR merge time - AC11 Codec-rehydration guardrail test (NFR5) Close-out actions: - Refresh ADR 021 (Contract Marker Storage) to reflect Mongo per-space marker shape now in place; remove the stale "out of scope for Mongo today" caveat, point to Subsystem 10 § Contract spaces. - Delete the transient projects/contract-spaces-mongo-port/ directory (spec, plan, specs/, reviews/) per the drive-project-workflow rule; durable docs already migrated to Subsystem 10 + ADR 212. No code changes; mechanism + docs already shipped earlier on the branch. Refs: TML-2408 Signed-off-by: Will Madden <[email protected]>
…viewer to scan for them; document Cursor Multitask Mode
Three connected changes pulled into one commit because they describe one
policy: transient project planning IDs (T1.1, TC-7, AC4, P3 R2,
CKPT-2, etc.) must not leak into source code, comments, test names, or
hash fixtures, and the iteration loop must catch them at review time
rather than after merge.
1. New rule `.agents/rules/no-transient-project-ids-in-code.mdc`. A
focused, always-applied companion to `doc-maintenance.mdc`. Names
the specific token classes that are forbidden in code (task IDs,
test-case IDs, AC/FR/NFR IDs, phase/round/checkpoint IDs,
`projects/<x>/...` paths, prose attributions to the plan,
ID-named hash fixtures), explains the failure mode (transient IDs
rot silently — once the plan is renumbered or deleted at close-out,
the comment is dangling), and lists the stable references that
stay allowed (Linear ticket IDs, ADR numbers, durable docs paths).
Includes a paste-ready scan command the implementer can run on
their `+` diff before declaring a task done.
2. Reviewer protocol update in
`.agents/skills/drive-orchestrate-plan/agents/reviewer.md`. Adds
step 7 to the round workflow ("Scan for transient project IDs
leaking into code") and a dedicated `## Transient ID scan` section
with the procedure: extract the round plan IDs from `plan.md` and
`spec.md`, scan the round `+` diff for them and the structural
patterns that catch IDs missed in step 1, file every hit as a
`must-fix` finding. Adds a zero-hits clause to the
`SATISFIED` acceptance bar so the scan is enforced rather than
advisory. Adds an anti-pattern entry naming the protocol breach
(skipping the scan).
3. Implementer protocol update in
`.agents/skills/drive-orchestrate-plan/agents/implementer.md`.
Adds a `## No transient project IDs in code` section with the
high-frequency leakage shapes (test names, JSDoc, hash fixtures,
`projects/<this-project>/...` paths, prose attributions) and the
self-scan command to run before declaring a task done. Clarifies
that commit messages and PR descriptions are out-of-band of the
source-tree ban — task IDs are useful there for traceability but
forbidden inside source files.
4. Multitasking guidance in
`.agents/skills/drive-orchestrate-plan/SKILL.md`. New `##
Multitasking the loop (Cursor IDE)` section: when the user is in
Multitask Mode, both implementer and reviewer round delegations
set `run_in_background: true`, and the orchestrator uses the
wait window for productive prep (pre-stage the next delegation
prompt, prepare R<N+1> implementer scoping, drain unrelated user
questions). Explicitly forbids polling the backgrounded subagent,
forbids running two persistent subagents of the same role in
parallel (the loop is sequential per role even when each call
is backgrounded), and reaffirms heartbeats as the canonical
"stuck?" signal — backgrounding makes them more important, not
less. Wires the multitasking hook into loop steps 2 and 5 and
adds a behavioural rule to the cross-cutting invariants list.
Refs: TML-2408
Refs: PR #494
Signed-off-by: Will Madden <[email protected]>
The Mongo family is being shipped with multi-space markers as part of this PR; we have no production users on the prior single-doc shape, and the no-backward-compat-shims rule says we should not pre-pay maintenance for hypothetical legacy state. Removes the LEGACY_MARKER_ID constant, the duplicate-key error code, the upgrade/sweep helpers, the markerCollection type widener, and the entire legacy-upgrade test describe block. readMarker collapses to a single non-branching aggregate. readAllMarkers keeps the defensive `space` filter as a guard against malformed/manually-inserted docs (now framed as exactly that, not as legacy handling). Surfaced by review feedback on PR #494. Signed-off-by: Will Madden <[email protected]>
… docs Two narrow corrections surfaced in PR #494 review: - mongo-target-descriptor.ts had a comment block pointing at `projects/contract-spaces-mongo-port/spec.md`, which the no-transient- project-ids-in-code rule (the rule introduced in 7c915a2) explicitly forbids. Replaced with the durable equivalents: subsystem 10 (MongoDB Family § Contract spaces) and ADR 212. - ADR 212 listed the producer-side helpers as imported from `@prisma-next/migration-tools/exports/spaces`. The codebase imports them from `@prisma-next/migration-tools/spaces` per the no-`/exports/`- in-imports convention; documenting the canonical name avoids leading readers to a non-canonical path. Signed-off-by: Will Madden <[email protected]>
c1fdf59 to
8c9edf3
Compare
All acceptance criteria for the Mongo contract-spaces port are satisfied on this branch (PR #494) and verified end-to-end against the live test suite: - AC1 MongoControlExtensionDescriptor.contractSpace + descriptor self-consistency wired in createMongoFamilyInstance - AC2 Marker docs keyed by {_id: <spaceId>, space: <spaceId>} (legacy upgrade clause from FR4 deliberately dropped during execution; no production users on the legacy single-doc shape, upgrade path was unnecessary scope) - AC3 readMarker / readAllMarkers per-space; executeAcrossSpaces accepts >= 2 perSpaceOptions - AC4 Resumable per-space failure semantics (multi-space-runner test) - AC5 Disjointness + sibling-pruning generalised for collections - AC6 Pinned per-space contract.json / contract.d.ts / refs/head.json - AC7 Aggregate apply + per-space verify drift isolation (e2e) - AC8 Existing Mongo baseline preserved - AC9 Subsystem 10 § Contract spaces + Subsystem 7 cross-reference - AC10 All validation gates green at PR merge time - AC11 Codec-rehydration guardrail test (NFR5) Close-out actions: - Refresh ADR 021 (Contract Marker Storage) to reflect Mongo per-space marker shape now in place; remove the stale "out of scope for Mongo today" caveat, point to Subsystem 10 § Contract spaces. - Delete the transient projects/contract-spaces-mongo-port/ directory (spec, plan, specs/, reviews/) per the drive-project-workflow rule; durable docs already migrated to Subsystem 10 + ADR 212. No code changes; mechanism + docs already shipped earlier on the branch. Refs: TML-2408 Signed-off-by: Will Madden <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 4
♻️ Duplicate comments (1)
.agents/skills/drive-orchestrate-plan/agents/implementer.md (1)
137-141:⚠️ Potential issue | 🟠 Major | ⚡ Quick winAlign the scan pattern with the rule file and the reviewer script.
This script has the same incompleteness as the patterns in
.agents/rules/no-transient-project-ids-in-code.mdcandreviewer.md:
- Missing
D[0-9]+(forD7)- Missing
M[0-9]+\.[0-9]+(forM3.2)AC[0-9]+should beAC-?[0-9]+(to matchAC-13)All three scripts must use the same complete pattern. See the review comments on the rule file and
reviewer.mdfor the proposed unified pattern.🔧 Proposed fix (same as rule file and reviewer.md)
git diff --cached -- '*.ts' '*.tsx' '*.js' '*.mjs' '*.py' '*.rs' '*.go' \ | grep -E '^\+' \ - | grep -oE '\b(T[0-9]+\.[0-9]+|TC-?[0-9]+|AC[0-9]+|FR[0-9]+|NFR[0-9]+|CKPT-[0-9]+|AM[0-9]+|P[0-9]+ R[0-9]+|M[0-9]+ review)\b' \ + | grep -oE '\b(T[0-9]+\.[0-9]+|D[0-9]+|M[0-9]+\.[0-9]+|TC-?[0-9]+|AC-?[0-9]+|AM[0-9]+|FR[0-9]+|NFR[0-9]+|CKPT-[0-9]+|P[0-9]+ R[0-9]+|M[0-9]+ review)\b' \ | sort -u🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.agents/skills/drive-orchestrate-plan/agents/implementer.md around lines 137 - 141, Update the grep regex in the staged-files scan inside implementer.md to match the unified pattern used by the rule file and reviewer script: add the D[0-9]+ token, add M[0-9]+\.[0-9]+ to cover versions like M3.2, and change AC[0-9]+ to AC-?[0-9]+ so AC-13 matches; ensure the final alternation list includes T[0-9]+\.[0-9]+, TC-?[0-9]+, D[0-9]+, M[0-9]+\.[0-9]+, AC-?[0-9]+, FR[0-9]+, NFR[0-9]+, CKPT-[0-9]+, AM[0-9]+, P[0-9]+ R[0-9]+, and M[0-9]+ review to keep it consistent with the other rule files.
🧹 Nitpick comments (2)
packages/1-framework/3-tooling/cli/test/utils/contract-space-seed-phase.mongo.test.ts (1)
116-121: ⚡ Quick winPrefer object matchers for grouped record/headRef assertions.
Use
toMatchObjectfor related fields to align with the test assertion style guideline and keep the expectation blocks tighter.Proposed refactor
expect(out.seeded).toHaveLength(1); const record = out.seeded[0]!; - expect(record.spaceId).toBe(EXT_SPACE); - expect(record.action).toBe('updated'); - expect(record.priorHash).toBeNull(); - expect(record.newHash).toBe(headHash); + expect(record).toMatchObject({ + spaceId: EXT_SPACE, + action: 'updated', + priorHash: null, + newHash: headHash, + }); @@ const headRef = await readContractSpaceHeadRef(migrationsDir, EXT_SPACE); expect(headRef).not.toBeNull(); - expect(headRef!.hash).toBe(headHash); - expect(headRef!.invariants).toEqual(['inv:a', 'inv:b']); + expect(headRef).toMatchObject({ + hash: headHash, + invariants: ['inv:a', 'inv:b'], + });As per coding guidelines: "
**/*.test.ts: Prefer object matchers (toMatchObject) over multiple individual expect().toBe() calls when checking 2 or more related values in tests."Also applies to: 145-147
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/1-framework/3-tooling/cli/test/utils/contract-space-seed-phase.mongo.test.ts` around lines 116 - 121, Replace the multiple individual assertions on the seeded record with an object matcher: use expect(out.seeded).toHaveLength(1); then expect(out.seeded[0]).toMatchObject({ spaceId: EXT_SPACE, action: 'updated', priorHash: null, newHash: headHash }); do the same refactor for the similar block around the other assertion group (lines referenced in the comment) so related fields are asserted with toMatchObject instead of separate expect(...).toBe() calls.test/integration/test/mongo/db-verify-sign.test.ts (1)
333-334: ⚡ Quick winInclude
_id: stringin the collection type shape to eliminate the blind cast.The
_idfield is standard in MongoDB collections. Adding it to the type parameter lets.findOne({ _id: 'app' })type correctly without theas unknown as neverescape hatch.Suggested fix
- const markerDoc = await db - .collection<{ invariants?: readonly string[] }>('_prisma_migrations') - .findOne({ _id: 'app' as unknown as never }); + const markerDoc = await db + .collection<{ _id: string; invariants?: readonly string[] }>('_prisma_migrations') + .findOne({ _id: 'app' });🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/integration/test/mongo/db-verify-sign.test.ts` around lines 333 - 334, The test uses .collection<{ invariants?: readonly string[] }>('_prisma_migrations') then calls .findOne({ _id: 'app' as unknown as never }); update the collection generic to include the _id field (e.g., { _id: string; invariants?: readonly string[] }) so that .findOne({ _id: 'app' }) types correctly without the blind cast; modify the generic on the collection call (the type passed to .collection<...>) and remove the as unknown as never on the .findOne call.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.agents/rules/no-transient-project-ids-in-code.mdc:
- Around line 54-59: Update the grep regex in the
.agents/rules/no-transient-project-ids-in-code.mdc script (the pattern used in
the pipeline that currently reads
'\b(T[0-9]+\.[0-9]+|TC-?[0-9]+|AC[0-9]+|FR[0-9]+|NFR[0-9]+|CKPT-[0-9]+|AM[0-9]+|P[0-9]+
R[0-9]+)\b') to also match D[0-9]+, M[0-9]+\.[0-9]+, AC-?[0-9]+ (to accept
hyphenated AC-13), and the milestone prose form M[0-9]+ review so it aligns with
the examples and the reviewer/implementer scripts; additionally add a short note
in the rule file documenting that freeform prose (e.g., "sub-spec § 4",
"deferred per project plan") cannot be reliably tokenized and suggest a
secondary heuristic grep (e.g., search for "spec §", "per project plan", "per
the spec") or manual review for those cases.
In @.agents/skills/drive-orchestrate-plan/agents/reviewer.md:
- Around line 100-115: The reviewer regex patterns that extract transient IDs
must be aligned with the canonical pattern used by the rule and implementer
scripts: update the token regex to include D[0-9]+ and M[0-9]+\.[0-9]+, change
AC[0-9]+ to AC-?[0-9]+ to allow hyphenated AC-13 forms, and remove or normalize
the ad‑hoc "M[0-9]+ review" variant so all three places use the exact same
complete pattern (the union of tokens:
T[0-9]+\.[0-9]+|TC-?[0-9]+|AC-?[0-9]+|FR[0-9]+|NFR[0-9]+|CKPT-[0-9]+|AM[0-9]+|D[0-9]+|M[0-9]+\.[0-9]+|P[0-9]+
R[0-9]+|M[0-9]+ review if you choose to keep it); apply this single canonical
regex to reviewer.md, implementer.md, and the
no-transient-project-ids-in-code.mdc rule script so the pre-commit check and
review scan are identical.
In
`@packages/1-framework/3-tooling/migration/src/aggregate/extract-storage-element-names.ts`:
- Around line 1-36: In the leading JSDoc of extract-storage-element-names.ts
remove transient planning/spec labels ("M1", "M2 R2", "NFR1") and any other
milestone shorthand, and reflow the prose to avoid hard-wrapped ~80-column
lines; keep durable context only (e.g., replace transient labels with canonical
ticket/ADR links or omit them) while preserving the behavioral notes and intent
of the comment.
In `@packages/3-mongo-target/1-mongo-target/src/core/marker-ledger.ts`:
- Line 87: The marker read and CAS filter must enforce the invariant that
document _id equals the provided space; update the RawAggregateCommand match
(where you currently use { _id: space }) to require both _id: space and space:
space (or use an $expr checking $_id == $space) so a row like { _id: "app",
space: "ext" } cannot be returned, and apply the same strict match to all
compare-and-swap/update filters used for markers (the places using
RawAggregateCommand(COLLECTION, ...) and the CAS update filters) so every
read/update uses { _id: space, space: space } (or equivalent $expr) to guarantee
_id === space.
---
Duplicate comments:
In @.agents/skills/drive-orchestrate-plan/agents/implementer.md:
- Around line 137-141: Update the grep regex in the staged-files scan inside
implementer.md to match the unified pattern used by the rule file and reviewer
script: add the D[0-9]+ token, add M[0-9]+\.[0-9]+ to cover versions like M3.2,
and change AC[0-9]+ to AC-?[0-9]+ so AC-13 matches; ensure the final alternation
list includes T[0-9]+\.[0-9]+, TC-?[0-9]+, D[0-9]+, M[0-9]+\.[0-9]+, AC-?[0-9]+,
FR[0-9]+, NFR[0-9]+, CKPT-[0-9]+, AM[0-9]+, P[0-9]+ R[0-9]+, and M[0-9]+ review
to keep it consistent with the other rule files.
---
Nitpick comments:
In
`@packages/1-framework/3-tooling/cli/test/utils/contract-space-seed-phase.mongo.test.ts`:
- Around line 116-121: Replace the multiple individual assertions on the seeded
record with an object matcher: use expect(out.seeded).toHaveLength(1); then
expect(out.seeded[0]).toMatchObject({ spaceId: EXT_SPACE, action: 'updated',
priorHash: null, newHash: headHash }); do the same refactor for the similar
block around the other assertion group (lines referenced in the comment) so
related fields are asserted with toMatchObject instead of separate
expect(...).toBe() calls.
In `@test/integration/test/mongo/db-verify-sign.test.ts`:
- Around line 333-334: The test uses .collection<{ invariants?: readonly
string[] }>('_prisma_migrations') then calls .findOne({ _id: 'app' as unknown as
never }); update the collection generic to include the _id field (e.g., { _id:
string; invariants?: readonly string[] }) so that .findOne({ _id: 'app' }) types
correctly without the blind cast; modify the generic on the collection call (the
type passed to .collection<...>) and remove the as unknown as never on the
.findOne call.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 409eb91c-4c98-4f12-a83c-8deaf3a03d6e
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (82)
.agents/rules/no-transient-project-ids-in-code.mdc.agents/skills/drive-orchestrate-plan/SKILL.md.agents/skills/drive-orchestrate-plan/agents/implementer.md.agents/skills/drive-orchestrate-plan/agents/reviewer.md.agents/skills/drive-orchestrate-plan/templates/delegate-implement.md.agents/skills/drive-orchestrate-plan/templates/delegate-review.mddocs/architecture docs/adrs/ADR 021 - Contract Marker Storage.mddocs/architecture docs/adrs/ADR 212 - Contract spaces.mddocs/architecture docs/subsystems/10. MongoDB Family.mddocs/architecture docs/subsystems/6. Ecosystem Extensions & Packs.mddocs/architecture docs/subsystems/7. Migration System.mdexamples/retail-store/app/products/[id]/page.tsxexamples/retail-store/migrations/app/20260415_add-product-validation/migration.jsonexamples/retail-store/migrations/app/20260415_add-product-validation/migration.tsexamples/retail-store/migrations/app/20260415_add-product-validation/ops.jsonexamples/retail-store/migrations/app/20260416_backfill-product-status/migration.jsonexamples/retail-store/migrations/app/20260416_backfill-product-status/migration.tsexamples/retail-store/migrations/app/20260416_backfill-product-status/ops.jsonexamples/retail-store/migrations/app/20260513T0505_initial/end-contract.d.tsexamples/retail-store/migrations/app/20260513T0505_initial/end-contract.jsonexamples/retail-store/migrations/app/20260513T0505_initial/migration.jsonexamples/retail-store/migrations/app/20260513T0505_initial/migration.tsexamples/retail-store/migrations/app/20260513T0505_initial/ops.jsonexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/end-contract.d.tsexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/end-contract.jsonexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/migration.jsonexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/migration.tsexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/ops.jsonexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/start-contract.d.tsexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/start-contract.jsonexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/end-contract.d.tsexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/end-contract.jsonexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/migration.jsonexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/migration.tsexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/ops.jsonexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/start-contract.d.tsexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/start-contract.jsonexamples/retail-store/prisma/contract.prismaexamples/retail-store/src/contract.d.tsexamples/retail-store/src/contract.jsonexamples/retail-store/src/seed.tsexamples/retail-store/test/aggregation.test.tsexamples/retail-store/test/crud-lifecycle.test.tsexamples/retail-store/test/manual-migration.test.tsexamples/retail-store/test/migration-chain.test.tsexamples/retail-store/test/migration.test.tsexamples/retail-store/test/search.test.tspackages/1-framework/1-core/framework-components/src/control/control-migration-types.tspackages/1-framework/3-tooling/cli/test/utils/contract-space-seed-phase.mongo.test.tspackages/1-framework/3-tooling/migration/src/aggregate/extract-storage-element-names.tspackages/1-framework/3-tooling/migration/src/aggregate/loader.tspackages/1-framework/3-tooling/migration/src/aggregate/project-schema-to-space.tspackages/1-framework/3-tooling/migration/test/aggregate/loader.test.tspackages/1-framework/3-tooling/migration/test/aggregate/project-schema-to-space.test.tspackages/2-mongo-family/9-family/package.jsonpackages/2-mongo-family/9-family/src/core/control-instance.tspackages/2-mongo-family/9-family/src/core/control-types.tspackages/2-mongo-family/9-family/src/core/mongo-target-descriptor.tspackages/2-mongo-family/9-family/src/exports/control.tspackages/2-mongo-family/9-family/test/control-instance.descriptor-self-consistency.test.tspackages/2-mongo-family/9-family/vitest.config.tspackages/3-mongo-target/1-mongo-target/src/core/marker-ledger.tspackages/3-mongo-target/1-mongo-target/src/core/mongo-runner.tspackages/3-mongo-target/1-mongo-target/src/exports/control.tspackages/3-mongo-target/1-mongo-target/test/marker-ledger.test.tspackages/3-mongo-target/2-mongo-adapter/src/core/runner-deps.tspackages/3-mongo-target/2-mongo-adapter/test/mongo-runner.schema-verify.integration.test.tspackages/3-mongo-target/2-mongo-adapter/test/mongo-runner.test.tstest/integration/test/cli.mongo-db-sign.e2e.test.tstest/integration/test/cli.mongo-db-verify.e2e.test.tstest/integration/test/contract-space-fixture-mongo/README.mdtest/integration/test/contract-space-fixture-mongo/constants.tstest/integration/test/contract-space-fixture-mongo/contract.tstest/integration/test/contract-space-fixture-mongo/control.tstest/integration/test/contract-space-fixture-mongo/descriptor.test.tstest/integration/test/contract-space-fixture-mongo/migrations.tstest/integration/test/mongo/aggregate-e2e.test.tstest/integration/test/mongo/codec-rehydration-guardrail.test.tstest/integration/test/mongo/db-verify-sign.test.tstest/integration/test/mongo/family-read-marker-per-space.test.tstest/integration/test/mongo/migration-e2e.test.tstest/integration/test/mongo/multi-space-runner.test.ts
💤 Files with no reviewable changes (6)
- examples/retail-store/migrations/app/20260416_backfill-product-status/migration.json
- examples/retail-store/migrations/app/20260415_add-product-validation/migration.json
- examples/retail-store/migrations/app/20260416_backfill-product-status/ops.json
- examples/retail-store/migrations/app/20260415_add-product-validation/migration.ts
- examples/retail-store/migrations/app/20260415_add-product-validation/ops.json
- examples/retail-store/migrations/app/20260416_backfill-product-status/migration.ts
✅ Files skipped from review due to trivial changes (17)
- test/integration/test/contract-space-fixture-mongo/README.md
- docs/architecture docs/adrs/ADR 021 - Contract Marker Storage.md
- examples/retail-store/test/search.test.ts
- examples/retail-store/test/aggregation.test.ts
- examples/retail-store/test/crud-lifecycle.test.ts
- docs/architecture docs/subsystems/7. Migration System.md
- docs/architecture docs/subsystems/6. Ecosystem Extensions & Packs.md
- packages/1-framework/1-core/framework-components/src/control/control-migration-types.ts
- packages/3-mongo-target/2-mongo-adapter/test/mongo-runner.test.ts
- examples/retail-store/migrations/app/20260513T0507_add_product_category_index/migration.json
- examples/retail-store/migrations/app/20260513T0508_backfill_product_status/end-contract.json
- examples/retail-store/migrations/app/20260513T0508_backfill_product_status/migration.json
- examples/retail-store/migrations/app/20260513T0508_backfill_product_status/start-contract.json
- examples/retail-store/migrations/app/20260513T0508_backfill_product_status/end-contract.d.ts
- docs/architecture docs/adrs/ADR 212 - Contract spaces.md
- examples/retail-store/migrations/app/20260513T0505_initial/end-contract.d.ts
- examples/retail-store/migrations/app/20260513T0505_initial/end-contract.json
🚧 Files skipped from review as they are similar to previous changes (41)
- examples/retail-store/prisma/contract.prisma
- packages/2-mongo-family/9-family/src/exports/control.ts
- packages/2-mongo-family/9-family/src/core/control-types.ts
- examples/retail-store/migrations/app/20260513T0507_add_product_category_index/ops.json
- test/integration/test/cli.mongo-db-sign.e2e.test.ts
- test/integration/test/contract-space-fixture-mongo/descriptor.test.ts
- packages/2-mongo-family/9-family/package.json
- packages/3-mongo-target/2-mongo-adapter/test/mongo-runner.schema-verify.integration.test.ts
- examples/retail-store/migrations/app/20260513T0507_add_product_category_index/migration.ts
- test/integration/test/contract-space-fixture-mongo/control.ts
- packages/3-mongo-target/2-mongo-adapter/src/core/runner-deps.ts
- examples/retail-store/test/migration.test.ts
- examples/retail-store/migrations/app/20260513T0508_backfill_product_status/ops.json
- packages/2-mongo-family/9-family/vitest.config.ts
- test/integration/test/mongo/family-read-marker-per-space.test.ts
- packages/3-mongo-target/1-mongo-target/src/exports/control.ts
- packages/1-framework/3-tooling/migration/test/aggregate/loader.test.ts
- .agents/skills/drive-orchestrate-plan/templates/delegate-implement.md
- test/integration/test/contract-space-fixture-mongo/migrations.ts
- packages/2-mongo-family/9-family/test/control-instance.descriptor-self-consistency.test.ts
- test/integration/test/contract-space-fixture-mongo/constants.ts
- examples/retail-store/migrations/app/20260513T0508_backfill_product_status/start-contract.d.ts
- packages/2-mongo-family/9-family/src/core/mongo-target-descriptor.ts
- test/integration/test/contract-space-fixture-mongo/contract.ts
- test/integration/test/mongo/codec-rehydration-guardrail.test.ts
- packages/2-mongo-family/9-family/src/core/control-instance.ts
- examples/retail-store/migrations/app/20260513T0507_add_product_category_index/end-contract.d.ts
- examples/retail-store/test/manual-migration.test.ts
- .agents/skills/drive-orchestrate-plan/templates/delegate-review.md
- test/integration/test/cli.mongo-db-verify.e2e.test.ts
- test/integration/test/mongo/migration-e2e.test.ts
- test/integration/test/mongo/aggregate-e2e.test.ts
- packages/3-mongo-target/1-mongo-target/src/core/mongo-runner.ts
- packages/1-framework/3-tooling/migration/src/aggregate/project-schema-to-space.ts
- packages/1-framework/3-tooling/migration/test/aggregate/project-schema-to-space.test.ts
- examples/retail-store/test/migration-chain.test.ts
- .agents/skills/drive-orchestrate-plan/SKILL.md
- examples/retail-store/migrations/app/20260513T0505_initial/ops.json
- examples/retail-store/migrations/app/20260513T0505_initial/migration.ts
- examples/retail-store/migrations/app/20260513T0507_add_product_category_index/start-contract.json
- examples/retail-store/migrations/app/20260513T0505_initial/migration.json
|
On it 👍 — addressing the PR-body sub-findings from review 4281865043 in separate commits: implementer.md grep alignment, the toMatchObject tidy in contract-space-seed-phase.mongo.test.ts, and the db-verify-sign |
|
PR-body sub-findings from review 4281865043: |
Capture the spec and plan for porting contract spaces to the Mongo family. Documents the cross-space atomicity choice (per-space marker-level, gated on post-apply verify, resumable not transactional), the marker-doc shape change, the descriptor surface, the multi-space runner contract, and the schema-prune generalisation. Plan is a single PR structured as five commit-clusters with reasoning-effort checkpoints at the design-call moments and a final pre-PR self-review. Refs: TML-2408 Signed-off-by: Will Madden <[email protected]>
Replace ExtensionContractSpace / ExtensionContractRef with the canonical ContractSpace<TContract> / ContractSpaceHeadRef types from framework-components/control. The descriptor blocks now show the SQL family specialising the family-agnostic generic, which is what lets a second family (Mongo, TML-2408) adopt the same shape without a parallel type. Also rename stale emitPinnedSpaceArtefacts references to the shipped emitContractSpaceArtefacts. Signed-off-by: Will Madden <[email protected]>
….T1.1)
Mongo marker/ledger ops are now keyed by contract space. Each marker
doc lives at `_id: <space>` with `space: <space>` carried alongside;
ledger entries gain a `space` field so the same edgeId can recur
across spaces without colliding. The runner derives the space from
`plan.spaceId ?? APP_SPACE_ID`, so single-space callers that pre-date
contract spaces still write the application's well-known marker.
Legacy `{_id: "marker", ...}` docs remain unsupported here — pre-port
upgrade is the next slice (T1.2). After T1.1, fresh databases write
`{_id: "app", space: "app", ...}` directly.
BREAKING CHANGE: `readMarker` / `initMarker` / `updateMarker` /
`writeLedgerEntry` exported from `@prisma-next/target-mongo/control`
take a `space` parameter as their first positional argument after `db`.
Callers that previously addressed the implicit single marker doc must
pass APP_SPACE_ID explicitly.
Refs: TML-2408
Signed-off-by: Will Madden <[email protected]>
…ts and test names Apply the new `no-transient-project-ids-in-code` rule to the code this branch added in earlier rounds. The leaks were exactly the shape the new rule names — test names tagged with TC-numbers, JSDoc blocks attributing comments to phase/task IDs (P5 T5.2, T1.2, T3.4), hash-fixture constants named after test-case IDs (`sha256:tc12-...`), and a `describe` block parenthesising round labels. Six files affected: - `packages/3-mongo-target/1-mongo-target/src/core/marker-ledger.ts`: drop the `(T1.2)` attribution from the JSDoc on `MongoMarkerDocSchema`. Rephrase "post-port shape" / "pre-port docs" to "canonical shape" / "pre-canonical docs" so the comment describes the schema property in its own terms rather than referencing the migration that introduced it. - `packages/3-mongo-target/1-mongo-target/test/marker-ledger.test.ts`: drop `(TC-3)`, `(TC-4, TC-5)` from `it` and `describe` strings. - `packages/1-framework/3-tooling/cli/test/utils/contract-space-seed-phase.mongo.test.ts`: drop the `Phase 4 smoke tests (T4.1 / T4.2 / T4.3)` doc-comment preamble; rewrite as a property-focused summary. Drop `(T4.1, T4.2)` and `(T4.3 / AC6)` from `it` strings. Rename `sha256:tc12-ext-contract` / `sha256:tc12-ext-profile` to `sha256:mongo-ext-contract` / `sha256:mongo-ext-profile` so the fixture is named after its role, not the test case that introduced it. - `test/integration/test/mongo/aggregate-e2e.test.ts`: drop `P5 T5.2 / T5.3` from the file-level JSDoc and `describe` label. Drop `(T5.2 / TC-14)` and `(T5.3 / TC-15)` from `it` labels. Drop `(AC4 property)` and `(AC4)` from JSDoc bullets and inline comments — the boundary they describe is intrinsic to the test, not a reference to a spec entry. - `test/integration/test/mongo/codec-rehydration-guardrail.test.ts`: drop `TC-18 — codec-rehydration guardrail (NFR5 / AC11)` from the file JSDoc heading and the `describe` label. - `test/integration/test/mongo/multi-space-runner.test.ts`: drop `(TC-7)`, `(TC-8)`, `(TC-9)` from `it` labels and `TC-8` / `T3.4` / `TC-9` references from JSDoc and inline comments. Tighten the `buildAppContractMissingPosts` JSDoc preamble. In every case the rewrite preserves the property the comment / test name was describing — what changed is that the property is now named in its own right, not by reference to the plan row that introduced it. Behaviour is unchanged; affected unit + integration suites remain green (cli + target-mongo unit tests, multi-space-runner + aggregate-e2e + codec-rehydration-guardrail integration tests). Refs: TML-2408 Signed-off-by: Will Madden <[email protected]>
The Mongo family is being shipped with multi-space markers as part of this PR; we have no production users on the prior single-doc shape, and the no-backward-compat-shims rule says we should not pre-pay maintenance for hypothetical legacy state. Removes the LEGACY_MARKER_ID constant, the duplicate-key error code, the upgrade/sweep helpers, the markerCollection type widener, and the entire legacy-upgrade test describe block. readMarker collapses to a single non-branching aggregate. readAllMarkers keeps the defensive `space` filter as a guard against malformed/manually-inserted docs (now framed as exactly that, not as legacy handling). Surfaced by review feedback on PR #494. Signed-off-by: Will Madden <[email protected]>
… walk The aggregate loader and projectSchemaToSpace were each doing their own typeof / Object.keys walk over a contract storage object to extract the top-level table/collection names. Two consequences review surfaced: - The loader walk push-pushed names into an array, so a contract that exposed the same name in both `tables` and `collections` (a hypothetical cross-family shape) registered the space twice and could trip a false self-collision in the disjointness check. - The record-shape guards (`typeof === "object" && !== null`) also matched arrays, so an unrecognised array-shaped value entered the record-prune path via numeric keys instead of falling through unchanged. Lifts the walk into a single `extractStorageElementNames(contract)` helper that returns a Set (dedupes by construction) and excludes arrays from the record branch (so the unrecognised-shape-passes-through guarantee is preserved). Both call sites switch to the helper, and projectSchemaToSpace gets the same `!Array.isArray` guard on its own prune-record branches. Also clarifies the projectSchemaToSpace JSDoc: "schema" here means the live introspected DB state (MongoSchemaIR / SqlSchemaIR), not a contract-space namespace nor a SQL CREATE-SCHEMA schema. The function filters that introspected state down to the slice claimed by one space. Signed-off-by: Will Madden <[email protected]>
… docs Two narrow corrections surfaced in PR #494 review: - mongo-target-descriptor.ts had a comment block pointing at `projects/contract-spaces-mongo-port/spec.md`, which the no-transient- project-ids-in-code rule (the rule introduced in 7c915a2) explicitly forbids. Replaced with the durable equivalents: subsystem 10 (MongoDB Family § Contract spaces) and ADR 212. - ADR 212 listed the producer-side helpers as imported from `@prisma-next/migration-tools/exports/spaces`. The codebase imports them from `@prisma-next/migration-tools/spaces` per the no-`/exports/`- in-imports convention; documenting the canonical name avoids leading readers to a non-canonical path. Signed-off-by: Will Madden <[email protected]>
The reviewer skill says (frontmatter) the agent is "the only file it writes is reviews/code-review.md" but the Heartbeats section requires writing wip/heartbeats/reviewer.txt every round. Two readers flagged this as an impossible reporting rule: any honest "Files modified" return list would have to include the heartbeat, contradicting the constraint. Splits the writable-file contract into two surfaces, named explicitly: - Durable: reviews/code-review.md (the round artifact). - Operational: wip/heartbeats/reviewer.txt (overwrite-in-place liveness ping; not a deliverable). The "Files modified" return-shape rule now says "durable writes only" and explicitly tells the reviewer not to list the heartbeat there. The frontmatter description and the body opening paragraph are aligned to the same split so the writable contract reads consistently end-to-end. Signed-off-by: Will Madden <[email protected]>
These values are guaranteed to exist after setup; the project's coding-conventions rule prefers asserting presence and using non-null property access over `if (!x) throw "unreachable"` and optional chaining. Three sites in this file followed the older defensive shape left over from when the API returned narrower types; tightening them up. Signed-off-by: Will Madden <[email protected]>
Avoid politically loaded "master" terminology in the example schema. "primaryCategory" reads naturally alongside the sibling `subCategory` field on `Product`. Signed-off-by: Will Madden <[email protected]>
…ML-2459
The framework lacks a typed primitive for storage topology — the
structural backbone of "what named things does this contract claim?"
independent of family. Today the helper duck-types `tables` /
`collections` from framework-domain code that has no business naming
family-specific storage idioms.
The correct fix is `interface Storage { namespaces: Record<string,
Namespace> }` at the framework level, which is scoped in TML-2459
(target-extensible-ir) M1; TML-2459 M2 R2 explicitly schedules removal
of this duck-typed walk when the IR class flip rebases onto this PR.
Landing an interim typed shape here would introduce a third on-disk
shape that TML-2459 would have to migrate away from again — violating
its NFR1 (no dual-shape transition window).
Update the JSDoc to record this so the next reader does not reach the
same conclusion and rewrite the helper under their own initiative.
Signed-off-by: Will Madden <[email protected]>
All acceptance criteria for the Mongo contract-spaces port are satisfied on this branch (PR #494) and verified end-to-end against the live test suite: - AC1 MongoControlExtensionDescriptor.contractSpace + descriptor self-consistency wired in createMongoFamilyInstance - AC2 Marker docs keyed by {_id: <spaceId>, space: <spaceId>} (legacy upgrade clause from FR4 deliberately dropped during execution; no production users on the legacy single-doc shape, upgrade path was unnecessary scope) - AC3 readMarker / readAllMarkers per-space; executeAcrossSpaces accepts >= 2 perSpaceOptions - AC4 Resumable per-space failure semantics (multi-space-runner test) - AC5 Disjointness + sibling-pruning generalised for collections - AC6 Pinned per-space contract.json / contract.d.ts / refs/head.json - AC7 Aggregate apply + per-space verify drift isolation (e2e) - AC8 Existing Mongo baseline preserved - AC9 Subsystem 10 § Contract spaces + Subsystem 7 cross-reference - AC10 All validation gates green at PR merge time - AC11 Codec-rehydration guardrail test (NFR5) Close-out actions: - Refresh ADR 021 (Contract Marker Storage) to reflect Mongo per-space marker shape now in place; remove the stale "out of scope for Mongo today" caveat, point to Subsystem 10 § Contract spaces. - Delete the transient projects/contract-spaces-mongo-port/ directory (spec, plan, specs/, reviews/) per the drive-project-workflow rule; durable docs already migrated to Subsystem 10 + ADR 212. No code changes; mechanism + docs already shipped earlier on the branch. Refs: TML-2408 Signed-off-by: Will Madden <[email protected]>
The pre-commit grep in the rule file lagged the canonical alternation used by reviewer.md/implementer.md. Add the missing token shapes (D[0-9]+, M[0-9]+\.[0-9]+, M[0-9]+ review) and accept hyphenated AC-?[0-9]+ so the three scans cover the same surface. Also note that the regex only catches token-shaped IDs — freeform prose attributions need a separate manual scan. Signed-off-by: Will Madden <[email protected]>
Both grep snippets in reviewer.md now use the same alternation as the rule file and the implementer pre-commit check, so a token caught by one scan is caught by all three. Signed-off-by: Will Madden <[email protected]>
… regex The implementer pre-commit scan now uses the same alternation as the rule file and reviewer.md, so a token caught by one scan is caught by all three. Signed-off-by: Will Madden <[email protected]>
…eElementNames JSDoc The JSDoc encoded TML-2459-internal milestone and spec-decision IDs (M1, M2 R2, NFR1) that the no-transient-project-ids-in-code rule forbids. Reword to describe the constraint itself: TML-2459 will remove the duck-typed walk via the typed Storage primitive, and an interim shape here would create a dual-shape transition window TML-2459 explicitly rules out. TML-2459 ticket reference and the behavioural notes are preserved. Signed-off-by: Will Madden <[email protected]>
…ad and CAS
Marker docs are written with `_id` and `space` set to the same string
(see initMarker), so the two fields should always agree at read time.
Previously the read and CAS sites only matched on one of them, which
meant a corrupted or non-Prisma-written row whose `_id` and `space`
disagreed could masquerade as a marker for the wrong space. Add
defence-in-depth so:
- readMarker's $match requires both `_id: <space>` and `space: <space>`
- readAllMarkers adds `$expr: { $eq: ['$_id', '$space'] }` so
any row where the two diverge is excluded by construction
- updateMarker's CAS filter includes `space` alongside `_id` and
`storageHash`, so a mismatched row never satisfies the precondition
Regression tests cover all three sites against an inserted
`{ _id: APP, space: EXT, ... }` row.
Signed-off-by: Will Madden <[email protected]>
The first-seed assertions on `record` and `headRef` were each split into four sequential single-field expectations. Collapse each group into one `toMatchObject` per logical object so a future structural change shows up as a single failure rather than four interleaved ones. Signed-off-by: Will Madden <[email protected]>
…p the cast
The previous generic on the marker-doc lookup omitted `_id`, so the
filter `{ _id: 'app' }` only typechecked via `as unknown as never`.
The repo's typesafety rules call out that cast as a last-resort escape
hatch. Including `_id: string` in the collection generic lets the filter
typecheck cleanly.
Signed-off-by: Will Madden <[email protected]>
79be933 to
cbae5b0
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
docs/architecture docs/subsystems/10. MongoDB Family.md (1)
464-464: 💤 Low valueConsider American spelling for consistency.
The document uses "behavior" (American spelling) consistently elsewhere (lines 5, 92, 462), but "behaviour" (British spelling) appears here. Consider changing to "behavior" to maintain internal consistency.
Proposed spelling fix
-Descriptors without a `contractSpace` remain valid — they are codec-only or query-ops-only extensions, the existing pre-spaces behaviour preserved. +Descriptors without a `contractSpace` remain valid — they are codec-only or query-ops-only extensions, the existing pre-spaces behavior preserved.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@docs/architecture` docs/subsystems/10. MongoDB Family.md at line 464, Change the British spelling "behaviour" to the American "behavior" in the described paragraph; specifically update the sentence that reads "codec-only or query-ops-only extensions, the existing pre-spaces behaviour preserved" so it uses "behavior" to match the rest of the document, leaving references like contractSpace, MongoControlExtensionDescriptor, createMongoFamilyInstance, assertDescriptorSelfConsistency, and MIGRATION.DESCRIPTOR_HEAD_HASH_MISMATCH unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.agents/skills/drive-orchestrate-plan/agents/reviewer.md:
- Line 30: Update the non-standard phrase "wants triaged" to the correct
phrasing "wants to be triaged" in the reviewer documentation; search for the
exact string "wants triaged" (e.g., in the reviewer.md content) and replace it
with "wants to be triaged" to fix grammar while preserving surrounding context
and punctuation.
---
Nitpick comments:
In `@docs/architecture` docs/subsystems/10. MongoDB Family.md:
- Line 464: Change the British spelling "behaviour" to the American "behavior"
in the described paragraph; specifically update the sentence that reads
"codec-only or query-ops-only extensions, the existing pre-spaces behaviour
preserved" so it uses "behavior" to match the rest of the document, leaving
references like contractSpace, MongoControlExtensionDescriptor,
createMongoFamilyInstance, assertDescriptorSelfConsistency, and
MIGRATION.DESCRIPTOR_HEAD_HASH_MISMATCH unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: fe02c963-550f-4e65-905d-ece4ffaf5dd1
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (82)
.agents/rules/no-transient-project-ids-in-code.mdc.agents/skills/drive-orchestrate-plan/SKILL.md.agents/skills/drive-orchestrate-plan/agents/implementer.md.agents/skills/drive-orchestrate-plan/agents/reviewer.md.agents/skills/drive-orchestrate-plan/templates/delegate-implement.md.agents/skills/drive-orchestrate-plan/templates/delegate-review.mddocs/architecture docs/adrs/ADR 021 - Contract Marker Storage.mddocs/architecture docs/adrs/ADR 212 - Contract spaces.mddocs/architecture docs/subsystems/10. MongoDB Family.mddocs/architecture docs/subsystems/6. Ecosystem Extensions & Packs.mddocs/architecture docs/subsystems/7. Migration System.mdexamples/retail-store/app/products/[id]/page.tsxexamples/retail-store/migrations/app/20260415_add-product-validation/migration.jsonexamples/retail-store/migrations/app/20260415_add-product-validation/migration.tsexamples/retail-store/migrations/app/20260415_add-product-validation/ops.jsonexamples/retail-store/migrations/app/20260416_backfill-product-status/migration.jsonexamples/retail-store/migrations/app/20260416_backfill-product-status/migration.tsexamples/retail-store/migrations/app/20260416_backfill-product-status/ops.jsonexamples/retail-store/migrations/app/20260513T0505_initial/end-contract.d.tsexamples/retail-store/migrations/app/20260513T0505_initial/end-contract.jsonexamples/retail-store/migrations/app/20260513T0505_initial/migration.jsonexamples/retail-store/migrations/app/20260513T0505_initial/migration.tsexamples/retail-store/migrations/app/20260513T0505_initial/ops.jsonexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/end-contract.d.tsexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/end-contract.jsonexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/migration.jsonexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/migration.tsexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/ops.jsonexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/start-contract.d.tsexamples/retail-store/migrations/app/20260513T0507_add_product_category_index/start-contract.jsonexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/end-contract.d.tsexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/end-contract.jsonexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/migration.jsonexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/migration.tsexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/ops.jsonexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/start-contract.d.tsexamples/retail-store/migrations/app/20260513T0508_backfill_product_status/start-contract.jsonexamples/retail-store/prisma/contract.prismaexamples/retail-store/src/contract.d.tsexamples/retail-store/src/contract.jsonexamples/retail-store/src/seed.tsexamples/retail-store/test/aggregation.test.tsexamples/retail-store/test/crud-lifecycle.test.tsexamples/retail-store/test/manual-migration.test.tsexamples/retail-store/test/migration-chain.test.tsexamples/retail-store/test/migration.test.tsexamples/retail-store/test/search.test.tspackages/1-framework/1-core/framework-components/src/control/control-migration-types.tspackages/1-framework/3-tooling/cli/test/utils/contract-space-seed-phase.mongo.test.tspackages/1-framework/3-tooling/migration/src/aggregate/extract-storage-element-names.tspackages/1-framework/3-tooling/migration/src/aggregate/loader.tspackages/1-framework/3-tooling/migration/src/aggregate/project-schema-to-space.tspackages/1-framework/3-tooling/migration/test/aggregate/loader.test.tspackages/1-framework/3-tooling/migration/test/aggregate/project-schema-to-space.test.tspackages/2-mongo-family/9-family/package.jsonpackages/2-mongo-family/9-family/src/core/control-instance.tspackages/2-mongo-family/9-family/src/core/control-types.tspackages/2-mongo-family/9-family/src/core/mongo-target-descriptor.tspackages/2-mongo-family/9-family/src/exports/control.tspackages/2-mongo-family/9-family/test/control-instance.descriptor-self-consistency.test.tspackages/2-mongo-family/9-family/vitest.config.tspackages/3-mongo-target/1-mongo-target/src/core/marker-ledger.tspackages/3-mongo-target/1-mongo-target/src/core/mongo-runner.tspackages/3-mongo-target/1-mongo-target/src/exports/control.tspackages/3-mongo-target/1-mongo-target/test/marker-ledger.test.tspackages/3-mongo-target/2-mongo-adapter/src/core/runner-deps.tspackages/3-mongo-target/2-mongo-adapter/test/mongo-runner.schema-verify.integration.test.tspackages/3-mongo-target/2-mongo-adapter/test/mongo-runner.test.tstest/integration/test/cli.mongo-db-sign.e2e.test.tstest/integration/test/cli.mongo-db-verify.e2e.test.tstest/integration/test/contract-space-fixture-mongo/README.mdtest/integration/test/contract-space-fixture-mongo/constants.tstest/integration/test/contract-space-fixture-mongo/contract.tstest/integration/test/contract-space-fixture-mongo/control.tstest/integration/test/contract-space-fixture-mongo/descriptor.test.tstest/integration/test/contract-space-fixture-mongo/migrations.tstest/integration/test/mongo/aggregate-e2e.test.tstest/integration/test/mongo/codec-rehydration-guardrail.test.tstest/integration/test/mongo/db-verify-sign.test.tstest/integration/test/mongo/family-read-marker-per-space.test.tstest/integration/test/mongo/migration-e2e.test.tstest/integration/test/mongo/multi-space-runner.test.ts
💤 Files with no reviewable changes (6)
- examples/retail-store/migrations/app/20260415_add-product-validation/migration.json
- examples/retail-store/migrations/app/20260416_backfill-product-status/migration.ts
- examples/retail-store/migrations/app/20260415_add-product-validation/migration.ts
- examples/retail-store/migrations/app/20260416_backfill-product-status/migration.json
- examples/retail-store/migrations/app/20260416_backfill-product-status/ops.json
- examples/retail-store/migrations/app/20260415_add-product-validation/ops.json
✅ Files skipped from review due to trivial changes (17)
- packages/2-mongo-family/9-family/src/exports/control.ts
- examples/retail-store/test/aggregation.test.ts
- packages/1-framework/3-tooling/migration/src/aggregate/extract-storage-element-names.ts
- test/integration/test/contract-space-fixture-mongo/README.md
- docs/architecture docs/adrs/ADR 021 - Contract Marker Storage.md
- packages/1-framework/1-core/framework-components/src/control/control-migration-types.ts
- packages/2-mongo-family/9-family/package.json
- examples/retail-store/migrations/app/20260513T0508_backfill_product_status/end-contract.json
- test/integration/test/contract-space-fixture-mongo/constants.ts
- examples/retail-store/migrations/app/20260513T0508_backfill_product_status/start-contract.d.ts
- examples/retail-store/migrations/app/20260513T0507_add_product_category_index/migration.json
- examples/retail-store/migrations/app/20260513T0507_add_product_category_index/end-contract.d.ts
- .agents/rules/no-transient-project-ids-in-code.mdc
- examples/retail-store/migrations/app/20260513T0505_initial/end-contract.d.ts
- examples/retail-store/migrations/app/20260513T0508_backfill_product_status/end-contract.d.ts
- examples/retail-store/migrations/app/20260513T0508_backfill_product_status/start-contract.json
- docs/architecture docs/adrs/ADR 212 - Contract spaces.md
🚧 Files skipped from review as they are similar to previous changes (48)
- examples/retail-store/test/migration.test.ts
- examples/retail-store/app/products/[id]/page.tsx
- packages/3-mongo-target/2-mongo-adapter/src/core/runner-deps.ts
- test/integration/test/contract-space-fixture-mongo/descriptor.test.ts
- examples/retail-store/prisma/contract.prisma
- test/integration/test/contract-space-fixture-mongo/control.ts
- .agents/skills/drive-orchestrate-plan/templates/delegate-implement.md
- packages/3-mongo-target/2-mongo-adapter/test/mongo-runner.schema-verify.integration.test.ts
- .agents/skills/drive-orchestrate-plan/agents/implementer.md
- docs/architecture docs/subsystems/7. Migration System.md
- packages/1-framework/3-tooling/migration/test/aggregate/loader.test.ts
- examples/retail-store/migrations/app/20260513T0507_add_product_category_index/migration.ts
- packages/2-mongo-family/9-family/test/control-instance.descriptor-self-consistency.test.ts
- examples/retail-store/test/crud-lifecycle.test.ts
- examples/retail-store/migrations/app/20260513T0508_backfill_product_status/ops.json
- packages/3-mongo-target/1-mongo-target/src/exports/control.ts
- packages/3-mongo-target/2-mongo-adapter/test/mongo-runner.test.ts
- packages/1-framework/3-tooling/cli/test/utils/contract-space-seed-phase.mongo.test.ts
- packages/2-mongo-family/9-family/src/core/control-types.ts
- examples/retail-store/migrations/app/20260513T0508_backfill_product_status/migration.ts
- examples/retail-store/test/manual-migration.test.ts
- docs/architecture docs/subsystems/6. Ecosystem Extensions & Packs.md
- test/integration/test/mongo/family-read-marker-per-space.test.ts
- examples/retail-store/src/contract.json
- examples/retail-store/test/migration-chain.test.ts
- examples/retail-store/migrations/app/20260513T0508_backfill_product_status/migration.json
- test/integration/test/mongo/codec-rehydration-guardrail.test.ts
- packages/1-framework/3-tooling/migration/src/aggregate/project-schema-to-space.ts
- packages/2-mongo-family/9-family/vitest.config.ts
- packages/2-mongo-family/9-family/src/core/mongo-target-descriptor.ts
- test/integration/test/cli.mongo-db-sign.e2e.test.ts
- test/integration/test/contract-space-fixture-mongo/contract.ts
- packages/1-framework/3-tooling/migration/test/aggregate/project-schema-to-space.test.ts
- .agents/skills/drive-orchestrate-plan/templates/delegate-review.md
- .agents/skills/drive-orchestrate-plan/SKILL.md
- test/integration/test/contract-space-fixture-mongo/migrations.ts
- test/integration/test/mongo/aggregate-e2e.test.ts
- examples/retail-store/migrations/app/20260513T0505_initial/end-contract.json
- test/integration/test/mongo/db-verify-sign.test.ts
- packages/1-framework/3-tooling/migration/src/aggregate/loader.ts
- examples/retail-store/src/contract.d.ts
- test/integration/test/cli.mongo-db-verify.e2e.test.ts
- packages/3-mongo-target/1-mongo-target/test/marker-ledger.test.ts
- examples/retail-store/migrations/app/20260513T0507_add_product_category_index/end-contract.json
- packages/2-mongo-family/9-family/src/core/control-instance.ts
- examples/retail-store/migrations/app/20260513T0507_add_product_category_index/start-contract.json
- examples/retail-store/migrations/app/20260513T0507_add_product_category_index/start-contract.d.ts
- packages/3-mongo-target/1-mongo-target/src/core/marker-ledger.ts
…viewer to scan for them; document Cursor Multitask Mode
Three connected changes pulled into one commit because they describe one
policy: transient project planning IDs (T1.1, TC-7, AC4, P3 R2,
CKPT-2, etc.) must not leak into source code, comments, test names, or
hash fixtures, and the iteration loop must catch them at review time
rather than after merge.
1. New rule `.agents/rules/no-transient-project-ids-in-code.mdc`. A
focused, always-applied companion to `doc-maintenance.mdc`. Names
the specific token classes that are forbidden in code (task IDs,
test-case IDs, AC/FR/NFR IDs, phase/round/checkpoint IDs,
`projects/<x>/...` paths, prose attributions to the plan,
ID-named hash fixtures), explains the failure mode (transient IDs
rot silently — once the plan is renumbered or deleted at close-out,
the comment is dangling), and lists the stable references that
stay allowed (Linear ticket IDs, ADR numbers, durable docs paths).
Includes a paste-ready scan command the implementer can run on
their `+` diff before declaring a task done.
2. Reviewer protocol update in
`.agents/skills/drive-orchestrate-plan/agents/reviewer.md`. Adds
step 7 to the round workflow ("Scan for transient project IDs
leaking into code") and a dedicated `## Transient ID scan` section
with the procedure: extract the round plan IDs from `plan.md` and
`spec.md`, scan the round `+` diff for them and the structural
patterns that catch IDs missed in step 1, file every hit as a
`must-fix` finding. Adds a zero-hits clause to the
`SATISFIED` acceptance bar so the scan is enforced rather than
advisory. Adds an anti-pattern entry naming the protocol breach
(skipping the scan).
3. Implementer protocol update in
`.agents/skills/drive-orchestrate-plan/agents/implementer.md`.
Adds a `## No transient project IDs in code` section with the
high-frequency leakage shapes (test names, JSDoc, hash fixtures,
`projects/<this-project>/...` paths, prose attributions) and the
self-scan command to run before declaring a task done. Clarifies
that commit messages and PR descriptions are out-of-band of the
source-tree ban — task IDs are useful there for traceability but
forbidden inside source files.
4. Multitasking guidance in
`.agents/skills/drive-orchestrate-plan/SKILL.md`. New `##
Multitasking the loop (Cursor IDE)` section: when the user is in
Multitask Mode, both implementer and reviewer round delegations
set `run_in_background: true`, and the orchestrator uses the
wait window for productive prep (pre-stage the next delegation
prompt, prepare R<N+1> implementer scoping, drain unrelated user
questions). Explicitly forbids polling the backgrounded subagent,
forbids running two persistent subagents of the same role in
parallel (the loop is sequential per role even when each call
is backgrounded), and reaffirms heartbeats as the canonical
"stuck?" signal — backgrounding makes them more important, not
less. Wires the multitasking hook into loop steps 2 and 5 and
adds a behavioural rule to the cross-cutting invariants list.
Refs: TML-2408
Refs: PR #494
Signed-off-by: Will Madden <[email protected]>
The Mongo family is being shipped with multi-space markers as part of this PR; we have no production users on the prior single-doc shape, and the no-backward-compat-shims rule says we should not pre-pay maintenance for hypothetical legacy state. Removes the LEGACY_MARKER_ID constant, the duplicate-key error code, the upgrade/sweep helpers, the markerCollection type widener, and the entire legacy-upgrade test describe block. readMarker collapses to a single non-branching aggregate. readAllMarkers keeps the defensive `space` filter as a guard against malformed/manually-inserted docs (now framed as exactly that, not as legacy handling). Surfaced by review feedback on PR #494. Signed-off-by: Will Madden <[email protected]>
… docs Two narrow corrections surfaced in PR #494 review: - mongo-target-descriptor.ts had a comment block pointing at `projects/contract-spaces-mongo-port/spec.md`, which the no-transient- project-ids-in-code rule (the rule introduced in 7c915a2) explicitly forbids. Replaced with the durable equivalents: subsystem 10 (MongoDB Family § Contract spaces) and ADR 212. - ADR 212 listed the producer-side helpers as imported from `@prisma-next/migration-tools/exports/spaces`. The codebase imports them from `@prisma-next/migration-tools/spaces` per the no-`/exports/`- in-imports convention; documenting the canonical name avoids leading readers to a non-canonical path. Signed-off-by: Will Madden <[email protected]>
All acceptance criteria for the Mongo contract-spaces port are satisfied on this branch (PR #494) and verified end-to-end against the live test suite: - AC1 MongoControlExtensionDescriptor.contractSpace + descriptor self-consistency wired in createMongoFamilyInstance - AC2 Marker docs keyed by {_id: <spaceId>, space: <spaceId>} (legacy upgrade clause from FR4 deliberately dropped during execution; no production users on the legacy single-doc shape, upgrade path was unnecessary scope) - AC3 readMarker / readAllMarkers per-space; executeAcrossSpaces accepts >= 2 perSpaceOptions - AC4 Resumable per-space failure semantics (multi-space-runner test) - AC5 Disjointness + sibling-pruning generalised for collections - AC6 Pinned per-space contract.json / contract.d.ts / refs/head.json - AC7 Aggregate apply + per-space verify drift isolation (e2e) - AC8 Existing Mongo baseline preserved - AC9 Subsystem 10 § Contract spaces + Subsystem 7 cross-reference - AC10 All validation gates green at PR merge time - AC11 Codec-rehydration guardrail test (NFR5) Close-out actions: - Refresh ADR 021 (Contract Marker Storage) to reflect Mongo per-space marker shape now in place; remove the stale "out of scope for Mongo today" caveat, point to Subsystem 10 § Contract spaces. - Delete the transient projects/contract-spaces-mongo-port/ directory (spec, plan, specs/, reviews/) per the drive-project-workflow rule; durable docs already migrated to Subsystem 10 + ADR 212. No code changes; mechanism + docs already shipped earlier on the branch. Refs: TML-2408 Signed-off-by: Will Madden <[email protected]>
closes TML-2408
After this lands, a Mongo extension can declare a contract space the same way an SQL one does:
The framework plans, applies, verifies, and pins each space's contract through the same per-space machinery ADR 212 specifies and the SQL family already implements. The marker collection (
_prisma_migrations) gains aspaceaxis: one document per loaded space keyed by_id: <spaceId>, withspacecarried as a stamped field for partitioned reads.The decision
One architectural call separates Mongo from SQL: cross-space apply is resumable per-space, not transactional all-or-nothing. Mongo cannot wrap a multi-space apply in a single session transaction — most DDL operations bypass session transactions entirely — so cross-space rollback is not architecturally available. Instead, each space's marker advance is the commit point: per-space verify must pass before the marker advances, and a failure leaves earlier-advanced markers in place. Re-running converges (each at-head space is a no-op skip; the failed space retries; later spaces follow). The atomicity model is documented at subsystem 10 § Contract spaces, with a one-line cross-reference in subsystem 7.
What changed
Per-space marker collection.
marker-ledger.tstakes aspaceparameter on every read/write/CAS. Ledger entries gainspaceso the sameedgeIdcan recur across spaces (e.g. the synthetic ∅→head edge on first apply).readMarkeris single-path;readAllMarkersreturns the full multi-space map and defensively filters docs that lack aspacefield.Multi-space runner with per-space verify projection.
mongo-target-descriptor.tsiteratesperSpaceOptionsin caller order; per-spacerunner.executeis followed by a strict verify against the projected slice of the live database (sibling-space collections are pruned before verify runs). The runner exposes an optionalprojectSchemacallback so the descriptor can wire the slice in withoutverifyMongoSchemaknowing about contract spaces. Failure short-circuits withfailingSpaceand aMultiSpaceRunnerFailureshape that surfaces which space stopped the apply.Descriptor surface.
MongoControlExtensionDescriptor.contractSpace?carries(contractJson, migrations, headRef).createMongoFamilyInstancerunsassertDescriptorSelfConsistencyover each extension, so a staleheadRef.hashfails fast at construction with the existingMIGRATION.DESCRIPTOR_HEAD_HASH_MISMATCHrather than corrupting an apply.Schema-prune lift to a family-agnostic helper.
projectSchemaToSpaceand the loader's storage-element extractor previously knew only about SQL'sstorage.tables. They now duck-type Mongo'sstorage.collections(record and array forms) too, with the actual walk consolidated intoextract-storage-element-names.ts. NoMongoSchemaIRimport lands inmigration-tools; an unrecognised storage shape falls through unchanged.Codec-rehydration guardrail. Migration ops, once serialised to disk, must execute with no codec runtime instances loaded. A new integration test plans an app + extension aggregate, JSON-roundtrips the ops through
serializeMongoOps, and runsexecuteAcrossSpaceswith an emptycontrolStackagainstmongodb-memory-server. A future regression that re-introduces a codec lookup at apply time turns this test red.How a multi-space apply runs
For a fresh DB with one app space and one extension space:
projectSchemaToSpace, run strictverifyMongoSchemaagainst that slice.{_id: <spaceId>, space: <spaceId>, storageHash, …}) and write a ledger entry.If step 2 fails for space
N: spaces1..N−1keep their advanced markers, spaceN's marker stays at its prior hash, and the runner returns immediately withfailingSpace: N. Re-running finds1..N−1already at-head (the runner's idempotency optimisation skips them) and retriesNonward.Why this shape, not the alternatives
Why not transactional cross-space apply? That's the SQL model. Mongo session transactions don't cover most DDL operations (
createCollection,createIndex,collMod, …), so wrapping a multi-space apply inwithTransactionwould silently fail to roll back the DDL ops on abort. Resumable + idempotent ops give the same end-state property — eventual convergence to the destination contract — without claiming an atomicity Mongo cannot deliver. Subsystem 10 names the trade-off explicitly so a reader landing on the migration-system doc knows where to look.Why duck-type the storage shape in framework code, instead of registering an extractor per family? A family-registered extractor callback (the cleaner architectural answer) would touch every SQL family call site for no near-term gain; the duck-typed walk lives in one ~30-line helper with an explicit fall-through guarantee for unrecognised shapes. Worth a focused follow-up if the team wants to invert the dependency, but not part of this port.
Why no typed
.d.tsrenderer for extension contracts? The framework'scontract-space-seed-phaseemits a placeholder.d.ts(export {};) for every family's extension spaces today — not just Mongo. Byte-equivalent re-emission is satisfied by the placeholder's by-construction stability. A typed renderer is a framework-wide concern, separately tracked.Compatibility & risk
runner.execute(options)leaves the per-space projection callback unset; markers keep their existing shape on first apply ({_id: 'app', space: 'app', …}).{_id: 'marker', …}legacy doc shape is not auto-upgraded — by design (no production Mongo users on that shape; the no-backward-compat-shims rule applies). If such a doc exists it is filtered out byreadAllMarkersand the next apply against_id: 'app'proceeds unaffected.Follow-ups
operationClass: 'data'ops; no consumer requesting it; recorded in subsystem 10)..d.tsrenderer for extension contracts — framework-wide, not Mongo-specific.mongoQuery().updateMany(…)not in the runner's deserializer) and TML-2507 (MongocollModpostcheck too lenient on validator content) — surfaced while regenerating the retail-store example chain; both filed.Summary by CodeRabbit
New Features
Documentation
Tests
Chores