Factory docs, home
Page navigation

One journal aggregate per Product controls admitted delivery work; create-once delivery records retain its inputs and results. This reference owns both contracts.

Status: Accepted local core; Delivery, W30 and W31 composition candidates remain subject to their separate acceptance. The R3/R4 acceptance record records current review and verification; build review owns the disposition. No live Slice, release or customer benefit is established. Human guide.

Open gates: complete independent acceptance of the new compositions, SQLite and Git committing together, cryptographic authentication, compaction, rebind or operator override (see Trust scope); CI on these bytes and publication (acceptance receipt).

Factory consumers: Delivery and the W30/W31 author candidates compose the gate and records; their separate evidence does not extend the original core acceptance.

  • Source: gate, records, shared input readers.
  • Tests: gate, ordering, records, boundaries, shared readers, effect checks, vocabulary and outcomes, R3 regressions, R4 regressions.

Intelligence: none — Authority, admission, integration, create-once delivery records and Assessments are pure decisions over durable facts; a model would be a second authority.

What it hides

  • One aggregate, one decision. Every gate command is one CommandJournal.execute whose pure decision re-parses the stored state (parseGateState; a defect is CORRUPT, never repaired), applies its rules in order (the first failure refuses and nothing is recorded), checks the state and transition invariants and the byte budget, and emits one event. atVersion is context.version + 1; clocks (now, frozenAt) travel in the payload. No I/O happens in a decision.
  • Command IDs. gate:<p>: followed by bind, grant:<g>, revoke:<g>, stop:<n>, resume:<n>, own:<token>, release:<token>, freeze:<s>:<r>, produce:<hex48>, produced:<hex48>, check:<hex48>, dispatch:<id32>, outcome:<id32>:<status or kind> or close:<s>:<r>. stop:<n> must be the next stop (STALE otherwise) and resume:<n> the current one. A changed payload under an ID is CONFLICT; an exact repeat replays. Since refactor step R4, gateCommandIds builds each of them once, and every command checks its ID against that builder's.
  • One vocabulary. The gate and the records validate with one set of grammars, the gate's limits and strict readers in src/strict-input.ts (refactor step R4): what one refuses, the other refuses in the same words. Each grammar is a Grammar, a frozen matcher over a RegExp that only it holds. matching is declared over a Grammar (a RegExp still satisfies that type structurally, so the rule is held by the tests and the reviewers' check, not by the compiler); the gate's and the records' own patterns that it checks are Grammars, and every other pattern either module uses is private to it: no importer can recompile or replace a pattern either module validates with (a frozen RegExp would not do: RegExp.prototype.compile rewrites one before it throws; the R3/R4 acceptance record records the reviewed result). Nor does either module hand such a pattern to caller code: readSlice matches a Slice ref by calling the ref's match method, which an input may define for itself, so it passes a new RegExp made from SLICE_REF's source for each read, as its RegExp literal did before R4 (one shared RegExp there would let such an input recompile it under every later read). The RegExp objects the gate still exports are copies that neither module validates with. A change to the realm's shared built-ins, such as RegExp.prototype, is outside this: it would change every module alike. The leaf's limits and operations are frozen, it imports only node:buffer, and it stays outside both pinned closures, so a change to it touches both modules and no fixture Run or repository recipe.
  • Proof re-derivation. admitDispatch(integrate-local) runs judgeRepository inside the decision over the caller's trusted manifest, base listing and store-read Evidence. The result must canonically equal the supplied Verdict, which must be Verified. trusted and verdict are decision inputs and are never journaled; the payload keeps the prepared intent and its proof digest.
  • Ledger keys. delivery:binding:<p>, delivery:slice:<p>/<s>/<r>, delivery:snapshot:<hex>, delivery:verdict:<hex>, delivery:integration:<prepared hex> and delivery:receipt:<prepared hex>, each written once by command record:<key> at expected version 0. Reads re-validate each record against its key.

Public interface

