Repository navigation
feat: add the canonical domain contract, glossary, and decision records - #101
Merged
Merged
Conversation
|
Sorry @keyurgolani, your pull request is larger than the review limit of 150,000 diff characters |
Contract 1.0.0 for CHECKMATE-01.1 · contracts (#29), under src/lib/domain/: the 23 PRODUCT.md entities and #29's supporting terms with one label, domain name, storage name and owner each; the five lifecycle tables and the command names they use; minimum states for the other entities; progress and run completion cases for 05.2's computeRunProgress; the retention classes, purge rules and relation matrix; and Step Keys with deriveLegacyStepKey. Tests cover test plan items 3 to 5. The retention test reads pb_schema.json, so a collection or relation without a row fails.
docs/architecture/glossary.md is rendered from src/lib/domain/ by scripts/transformation/render.ts, which now writes it beside the dependency graph. vocabulary.test.ts fails when the glossary is stale, when a PRODUCT.md entity or #29 supporting term is missing, or when a decision record lacks its status and superseded clauses (test plan item 2). The eleven records cover Run, Blueprint, Step and Task, Section and reference, Step Key, aggregates, the revision store, retention, the navigation map, the visibility split and personal presentation.
Unit tests check docs/architecture/ and docs/transformation/ Markdown against the data in src/lib/domain/ and the dependency graph, and the retention test reads docker/pocketbase/pb_schema.json. A docs-only or schema-only pull request skipped those tests, so a stale glossary or an unmatched relation could merge with a green aggregate. The new contract-docs class runs unit for those Markdown files, and the fixture class now runs unit too. dependency-graph.json still runs the full set.
step-key.ts imported node:crypto, but 16.1 runs it in the browser and 05.1 keeps Node imports out of domain code. It now uses globalThis.crypto, so deriveLegacyStepKey and sha256UuidV8 are async. The golden keys are unchanged. isStepKey now follows #29's opaque-string rule: a non-empty string of up to 128 characters that isn't a PocketBase record id. Minted keys stay version-4 UUIDs and derived keys version-8, and keys authored in 16.3 files or kept by 16.1 and 16.2 imports pass.
…ess cases A legacy reference counts as checkable when it has no included child steps, since excluded and retired children aren't in the run. A step sent the state it already has is unchanged, writes nothing and never completes the run. Both rules now have cases that 05.2's computeRunProgress must pass.
Lifecycles. A scheduled run with no executable steps can go straight to completed through CompleteRun. RestoreRevisionToDraft makes a clean draft dirty, and a rollback restore leaves it clean. A rejected approval reopens its subject steps, and an upgrade's reconfirm reopens a changed done step to pending until 10.2 makes that an invalidation. Only an approval step is invalidated by a subject reopen or a rescind, and an approval step can't be excepted, so excepted to invalidated is left to the upgrade. An upgrade that drops an excluded step retires it. TRANSITION_TABLES now comes from LIFECYCLES. Commands and checks. PRECONDITIONS replaces the two check lists. It adds StartRunFromDraft, RestoreRevisionToDraft and multi-op draft calls to the aggregateRevision checks, UpdateStep and RemoveStep to the stepRevision checks, the last-seen value for SetHeaderField and SetQuestion, and the commands that take only an idempotency key. TransferOwnership is gone: 03.1 makes transfer an atomic owner swap that deletes nothing, so it has no purge. Minimum states name their fields, including catalogListings.state. Retention. A proof row nothing references purges as history, except revisions and completion records, which never leave proof, and purgeEffect applies that rule. runSources.run is a planned relation that DeleteRun's tombstone clears. Restrict rows must be required in the schema unless the row says nullable. Vocabulary. Module Include, Catalog Package, Share Capability, Template Revision and Completion Record use PRODUCT.md's wording again. Grant and Secret Reference have no invented label, and Account Preferences is labeled Account settings. Records and glossary. The records drop the 01.1- prefix to match the other leaves' records, and say what changed above. The glossary links every leaf ID to its issue, and its counts, soft-delete list and precondition table come from the data.
keyurgolani
force-pushed
the
docs/01.1-contracts
branch
from
October 20, 2026 12:45
b1172e7 to
cfca57d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements CHECKMATE-01.1 · contracts
Refs #29
What changed
src/lib/domain/, contract1.0.0:contract.ts:DOMAIN_CONTRACT_VERSION, leaf IDs and the decision record list.vocabulary.ts: the 23 PRODUCT.md entities and the supporting terms from [CHECKMATE-01.1] Publish canonical domain vocabulary and lifecycle state machines #29, each with one label, domain name, storage name and owner, plus kind keys, retired words, the seven destinations, route moves and action labels.lifecycles.ts: the five transition tables, the commands they name, what each command checks before it writes, minimum states, immutable records and aggregates.progress-cases.ts,retention.ts, andstep-key.tswithderiveLegacyStepKeyas [CHECKMATE-01.1] Publish canonical domain vocabulary and lifecycle state machines #29 specifies.docs/architecture/glossary.md, rendered from those files byscripts/transformation/render.ts. Its counts and lists come from the data, and every leaf ID links to its issue.docs/architecture/decisions/..github/ci-scope.json, so the unit job runs for the docs and schema that unit tests read.The adapter,
records.ts, the type test and the ratchet come in the next PR for #29. No service, schema or UI change.Why
Revision storage (#38), run creation (#47), expected revisions (#59) and domain events (#62) start from these names, and #30, #41 and #89 build on them.
CI scope
This touches
.github/ci-scope.jsonfrom #92. Unit tests compare the Markdown indocs/architecture/anddocs/transformation/against the data, and the retention test readsdocker/pocketbase/pb_schema.json. A change to only those files skipped the unit job, so a hand-edited glossary or a schema relation with no retention row could merge green. The newcontract-docsclass runs unit for that Markdown, and thefixtureclass runs unit too.dependency-graph.jsonstill runs every code job.scope.test.tsand CONTRIBUTING cover both.Verification
origin/next(cfcd9ae)npx eslinton the 14 changed TS fileseslint-disablenpm run lintnpx tsc --noEmitnpm test(unit, plus backend on the fixture)npx vitest run src/lib/domain scripts/transformationnpm run buildwith both PocketBase URLs onhttp://127.0.0.1:9Test plan items 2 to 5:
glossary.mdhas a row for each and matches the renderer. Every cited owner is checked againstdocs/transformation/dependency-graph.json.timeorderived, every state is reachable, immutable records have no lifecycle, and Run Step has every state and inclusion value that [CHECKMATE-07.3] Replace sync stubs with dry-run and apply upgrade plans #49, [CHECKMATE-08.3] Add deterministic conditions and structured exceptions #52, [CHECKMATE-09.1] Redesign run execution around one focused next step #53, [CHECKMATE-10.2] Add approval policy, decisions, rework, and invalidation #57 and [CHECKMATE-10.3] Issue immutable portable completion records #58 name.completedstep completes the run, a lastexceptedone only offersCompleteRun, and a resentcompletedchanges nothing. A reference whose children are all excluded or retired counts as a checkable step.shasum, and didn't change with the move to Web Crypto. Retention readspb_schema.jsonin its current shape and in PocketBase's export shape: a class per collection, a row per relation, restrict rows required unless the row says nullable, and the purge cases.I broke each new rule on purpose (a record id passing
isStepKey, noexcludedtoretiredmove, a rescind on an excepted step,UpdateStepwithout its check, a restrict row losingnullable, an unreferenced proof row staying proof, a resent completion, a hand edit to the glossary, a missing scope class) and watched the tests fail.Decisions
isStepKeytakes any non-empty string up to 128 characters that isn't a PocketBase record id, so keys written in blueprint files ([CHECKMATE-16.3] Add UI and YAML or JSON blueprints over one schema #76) or kept by imports ([CHECKMATE-16.1] Publish canonical versioned package, workflow, and proof schemas #74, [CHECKMATE-16.2] Add deterministic export, dry-run import, and migration reports #75) pass. Minted keys stay version-4 UUIDs and derived keys version-8.deriveLegacyStepKeyis async now.step-key.tsuses Web Crypto with nonode:import, because [CHECKMATE-16.1] Publish canonical versioned package, workflow, and proof schemas #74 runs it in the browser. Nothing onnextcalls it yet, and the golden values are the same.01.1-prefix to match [CHECKMATE-01.2] Specify command and projection authority for every actor type #30'senforcement-point.md, so the folder has one naming convention.CreateShareCapability,RevokeShareCapabilityandRevokeAllShareCapabilities. The last one covers both revoke-all surfaces in [CHECKMATE-03.3] Add expiring progress and completion-record capabilities #37, and [CHECKMATE-01.2] Specify command and projection authority for every actor type #30 gives it a matrix row per surface.src/, solifecycles.tslists onlyblueprints.versionas stateless and the Run record covers the sync flag.Where this differs from #29
TransferOwnershipcommand.basedOnandpublishedByon revisions get no retention row. [CHECKMATE-04.1] Split template identity, editable draft, and immutable revision storage #38 doesn't make them relations, and the retention test fails as soon aspb_schema.jsongains a relation without a row.Owner steps: none.