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.executewhose pure decision re-parses the stored state (parseGateState; a defect isCORRUPT, 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.atVersioniscontext.version + 1; clocks (now,frozenAt) travel in the payload. No I/O happens in a decision. - Command IDs.
gate:<p>:followed bybind,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>orclose:<s>:<r>.stop:<n>must be the next stop (STALEotherwise) andresume:<n>the current one. A changed payload under an ID isCONFLICT; an exact repeat replays. Since refactor step R4,gateCommandIdsbuilds 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 aGrammar, a frozen matcher over aRegExpthat only it holds.matchingis declared over aGrammar(aRegExpstill 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 areGrammars, and every other pattern either module uses is private to it: no importer can recompile or replace a pattern either module validates with (a frozenRegExpwould not do:RegExp.prototype.compilerewrites one before it throws; the R3/R4 acceptance record records the reviewed result). Nor does either module hand such a pattern to caller code:readSlicematches a Slice ref by calling the ref'smatchmethod, which an input may define for itself, so it passes a newRegExpmade fromSLICE_REF's source for each read, as itsRegExpliteral did before R4 (one sharedRegExpthere would let such an input recompile it under every later read). TheRegExpobjects the gate still exports are copies that neither module validates with. A change to the realm's shared built-ins, such asRegExp.prototype, is outside this: it would change every module alike. The leaf's limits and operations are frozen, it imports onlynode: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)runsjudgeRepositoryinside the decision over the caller's trusted manifest, base listing and store-read Evidence. The result must canonically equal the supplied Verdict, which must beVerified.trustedandverdictare 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>anddelivery:receipt:<prepared hex>, each written once by commandrecord:<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_LIMITSisstrict-input.ts's own frozen object, re-exported.GATE_LIMITS:maxSliceIdLength24,maxGrantIdLength32,maxRevision999 999,maxOccurrence99,maxOccurrenceGap16,maxGrantScopeEntries64,maxSliceScopeEntries16,maxTextLength280,maxGrants32,maxSlices64,maxRunsPerSlice20,maxAttemptsPerCheck20,maxStops1 000,maxElapsedMs86 400 000,maxStateBytes786 432. PatternsPRODUCT_ID(1–63 characters),SLICE_ID(1–24),GRANT_ID(1–32),DISPATCH_ID(32 hex):RegExpobjects, 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 | undefinedvalidates the stored state (CORRUPTon any defect) and reads withreadAggregateonly.bindStore,grant,revoke,requestStop,clearStop,takeOwnership,releaseOwnership,freezeSlice,admitProduction,recordProduction,admitCheck,recordOutcomeandcloseSlicereturnGateResult {gate, replayed}or throwGateError.admitDispatch(input: AdmitDispatchInput): AdmitDispatchResultreturns{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.reasonis typedGateErrorCode | "REPLAYED"(refactor step R4; it wasstring).
- Before and after an effect (refactor step R4; pure, recording nothing, a
TypeErrorfor malformed arguments):currentCheck(gate, dispatchId, owner, now): CurrentCheckanswers, from one read of the gate (GateState, orundefinedfor a Product with no gate record), whether the admitted dispatch may start its effect now:{proceed: true}, or{proceed: false, code, detail}withdetail1–280 printable ASCII andcodeaCurrentCheckCode, the first ofnot-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) anddeadline(after, not at, the Slice's deadline).seamAnswer(check): SeamAnswergives that answer in the shape the collector'sCollectGateand Repository'sIntegrationGuardtake: exactly{proceed: true}, or{proceed: false, reason: "<code>: <detail>"}cut to Repository's bound of 256 printable ASCII.observedIntegrationOutcome(observation, role): IntegrationReportmaps anIntegrationObservation, read throughboundedObservation, to the outcome reportrecordOutcometakes, for anObservationRole:sender(its own call, or its own inspection afterinvokeOncethrew before any claim),receipt(a later owner reading the sender's receipt) orinspection(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 (stopthe stop being requested,resumethe current one,outcomethe report) and refusing an argument no command accepts.
- Helpers:
gateAggregateId,sliceRefOf(<s>/<r>),ownerIdOf(delivery/<token>),actionIdOf(integrate-local:<p>:<sliceRef>),productionKeyOfandcheckKeyOf(produce:orcheck:plus the first 48 hex of the SHA-256 of canonical{productId, sliceRef, proposal | candidate}),verificationRunId(ver-<hex48>, the EvidencerunId),storeDigestOf,parseGateState,openDispatch(a dispatch whose outcome is null) andintegrationBlocked(an integrate-local dispatch of any Slice whose outcome is null orunknown). 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,ObservationRoleandIntegrationReport(an integration outcome withoutatVersion), 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}orreleased {generation}),OwnerRef,SliceEntry,SliceDisposition,Admission,ProductionOutcome,CheckOutcome,IntegrationOutcome,Dispatch(check,integrate-local, or a reservedreviewthat 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):maxNeedLength2 000,maxBriefLength16 384,maxMeasurements16,maxPopulationLength500,maxSnapshotsPerSlice16,maxMetricLength56.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 asundefined.LedgerErrorcodes:invalid-input,conflict,corruptandmissing(declared; no path throws it today).deriveAssessment(slice, verdict, gathered): Assessment(pure),briefDigest,sliceDigestOf(the gate'ssliceDigest), and the parsers shared with the gate:parseProductBinding,parseIntegrationObservation(each of Repository's four invocations, checked against its union by asatisfiestable, so a fifth fails the typecheck, and the whole held to Repository's invocation table, invariant 11),parseSliceRecordandparseSnapshotManifest.boundedObservation(value)(refactor step R4) is the observation Repository returned with its problem cut to the free-text rule byprintable, 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'sparsePreparedIntegration(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}ordeclared {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 grammarsPRODUCT_ID,SLICE_ID,GRANT_ID,SLICE_REF(<s>/<r>),OWNER_ID(delivery/<token>),DIGEST,OBJECT_ID(40 hex) andHEX32(an observation ID), each aGrammar; andOPERATIONS(frozen: the operations in their one order).Grammarandgrammar(pattern): aGrammaris a frozen object whose ownsource,testandexecare fixed;testandexecbehave as theRegExpmethods of those names over a copy ofpatternthat only the matcher holds, so recompiling or changing theRegExpit was given, or any made from itssource, changes noGrammar.grammarrefuses a pattern with flags or one that is not aRegExp(TypeError).matchingtakes aGrammar.- Readers, each returning the value it checked or throwing a
TypeErrorthat 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,absolutePathandsorted;failthrows 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 tomaxwith a trailing....deepFreezeanddescribe(an error's message, at most 512 characters and well formed).
Invariants and guarantees
- 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);nowis 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. - Linearisation with revocation. Revoke and admit are commands on one aggregate. A revoke committed first makes a stale admission
STALEand a current oneREVOKED; 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). - 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 orunknownblocks every later integration of the Product, across closure and new Slices, until it is confirmed. - Check dispatch, in order: bound (
NOT_BOUND); an existing check admission (DISPATCH_UNKNOWN); then the common rules (admissible) on that admission's Slice, soDISPATCH_UNKNOWNprecedes the Slice, revocation, scope, stop, owner and deadline checks; then a new dispatch id (CONFLICT), no open dispatch (DISPATCH_OPEN), no earlier epoch alreadyobserved(OUTCOME_FINAL), and an epoch that is the next one and withinattemptsPerCheck(ALLOWANCE). - 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 withinmaxOccurrenceGap(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 atpins.epochrecordedobservedwith 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 isVerified(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 isINVALIDand nothing is recorded. No allowance is spent on a malformed intent, whichinvokeOncerefuses asinvalid-inputtoo (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,invokeOncerefuses 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 isINVALIDwhen re-issued, neverREPLAYED; its stored dispatch, which keeps only the digest and the intent commit, still reads, andrecordOutcome, 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. - Ownership by proof only. Generation 1 takes no proof. A later generation needs
fencedwith the current generation and the current owner's fence nonce, orreleasedof 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 realcreateFenceandtryFence. - Outcomes. A check goes from null to
observedornot-startedby its admitted sender, or tounresolvedby the current owner of a later generation. An integration goes from null to any outcome, fromunknowntoconfirmed, and from a reconciler'snot-dispatchedtounknownorconfirmed; a sender'snot-dispatchedandconfirmedare final.confirmed.targetmust be the Candidate commit. An outcome from an inspection needs an unrevoked grant that includesread; one from a receipt does not. Outcome recording never checks deadline, stop or closure.recordProductiontakes the admitting or the current owner (only the current owner may abandon), and a sealed Candidate must be on the Slice's base.closeSlicetakes no owner;integratedneeds a confirmed integration of the Slice, and exactlypostcondition-observednames an observation id. - 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 anunknown, check epochs1..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"). - Byte budget. Growing commands (bind, grant, freeze and the admissions) refuse with
LIMITabove 768 KiB; recording commands may use the journal's 1 MiB, so a successor settles every obligation from the soft limit (test "byte budget…"). - 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…").
- Ledger. An observation takes each of Repository's four invocations and must agree with Repository's invocation table (
repository.ts:invokeOnceand its reads), whoever supplies it:not-dispatchedholds no claim and no receipt and started nothing;withheldstarted nothing and holds its claim, no receipt and the reason it was withheld;unknownholds a claim without a receipt;confirmedholds 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 postconditionunknown, only after that call's own move; beside a receipt, the postcondition isdesired-state-observedexactly when the target is the receipt's M; and the call's own confirmation read the target back at M. Anything else isinvalid-inputon write,corrupton read, and aTypeErrorwhen 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 dispatchedunknownwithout a problem; neither claims more than Repository could. A receipt still records only the sender's own dispatch,confirmedorunknown, so it refuses a withheld move (tests "the records accept withheld…", "the records hold every observation to Repository's invocation table…" andrefine-r4-adversarial.test.ts). Create-once: identical content replays, and different content isconflictand 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 iscorrupt, never "replayed". A record planted under another key iscorrupton 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 isinvalid-inputon write andcorrupton 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 ascorruptand is never repaired (test "an admission of a forged intent commit written before R3…"). - Assessment is Verdict-first.
deriveAssessmentrefuses (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.FailedgivesrejectedandInconclusivegivesinconclusive. Evidence measurements come only from a Verdict its supplied records reproduce exactly (the first judged record's facts, orpassedas 1 or 0), declared values come as frozen, and anything else isnullwith a reason. AVerifiedVerdict the records do not reproduce isinconclusive; otherwise the conclusion follows the frozen predicates, with any unknown value givinginconclusive. No conclusion is stored. - One current read before each effect.
currentCheckproceeds 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 throughseamAnswer, 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. - Observations to outcomes.
observedIntegrationOutcomereads the observation as the records do, throughboundedObservation: 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: awithheldmove as its finalnot-dispatchedwith the claim D and Repository's problem as its reason, which does not block the Product; anot-dispatchedread without a claim as itsnot-dispatchedwithout one; and the move it started (dispatched) as itsunknownorconfirmed. A claim the sender's own call did not make, with or without a receipt, isunknownto it, as the step-1 spec's I8 reads its inspection (a claim isunknown, no claimnot-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 dispatchedconfirmedorunknown, and from an inspection nothing dispatched and nothingwithheld: an inspection of a withheld move's claim readsunknown, and if the sender died before recording its non-dispatch, thatunknownblocks 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 asrecordOutcomevalidates one, andrecordOutcomestill decides authority and the transition (tests inproduct-gate-vocabulary.test.ts, over observations from real Repositories, andrefine-r4-adversarial.test.ts). - Admission times.
gate.production-admittedandgate.check-admittedrepeat their payload'snowasat(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
INVALIDbefore any journal work. Rule failures throw their code and record nothing.VersionConflictErrorbecomesSTALE(withcurrentVersion),CommandConflictErrorbecomesCONFLICT("already recorded; re-read"; never re-issue under a new clock), and stored defects areCORRUPT. admitDispatchreturns everyGateErrorexceptCORRUPTas a refusal result (a malformedproductIdstill throwsINVALID). Journal storage errors pass through.currentCheck,seamAnswer,observedIntegrationOutcome,boundedObservationand thegateCommandIdsbuilders record nothing and throw aTypeErrorfor 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-inputbefore writing, including a record larger than one canonical journal document;conflictfor different content under a key;corruptfor 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
currentCheckread 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.tsreads imports from the pinned TypeScript 7.0.2's unstable JS API (typescript/unstable/syncto open the project in the compiler's server,typescript/unstable/astto 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 andimport('…')type, every triple-slash file reference and every identifier namedrequireormodule; specifiers are the literals' decoded text and the checker resolves each one, so comments, strings, escapes, line terminators and@ts-ignore/@ts-nocheckchange 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 animport typedeclaration counts as type-only, because Node's type stripping keeps every other import declaration (includingimport {},import { type X }and a side-effect import) and so loads its module. Outsidesrc/producer.ts,src/claude-producer.tsandsrc/openai-producer.ts, no file may reach a producer, importnode:module(ormodule, the static source ofcreateRequire), callimport()with anything but one string literal, namerequireormodule, or carry a/// <reference path>ortypesdirective (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 exampleprocess.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
fencedproof is the caller's report oftryFence, 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 (
parseFenceIdentityonly), Repository Assurance, and Repository: its types, and its wire grammar'sparsePreparedIntegration(src/repository-protocol.ts, since refactor step R3). - Used by: nothing outside the two modules themselves.
SnapshotManifestremains reexported from the delivery records, with its unchanged neutral shape now declared inrepository-protocol.tsso 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), thenbindStore; take ownership with a fence proof the caller obtained fromtryFence; freeze the Slice, then record the Slice whose digest the freeze names (recordSlice); issue every command under the IDgateCommandIdsbuilds; admit each production and check before its effect; pass the collector aCollectGatewhosecurrent()isseamAnswer(currentCheck(gate.read(p), dispatchId, owner, now)); retain the Verdict (recordVerdict) and record the prepared intent (recordPrepared) beforeadmitDispatch; admit only an intentprepareIntegrationreturned; callinvokeOnceonly for an admitted dispatch, after the same final read, passing aguardthat repeats it throughseamAnswer; record each result withobservedIntegrationOutcome(observation, "sender"), so awithheldresult isnot-dispatchedwith its claim; aRepositoryErrorfrominvokeOncestarted no update, but the dispatch stays open until the sender settles it from an inspection (not-dispatchedwithout a claim,unknownwith one, a receipt included); record the sender's receipt (recordReceipt) of a dispatched result before its outcome, asboundedObservation(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 (rolesreceiptandinspection).
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, thennpm 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
trustedandverdictout of the journaled payload and keep re-derivation inside the decision. - Reviewers check: no I/O in a decision; refusals record nothing;
REPLAYEDis never a permit; every new obligation is bounded so that recording fits under the hard limit;strict-input.tsstays 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 withGrammars or patterns no other module can reach, never with an exportedRegExp, and hand no such pattern to caller code: one given to an input's own method (readSlice'smatch) 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.