src/product-gate.ts. Runtime imports: parseFenceIdentity from ./attempt-fence.ts, canonicalJson and JSON_LIMITS from ./canonical-json.ts, boundedObservation and parseProductBinding from ./delivery-records.ts, parsePreparedIntegration from ./repository-protocol.ts (Repository's wire grammar), the journal class and its errors from ./journal.ts, acceptanceDigest, environmentDigest, judgeRepository, parseRepositoryVerdict, parseStoreIdentity, recipeDigest and verdictDigest from ./repository-assurance.ts, and the grammars, GATE_LIMITS and the readers it uses from ./strict-input.ts. Types only from ./assurance.ts and ./repository.ts.

  • Constants: GATE_PROTOCOL = "sf-product-gate/1". GATE_LIMITS is strict-input.ts's own frozen object, re-exported. GATE_LIMITS: maxSliceIdLength 24, maxGrantIdLength 32, maxRevision 999 999, maxOccurrence 99, maxOccurrenceGap 16, maxGrantScopeEntries 64, maxSliceScopeEntries 16, maxTextLength 280, maxGrants 32, maxSlices 64, maxRunsPerSlice 20, maxAttemptsPerCheck 20, maxStops 1 000, maxElapsedMs 86 400 000, maxStateBytes 786 432. Patterns PRODUCT_ID (1–63 characters), SLICE_ID (1–24), GRANT_ID (1–32), DISPATCH_ID (32 hex): RegExp objects, as before R4, made from the grammars' sources; the gate validates with the grammars and its own private dispatch ID grammar, never with these, so recompiling or changing one changes no validation. Free texts are 1–280 printable ASCII.
  • class ProductGate(journal: CommandJournal):
    • read(productId): Gate | undefined validates the stored state (CORRUPT on any defect) and reads with readAggregate only.
    • bindStore, grant, revoke, requestStop, clearStop, takeOwnership, releaseOwnership, freezeSlice, admitProduction, recordProduction, admitCheck, recordOutcome and closeSlice return GateResult {gate, replayed} or throw GateError.
    • admitDispatch(input: AdmitDispatchInput): AdmitDispatchResult returns {admitted: true, dispatch}, a refusal {admitted: false, reason, detail, dispatch: null}, or, for an exact replay, {admitted: false, reason: "REPLAYED", dispatch}: history, never a permit. reason is typed GateErrorCode | "REPLAYED" (refactor step R4; it was string).
  • Before and after an effect (refactor step R4; pure, recording nothing, a TypeError for malformed arguments):
    • currentCheck(gate, dispatchId, owner, now): CurrentCheck answers, from one read of the gate (GateState, or undefined for a Product with no gate record), whether the admitted dispatch may start its effect now: {proceed: true}, or {proceed: false, code, detail} with detail 1–280 printable ASCII and code a CurrentCheckCode, the first of not-bound, dispatch-unknown, dispatch-settled, slice-closed, revoked, stopped, not-owner (the dispatch was admitted for another owner, or its owner is no longer the current, unreleased one) and deadline (after, not at, the Slice's deadline).
    • seamAnswer(check): SeamAnswer gives that answer in the shape the collector's CollectGate and Repository's IntegrationGuard take: exactly {proceed: true}, or {proceed: false, reason: "<code>: <detail>"} cut to Repository's bound of 256 printable ASCII.
    • observedIntegrationOutcome(observation, role): IntegrationReport maps an IntegrationObservation, read through boundedObservation, to the outcome report recordOutcome takes, for an ObservationRole: sender (its own call, or its own inspection after invokeOnce threw before any claim), receipt (a later owner reading the sender's receipt) or inspection (a later owner's own read). See invariant 14.
    • gateCommandIds (frozen): one builder per command (bind, grant, revoke, stop, resume, own, release, freeze, produce, produced, check, dispatch, outcome, close), each taking what its command's input names (stop the stop being requested, resume the current one, outcome the report) and refusing an argument no command accepts.
  • Helpers: gateAggregateId, sliceRefOf (<s>/<r>), ownerIdOf (delivery/<token>), actionIdOf (integrate-local:<p>:<sliceRef>), productionKeyOf and checkKeyOf (produce: or check: plus the first 48 hex of the SHA-256 of canonical {productId, sliceRef, proposal | candidate}), verificationRunId (ver-<hex48>, the Evidence runId), storeDigestOf, parseGateState, openDispatch (a dispatch whose outcome is null) and integrationBlocked (an integrate-local dispatch of any Slice whose outcome is null or unknown).
  • GateErrorCode: INVALID CORRUPT STALE CONFLICT LIMIT NOT_BOUND ALREADY_BOUND NOT_REGISTERED GRANT_EXISTS NO_GRANT REVOKED STOPPED NOT_STOPPED OWNERSHIP_PROOF NOT_OWNER OUT_OF_SCOPE SLICE_EXISTS SLICE_UNKNOWN SLICE_CLOSED DEADLINE ALLOWANCE PRODUCTION_OPEN PRODUCTION_UNKNOWN OUTCOME_FINAL DISPATCH_UNKNOWN DISPATCH_OPEN OCCURRENCE PROOF_MISMATCH CANDIDATE_MISMATCH NOT_VERIFIED. GateError {code, productId, currentVersion}.
  • Types: CurrentCheckCode, CurrentCheck, SeamAnswer, ObservationRole and IntegrationReport (an integration outcome without atVersion), added by refactor step R4; Operation (read | produce | check | integrate-local), ProductBinding, GrantLimits {produceRuns, checkRuns, attemptsPerCheck, integrations, elapsedMs}, Grant, StopIntent, DispatchOwner, OwnershipProof (fenced {generation, fenceNonce, alreadyFenced} or released {generation}), OwnerRef, SliceEntry, SliceDisposition, Admission, ProductionOutcome, CheckOutcome, IntegrationOutcome, Dispatch (check, integrate-local, or a reserved review that no command creates and stored state refuses), GateState, Gate, GateCommand, GateResult, and one input type per command.

src/delivery-records.ts. Runtime imports: canonicalJson from ./canonical-json.ts, the journal class and its conflict errors from ./journal.ts, parsers, digests and rejudgeRepository from ./repository-assurance.ts, parsePreparedIntegration from ./repository-protocol.ts, and the grammars, GATE_LIMITS and the readers it uses from ./strict-input.ts, in place of its own copies and mirrors of the gate's limits (refactor step R4). Types only from ./product-gate.ts, ./repository.ts and ./assurance.ts.

  • RECORD_LIMITS (frozen): maxNeedLength 2 000, maxBriefLength 16 384, maxMeasurements 16, maxPopulationLength 500, maxSnapshotsPerSlice 16, maxMetricLength 56.
  • class DeliveryLedger(journal): recordBinding / readBinding, recordSlice (returns {sliceDigest, replayed}) / readSlice, recordSnapshotManifest / readSnapshotManifest, recordVerdict (returns the proof digest) / readVerdict, recordPrepared / readPrepared, recordReceipt / readReceipt. An absent record reads as undefined. LedgerError codes: invalid-input, conflict, corrupt and missing (declared; no path throws it today).
  • deriveAssessment(slice, verdict, gathered): Assessment (pure), briefDigest, sliceDigestOf (the gate's sliceDigest), and the parsers shared with the gate: parseProductBinding, parseIntegrationObservation (each of Repository's four invocations, checked against its union by a satisfies table, so a fifth fails the typecheck, and the whole held to Repository's invocation table, invariant 11), parseSliceRecord and parseSnapshotManifest. boundedObservation(value) (refactor step R4) is the observation Repository returned with its problem cut to the free-text rule by printable, then parsed: the form in which the composition records a receipt and the gate maps an observation. It checks the shape on the value as given, before the cut, so what it refuses never depends on the problem's length. A prepared intent is parsed with Repository's parsePreparedIntegration (the records' own copy was deleted in refactor step R3, so the records no longer export one): its digest and intent commit are recomputed from the canonical payload (at most 4096 bytes), and the payload's ref must be a valid target ref (refs/heads/<name> of at most 128 characters).
  • Types: SliceNeed, SliceBrief (an optional guidance pin of the same Product), MeasurementSource (evidence {check, quantity: stdoutBytes | passed} or declared {value}), SliceRecord, SnapshotManifest, Assessment {measurements, conclusion: supported | inconclusive | rejected}, IntegrationRecord, ReceiptRecord, LedgerErrorCode.

src/strict-input.ts (refactor step R4). Runtime import: Buffer from node:buffer; nothing else. Only the gate and the records import it.

  • GATE_LIMITS (above); the grammars PRODUCT_ID, SLICE_ID, GRANT_ID, SLICE_REF (<s>/<r>), OWNER_ID (delivery/<token>), DIGEST, OBJECT_ID (40 hex) and HEX32 (an observation ID), each a Grammar; and OPERATIONS (frozen: the operations in their one order).
  • Grammar and grammar(pattern): a Grammar is a frozen object whose own source, test and exec are fixed; test and exec behave as the RegExp methods of those names over a copy of pattern that only the matcher holds, so recompiling or changing the RegExp it was given, or any made from its source, changes no Grammar. grammar refuses a pattern with flags or one that is not a RegExp (TypeError). matching takes a Grammar.
  • Readers, each returning the value it checked or throwing a TypeError that names it: exact (a plain object with exactly the keys, named sorted in the message), list, matching, oneOf, integer, finite, freeText (1–280 printable ASCII, the free-text rule), wellFormedText (1..max well-formed characters, not only white space), timestamp (ISO 8601 UTC with milliseconds), repositoryPath, absolutePath and sorted; fail throws one.
  • printable(text, max = 280) fits any text to the free-text rule: each character outside printable ASCII becomes ?, and a longer text is cut to max with a trailing .... deepFreeze and describe (an error's message, at most 512 characters and well formed).

Invariants and guarantees

  1. Common admission rules, in order (admissible): bound (NOT_BOUND); the Slice exists and is open (SLICE_UNKNOWN, SLICE_CLOSED); its grant is unrevoked (REVOKED); grant and Slice both include the operation (OUT_OF_SCOPE); no stop (STOPPED); the current, unreleased owner (NOT_OWNER); now is at or before the Slice deadline (DEADLINE). Then per command: a production checks its key is new (CONFLICT), its allowance (ALLOWANCE) and that no production is pending (PRODUCTION_OPEN); a check checks its key, its allowance and that this Slice sealed that Candidate (PRODUCTION_UNKNOWN). Tests: "admissions check authority…", and the A1 rows.
  2. Linearisation with revocation. Revoke and admit are commands on one aggregate. A revoke committed first makes a stale admission STALE and a current one REVOKED; an admission committed first stands, and the later revoke succeeds. Four revokers and four admitters racing in real processes give one history, one command per version (product-gate-ordering, A1).
  3. One in flight. At most one production with outcome null and one dispatch with outcome null per Product, whatever the Slice (PRODUCTION_OPEN, DISPATCH_OPEN). An integrate-local outcome that is null or unknown blocks every later integration of the Product, across closure and new Slices, until it is confirmed.
  4. Check dispatch, in order: bound (NOT_BOUND); an existing check admission (DISPATCH_UNKNOWN); then the common rules (admissible) on that admission's Slice, so DISPATCH_UNKNOWN precedes the Slice, revocation, scope, stop, owner and deadline checks; then a new dispatch id (CONFLICT), no open dispatch (DISPATCH_OPEN), no earlier epoch already observed (OUTCOME_FINAL), and an epoch that is the next one and within attemptsPerCheck (ALLOWANCE).
  5. Integration admission, after the common rules, in order: a new dispatch id; no open dispatch; the integration allowance; the prepared intent names this Product, store and target ref (OUT_OF_SCOPE) and this Slice, base and action occurrence (INVALID) and this owner (NOT_OWNER); the occurrence is above the Slice's highest and within maxOccurrenceGap (OCCURRENCE); the Verdict parses and digests to the intent's proof (PROOF_MISMATCH); a check admission of this Slice matches the intent's Candidate and commit and the proof's run (CANDIDATE_MISMATCH); that check's dispatch at pins.epoch recorded observed with this proof, and the pins are this Product, store, Candidate, base, commit, Slice and its three frozen digests (PROOF_MISMATCH); re-derivation succeeds, equals the Verdict and is Verified (NOT_VERIFIED); the authenticated Candidate was sealed under exactly the Slice's scope, and every edit and every file it adds, changes or removes against the authenticated base listing lies at or below a scope entry, or it is refused when its edits cannot be read (OUT_OF_SCOPE); finally the Product-wide unknown block (DISPATCH_OPEN). Before any rule, the prepared intent is parsed with Repository's own grammar: its digest and intent commit are recomputed from the payload (at most 4096 bytes) and its ref must be a valid target ref, or it is INVALID and nothing is recorded. No allowance is spent on a malformed intent, which invokeOnce refuses as invalid-input too (refactor step R3; test "a prepared intent Repository refuses as malformed…"). The gate reads no repository, though: a well-formed intent that the store never retained is admitted and spends an allowance, invokeOnce refuses it afterwards (missing) without starting an update, and the dispatch stays open, blocking the Product, until an outcome is recorded for it (refine-r3-adversarial.test.ts). An admission of a forged intent commit written before R3 is INVALID when re-issued, never REPLAYED; its stored dispatch, which keeps only the digest and the intent commit, still reads, and recordOutcome, which never parses the intent, still settles it (test "an admission of a forged intent commit written before R3…"). The step-1 spec's §4.1 list does not state the scope rule yet; the build review records the review rounds that added it.
  6. Ownership by proof only. Generation 1 takes no proof. A later generation needs fenced with the current generation and the current owner's fence nonce, or released of the current generation after that owner released (OWNERSHIP_PROOF). Time never passes ownership. The owner's fence must be {runId: productId, epoch: 1, worker: delivery/<token>}, and the owner record is at most 2 KiB. Tests H: eight racers, a dead dispatcher, 6,000 racing takeovers and 70 dead successors, and 6,000 successive idle takeovers, with real createFence and tryFence.
  7. Outcomes. A check goes from null to observed or not-started by its admitted sender, or to unresolved by the current owner of a later generation. An integration goes from null to any outcome, from unknown to confirmed, and from a reconciler's not-dispatched to unknown or confirmed; a sender's not-dispatched and confirmed are final. confirmed.target must be the Candidate commit. An outcome from an inspection needs an unrevoked grant that includes read; one from a receipt does not. Outcome recording never checks deadline, stop or closure. recordProduction takes the admitting or the current owner (only the current owner may abandon), and a sealed Candidate must be on the Slice's base. closeSlice takes no owner; integrated needs a confirmed integration of the Slice, and exactly postcondition-observed names an observation id.
  8. Counters and state. used.* equals the admissions and dispatches it counts, never decreases and never exceeds the limits. Frozen fields, grants, closures and revocations are set once. Stored state must also be a history the rules could have made: each admission and dispatch under the grant, Slice, stop and owner tenure in force at its version, no integration after an unknown, check epochs 1..n, and each integration on an observed check with its proof. State equals the fold of its events (test "the gate state equals the fold of its events").
  9. Byte budget. Growing commands (bind, grant, freeze and the admissions) refuse with LIMIT above 768 KiB; recording commands may use the journal's 1 MiB, so a successor settles every obligation from the soft limit (test "byte budget…").
  10. Product isolation. Keys, IDs and pins carry the Product; Product A cannot integrate with B's Candidate, proof or store (test "two Products in one journal…").
  11. Ledger. An observation takes each of Repository's four invocations and must agree with Repository's invocation table (repository.ts: invokeOnce and its reads), whoever supplies it: not-dispatched holds no claim and no receipt and started nothing; withheld started nothing and holds its claim, no receipt and the reason it was withheld; unknown holds a claim without a receipt; confirmed holds a claim and its receipt, or is the call's own acknowledged move whose receipt could not be retained, with the problem saying why; only the call that started the move, or withheld it, names a problem; the target is null, and exactly then the postcondition unknown, only after that call's own move; beside a receipt, the postcondition is desired-state-observed exactly when the target is the receipt's M; and the call's own confirmation read the target back at M. Anything else is invalid-input on write, corrupt on read, and a TypeError when the gate maps it. Two combinations Repository does not return stay readable, as tests unchanged since increment 2 record them: a problem beside a retained receipt, and a dispatched unknown without a problem; neither claims more than Repository could. A receipt still records only the sender's own dispatch, confirmed or unknown, so it refuses a withheld move (tests "the records accept withheld…", "the records hold every observation to Repository's invocation table…" and refine-r4-adversarial.test.ts). Create-once: identical content replays, and different content is conflict and changes nothing. A replay or a lost race re-reads the stored record with the same checks as a read, so a corrupt stored copy is corrupt, never "replayed". A record planted under another key is corrupt on read. Limits and text rules match the gate's on write and on read. A prepared intent is recorded and read only in Repository's grammar: a forged intent commit, a ref Repository's grammar refuses or a payload over 4096 bytes is invalid-input on write and corrupt on read (test "a prepared intent is recorded only in Repository's grammar…"). The records read no repository, so an intent the store never retained is recorded. A record written before refactor step R3 for a forged intent commit reads as corrupt and is never repaired (test "an admission of a forged intent commit written before R3…").
  12. Assessment is Verdict-first. deriveAssessment refuses (TypeError) a Verdict for another Product, Slice, store, base or frozen input. It judges the supplied records again in full (rejudgeRepository) and refuses a Verdict whose judgement of a check covers all of that check's records but disagrees with what they give. Failed gives rejected and Inconclusive gives inconclusive. Evidence measurements come only from a Verdict its supplied records reproduce exactly (the first judged record's facts, or passed as 1 or 0), declared values come as frozen, and anything else is null with a reason. A Verified Verdict the records do not reproduce is inconclusive; otherwise the conclusion follows the frozen predicates, with any unknown value giving inconclusive. No conclusion is stored.
  13. One current read before each effect. currentCheck proceeds only while the Product is bound, the dispatch exists without an outcome, its Slice is open under an unrevoked grant, no stop is requested, the caller is the dispatch's owner and still the current, unreleased one, and the clock is at or before the Slice's deadline, and it names the first rule that fails, in that order; the operation needs no check, because a grant changes only by revocation and a Slice's operations are frozen. Over seeded random gate histories (stops, resumptions, revocation, closure, hand-overs and release, before, at and after the deadline), the dispatch's owner proceeds exactly when a second admission of the same operation passes every common rule, and every refusal names the rule that admission fails first (test "currentCheck agrees with the admission rules…"). Given through seamAnswer, the same read answers the collector before each executor process and Repository's guard after the claim and before the move (test "one current read answers both seams…", with the real collector and Repository). It narrows the window between the read and the effect but does not close it: SQLite and Git are never one transaction.
  14. Observations to outcomes. observedIntegrationOutcome reads the observation as the records do, through boundedObservation: whole, held to Repository's invocation table (invariant 11), and with Repository's unbounded problem text cut to the free-text rule. It gives the sender what its own call did: a withheld move as its final not-dispatched with the claim D and Repository's problem as its reason, which does not block the Product; a not-dispatched read without a claim as its not-dispatched without one; and the move it started (dispatched) as its unknown or confirmed. A claim the sender's own call did not make, with or without a receipt, is unknown to it, as the step-1 spec's I8 reads its inspection (a claim is unknown, no claim not-dispatched), so it blocks the Product until a later owner's inspection confirms the move from the receipt. A reconciler reads from a receipt only a dispatched confirmed or unknown, and from an inspection nothing dispatched and nothing withheld: an inspection of a withheld move's claim reads unknown, and if the sender died before recording its non-dispatch, that unknown blocks every later integration of the Product. A confirmed outcome's target is M, the receipt's or the sender's own readback. The report is validated as recordOutcome validates one, and recordOutcome still decides authority and the transition (tests in product-gate-vocabulary.test.ts, over observations from real Repositories, and refine-r4-adversarial.test.ts).
  15. Admission times. gate.production-admitted and gate.check-admitted repeat their payload's now as at (refactor step R4). Stored state keeps no time for an admission, as before, so a gate recorded before R4 parses and folds unchanged, and a re-issued admission replays: the journal compares payloads, which did not change.

Failure semantics

  • Input defects are INVALID before any journal work. Rule failures throw their code and record nothing. VersionConflictError becomes STALE (with currentVersion), CommandConflictError becomes CONFLICT ("already recorded; re-read"; never re-issue under a new clock), and stored defects are CORRUPT.
  • admitDispatch returns every GateError except CORRUPT as a refusal result (a malformed productId still throws INVALID). Journal storage errors pass through.
  • currentCheck, seamAnswer, observedIntegrationOutcome, boundedObservation and the gateCommandIds builders record nothing and throw a TypeError for malformed arguments; a caller's seam turns a throw into a refusal (the collector's "the gate could not be read", Repository's "the guard failed").
  • Ledger: invalid-input before writing, including a record larger than one canonical journal document; conflict for different content under a key; corrupt for a stored record that fails its parser or key, or a recorded command with no record.

Trust scope

  • Established locally (macOS arm64, Node 26.8.1, real SQLite journals and Evidence stores in temporary directories): the rule order, linearisation against revocation in real processes, fence-proved ownership chains, refusal of forged and mutated proofs inside the decision, the scope rule, outcome transitions, separate allowance counters, the byte budget and refusal of corrupt state. In tests only (refactor step R4): one currentCheck read answering the real collector's gate and the real Repository's guard, and each observation real Repositories return, a move whose receipt could not be retained among them, read and mapped to the outcome its reporter records.
  • Import boundaries: test/delivery-boundaries.test.ts reads imports from the pinned TypeScript 7.0.2's unstable JS API (typescript/unstable/sync to open the project in the compiler's server, typescript/unstable/ast to walk each file's syntax tree), not from source text or diagnostics. It visits every import and export declaration with a specifier, import x = require(…), import(…) call and import('…') type, every triple-slash file reference and every identifier named require or module; specifiers are the literals' decoded text and the checker resolves each one, so comments, strings, escapes, line terminators and @ts-ignore/@ts-nocheck change nothing, and the walk must match the imports the compiler itself collected. The core modules' import tables name the export each import takes, and those modules rename no import; only an import type declaration counts as type-only, because Node's type stripping keeps every other import declaration (including import {}, import { type X } and a side-effect import) and so loads its module. Outside src/producer.ts, src/claude-producer.ts and src/openai-producer.ts, no file may reach a producer, import node:module (or module, the static source of createRequire), call import() with anything but one string literal, name require or module, or carry a /// <reference path> or types directive (the compiler adds the named file outside the import list; src/ has none); every source file must be in the program as an ES module and every import must resolve. Loaders obtained at run time (for example process.getBuiltinModule('module')) and paths handed to workers or child processes are not visible to it: it guards against accidental coupling, not deliberately hostile source. The API is unstable, so the test asserts the pinned version.
  • Not established: any composition (no bind from the Portfolio, no collector, no Git, no delivery). SQLite and Git never commit together, so a revoke can land between the final read and Git's move. The gate cannot see a fence: a fenced proof is the caller's report of tryFence, checked only against the current generation and fence nonce. Authentication is re-derivation over trusted local files, not cryptography. No compaction, rebind or operator override.

Composition

  • Depends on: Command journal, Attempt fence (parseFenceIdentity only), Repository Assurance, and Repository: its types, and its wire grammar's parsePreparedIntegration (src/repository-protocol.ts, since refactor step R3).
  • Used by: nothing outside the two modules themselves. SnapshotManifest remains reexported from the delivery records, with its unchanged neutral shape now declared in repository-protocol.ts so the Repository collector does not import this ledger for a type.
  • Intended caller contract (step-1 spec §5; increments 4–5, not built): check the Portfolio registry, create the store, record the complete binding draft (recordBinding), then bindStore; take ownership with a fence proof the caller obtained from tryFence; freeze the Slice, then record the Slice whose digest the freeze names (recordSlice); issue every command under the ID gateCommandIds builds; admit each production and check before its effect; pass the collector a CollectGate whose current() is seamAnswer(currentCheck(gate.read(p), dispatchId, owner, now)); retain the Verdict (recordVerdict) and record the prepared intent (recordPrepared) before admitDispatch; admit only an intent prepareIntegration returned; call invokeOnce only for an admitted dispatch, after the same final read, passing a guard that repeats it through seamAnswer; record each result with observedIntegrationOutcome(observation, "sender"), so a withheld result is not-dispatched with its claim; a RepositoryError from invokeOnce started no update, but the dispatch stays open until the sender settles it from an inspection (not-dispatched without a claim, unknown with one, a receipt included); record the sender's receipt (recordReceipt) of a dispatched result before its outcome, as boundedObservation(observation) reads it, since the records refuse Repository's problem text longer than the free-text rule; a later generation reconciles from the receipt first, then from an inspection (roles receipt and inspection).

Changing it safely

  • Run node --test test/product-gate.test.ts test/product-gate-ordering.test.ts test/delivery-records.test.ts test/delivery-adversarial.test.ts test/refine-r3-adversarial.test.ts test/refine-r4-adversarial.test.ts test/strict-input.test.ts test/product-gate-seams.test.ts test/product-gate-vocabulary.test.ts test/delivery-boundaries.test.ts, then npm run check.
  • Any change to a rule's order, a command ID, a key formula or a stored shape changes the recorded history: stored gates must still parse, or add a versioned reader. Keep trusted and verdict out of the journaled payload and keep re-derivation inside the decision.
  • Reviewers check: no I/O in a decision; refusals record nothing; REPLAYED is never a permit; every new obligation is bounded so that recording fits under the hard limit; strict-input.ts stays a leaf that only the gate and the records import, so a change to it is a change to both and to their receipt, never to a pinned closure; both modules validate only with Grammars or patterns no other module can reach, never with an exported RegExp, and hand no such pattern to caller code: one given to an input's own method (readSlice's match) is made for that call.

Compatibility of this refactor

Genuine admissible commands keep their identities and exact replay. R3 rejects a forged intent that the older gate admitted: reissuing it is INVALID, and reading its prepared delivery record is corrupt. The original sender can still settle the open gate dispatch. No history is rewritten or adopted as current proof.

R4 leaves stored gate shapes and command payloads unchanged. Only newly emitted production and check admission events gain at, copied from the command's now; old events are not backfilled. The separate collector closure changes under R3, so an old recipe pin does not qualify for new execution.

Private package adoption draft

The Product gate and delivery records ship with Repository in one standalone adoption draft, through their own public subpaths. Repository: private package adoption draft states its contract, proof, reviews, acceptance and limits once for all three.

The two historical candidate descriptions below retain their original gates. The bounded local qualification separately records independent installed/full acceptance at source 7cf4b26e. That historical receipt does not qualify the union. Current combined-source review and local execution are recorded in the joint qualification record; exact-final-head CI is recorded separately.

W30 worker-origin reservation candidate

An explicit worker command upgrades the existing aggregate to /2, atomically checks original request/current claimed Attempt and Product authority, and spends the original Slice production-run allowance. Legacy /1 reads/ordinary commands/history remain unchanged. Delivery and the Implementation Workflow share one native Product ownership routine. Unknown worker/provider exposure blocks another dispatch and retains its envelope; exact replay is history. Separate Producer compatibility uses the same reservation without contacting a provider. Author focused/native checks passed; final independent review and acceptance remain open. Implementation Workflow.

W31 external verification candidate

The Verification Workflow adds explicit external check origin and profiled original dispatches under sf-product-gate/2. Legacy /1 histories remain readable. admitExternalCheck authenticates the exact native Candidate/base in the bound store; it charges checks without inventing production. recoverCheck reads the original durable witness and Verdict in the same active Journal transaction and re-judges branded Evidence after native owner exclusion. recordOutcome cannot accept a recovered observed report. Missing or corrupt witnesses never permit recollection. Final independent and installed acceptance remain open.

Neutral adoption contracts, 3 October 2026

The additive ProductGateV2 uses ProductBindingV2 provenance without registry/checkout fields. Explicit registration and protected roots, grants, ownership, limits and unknown-effect rules remain mandatory. Legacy ProductGate retains binding schema sf-product-binding/1, including its explicit W30/W31 aggregate upgrade to sf-product-gate/2. ProductGateV2 selects binding schema sf-product-binding/2 and aggregate /2 from binding onward. Both facades share one Product aggregate and refuse the other binding schema, including reopening a legacy worker aggregate through the neutral facade; /2 grants no second authority or automatic migration. The Delivery ledger remains /1. See caller setup.

Current evidence and open gates.

Source: docs/agents/product-gate.md