Gate P10 — Team exchange¶
Status: Gate P10 passed (2026-11-18, owner acceptance). G0–G8 pass. Declared deviations, all by owner decision: G4's team_doc fuzz ran 17.4 h, not 24 h (stopped at libFuzzer's 4 GB RSS limit, traced to ASan's allocator); G5's git commit budget is measured over a trivial hook; G6 ran the bare-remote trial only, without the ≥ 5-day real-remote part. The owner's review of 2026-11-18 is fixed (bfe1668, 7a6e2da) and G1, G3, G5 and G6 were rerun on it. Normative contract: SPEC v1.10.1, especially SD21, §5 P10 and §§6–8. Design and review history: ADR 0018 r0.6, accepted.
G0 — Design review and acceptance¶
The review was non-implementing. Findings and their dispositions are preserved in ADR 0018 §14.
| Round | Findings / disposition | Result |
|---|---|---|
| r0.1 | 5 blockers, 10 majors, 15 minors | revised |
| r0.2 closure | 3 blockers, 7 majors, 17 minors | revised; replaced the cross-store premise join with local mirrors |
| r0.3 closure | 2 blockers, 9 majors, 17 minors | revised; origin, branch visibility and replica-channel protection made explicit |
| r0.4 closure | remaining boundary and protocol questions recorded in §14 | revised in r0.5 |
| r0.5 review | 1 blocker, 5 majors, 4 further points | closed in r0.6: one-way Git commitments, publish-time policy, local Read checks, strict history, announce fence and checkpoint capacity |
| r0.6 closure | 1 P1 and 3 P2 | closed in place: post-Compact state, per-proposal capacity, format bounds and complete remote-object enumeration |
| final r0.6 review | no blocker or major; clarify the Compact reserve exception | clarified: ordinary proposals reserve one future Compact id; Compact consumes it and checks its actual size |
| owner acceptance, 2026-11-16 | authorised the clarification, SPEC v1.10.0 and G0 pass | G0 passed; ADR accepted |
O1–O7 take the recommended decisions recorded in ADR §0.1: no code anchors inside team knowledge in P10; plaintext Git payloads with the declared shred/history limits; no local dependency on unpublished proposals; custom generation refs with an orphan-branch fallback; auto publish becoming confirm for multiple local authors; Pin/Cur/Ref team rules without Sem; and bounded pre-push sync with ReplicationLag warning behavior. SPEC is authoritative for these contracts; the ADR preserves the alternatives and reasoning.
Gate status and required evidence¶
| Gate | Status | Required evidence |
|---|---|---|
| G0 | passed | r0.6 review closure, owner acceptance and SPEC v1.10.0 |
| G1 | passed (023ed9d; rerun bfe1668, 7a6e2da) | scripts/check.sh exit 0 on the remote Linux host: fmt, clippy, every workspace test, loom, the script tests, the dependency boundaries (after nix was recorded for contextdb-cli, ed6f1d3), cargo deny (advisories, bans, licenses, sources), contextdb-dd and the fuzz crate; CI green on Linux and macOS (one P5b timing test failed on the macOS runner and passed on rerun) |
| G2 | passed | every T-ID of T109–T121 traced in p10-g2.md; declared: two admins resuming as a real race, catch-up kill points in process rather than a killed ctxd |
| G3 | passed (023ed9d; rerun bfe1668) | PROP17, PROP18, PROP19, PROP13 and the T114 kill points at 10,000 seeds; G-LAG at 300 seeds |
| G4 | passed with a deviation (owner decision 2026-11-18) | 24 h fuzz of seven targets with 0 crashes; team_doc stopped at libFuzzer's 4 GB RSS limit after 17.4 h, which the owner accepted (see the G4 note); import/publish/compaction kill points and hostile or rewritten remote refs are tested in the workspace (G1 at 023ed9d) |
| G5 | passed (023ed9d; rerun bfe1668, hooks 7a6e2da; recall 6c05509) | every budget below met; the git commit budget is measured over a trivial hook (owner decision 2026-11-17) |
| G6 | passed, bare-remote trial only (023ed9d; rerun 7a6e2da) | the ≥ 5-day real-remote part is skipped by owner decision (2026-11-17), as for P9 |
| G7 | passed (bfad171) | previous phases' required G2/G3/G4 regression suites, including P9 authorisation, shred, branch and strict-certificate boundaries |
| G8 | passed: both independent reviews and the owner's review fixed or declared; owner acceptance 2026-11-18 | user documentation, CHANGELOG, SPEC traceability and an independent implementation review with findings closed or declared |
G0 itself claimed no implementation evidence; the evidence is in the rows above and the notes below. Format 6 and protocol 8 are implemented; installed stores stay at format 5 / protocol 7 until a release. P9's owner-skipped G6 is unchanged by this acceptance.
Test traceability¶
| Tests | Contract |
|---|---|
| T109 | portable encoding, reserved namespaces, supported team kinds and batch routing |
| T110, T112 | real-hook import, partial clones, deterministic rejection and frozen accept semantics |
| T111 | publish races, dry runs, signing, publish-time authorisation/egress and fixed confirm sets |
| T113, T114 | immediate announce fence, lag, daemon restart and crash recovery |
| T115, T116 | precise local invalidation and strict head/base history, including ABA and gaps |
| T117 | P9 local Read/Write/Curate, queue redaction, team lane defaults and shred interaction |
| T118 | signed real-OID compaction, follower/joiner equality, exact capacity and successor recovery |
| T119 | format 5 → 6, protocol 8 and chained hook veto |
| T120, T121 | mirror origin/visibility, branch/merge protection and remaining boundary regressions |
| PROP17–PROP19 | independent deterministic acceptance/digest, publish/import equivalence and mirror/history invariants |
G5 — Budgets¶
Initial ADR-calibrated budgets, measured with the workload and fsync/copy-on-write costs reported:
- Import 10,000 entries into the replica in ≤60 s on the remote Linux host.
- Join 10,000 entries with 10 open branches in ≤120 s; report copy-on-write memory.
- Catch up one entry on 10 open branches in ≤50 ms; report op_log batches, fsyncs and memory.
- Publish ten proposals to a local remote with ≤2 s added to
git push. - Add ≤20 ms to
git committhroughreference-transaction, measured over a trivialreference-transactionhook on the same host (owner decision 2026-11-17, below); a team-ref fetch's durable announce and ACK add ≤50 ms. - Compact and join 100 MiB of team state; report time and peak memory, including the streaming verification buffer separately from resident state.
- Recall p99 with 10⁴ mirrors stays within +10% of the baseline with the same record count.
G6 — Real use¶
First use two clones, two signing keys and a bare remote on one machine. Then use a real team remote with agents on both edges for at least five days, at least 50 accepted entries and at least two members. Record:
- Equal team digests checked daily.
- Zero lost proposals: each ends accepted, rejected, conflicted or dropped.
- Probe records depending on every changed team record, read after each fetch: every supersede/retraction invalidates the other edge within one fetch.
- Zero code pushes blocked by publish or ReplicationLag under the default policy.
- No ReplicationLag persisting beyond one fetch after the last import.
Implementation plan¶
These milestones organise future work; none is marked complete by G0:
- Portable team document/ops, signed-chain validation, frozen acceptance and independent oracle.
- Replica storage/import/recovery, checkpoints and exact state limits.
- Kernel origin, replica channel, MirrorAttach, branch catch-up/history and merge protection.
- Proposal queue, P9 authorisation/redaction, publish policy, signing and recovery.
- Hooks, durable announce fence, lag/certificates, CLI, migration and protocol.
- Full gate evidence, real-remote dogfood and independent implementation review.
Implementation notes¶
Clarifications made while implementing milestone 1. They fix details the ADR and SPEC leave open and do not change any guarantee.
Refnames its revision. A team rule's reference isRef(content), likePin(content): the kernel'sRefedge targets a revision, and a rule's identity must not depend on the replica's state.- Genesis carries a
batch. Generation 0's first entry has the ordinary tree with one proposal whose only op isSetTeamAccess{doc}; it is signed by an admin of that document. Every entry is parsed the same way. - The Compact reserve is a proven bound. Where the future
Compact's accepted id lands among the sorted items changes the next-fit chunk packing. Next-fit gains at most one chunk when one item is inserted anywhere, so an ordinary proposal is accepted only ifckpt_size(Σ) + item(64-byte member) + 44 ≤ state_bytes(one item and one index entry). Thenckpt_size(Σc) ≤ state_bytesfor everyCompact, whatever its id and author. - git ≥ 2.44 for partial clones.
ctxdreads team objects withGIT_NO_LAZY_FETCH=1, so a partial clone reports missing blobs (ReplicaIncomplete) for the hook to fetch by id in the user's environment (§8.1). Older git ignores the variable and would try the promisor itself, without credentials or a terminal; it fails instead of hanging, and the import stays incomplete until a newer git orctx team syncfetches the objects. - The decision log is the replica's durable form.
<data>/teams/<id>/logholds every decided entry with the bytesacceptread, framed and checksummed; open replays it throughaccept(deterministic), cuts a torn tail, and import fetches what is missing from git. Snapshots of the replica (the checkpoint encoding) are a later optimisation, measured against the G5 join budget. - Admission details the SPEC leaves open (milestone 3).
- A mirror as a local rule's conclusion is
ReplicaReadOnly(SD21.7 and the §6.2 P10 order), checked before the canonical rule checks; §2.5 A1'sForbiddenConclusionwording is superseded for replica origin. - No artifact of any type may target a mirror (
ReplicaReadOnly), not only Conflict sides: only the replica channel writes mirror state, and an artifact a merge carried could otherwise land where its target is invisible. The P7 judge targets the local side. - "Rebind target" means a rule whose conclusion is a mirror. Rebinding a local dependent onto a newer mirror head is the intended recovery for
Cur(ADR §5.3). - A replica-origin create outside its own team's namespace is
InvalidKey(key) orInvalidLane(lane). ReservedNamespace applies in the multi-branch kernel only; the team replica's plainDbkeeps itsteam/keys with Local origin and its own A5. gap = trueon a scope that is notteam:isChannelRestricted. The replica channel may not runExpectHeads, branch ops or merges (ChannelRestricted).- The shred exemption also skips
MissingBlobfor a replica write of shredded content: its bytes are gone, and the revision reads unavailable. - A replica
SetMetadatawith non-emptydirsisInvalidMetadata: only tags are mirrored (Q9). - The kernel does not check that a replica batch's principal is the store owner; no client socket maps to
Channel::Replica(transport trust, as for the observer). - MirrorAttach mechanics.
headis a content hash; the op brings in the logical and its head revision only (other revisions arrive by replicaAddRevision, a dedup import) and adds nothing toAllocations. If no branch holds a revision withheadyet — a branch caught up alone, ahead of the others — the attach creates it, as a replicaAddRevisionwould (MissingBlobunless its bytes are present or shredded); otherwise it imports the existing one. A key already visible on the branch isLogicalExists; a key with no replica-origin logical isUnknownRef; both are decided after the channel check, so a non-replica caller learns nothing about keys. (PROP19 at 10,000 seeds found the first version, which refused a head no branch held, failing such a catch-up.) In a batch that attaches, logicals are named byNew(k)or key: an invisible global logical id isUnknownRefthere (the kernel'sExisting(next + i)convenience for fresh logicals is not available when attached and fresh logicals interleave; the oracle never had it). - op_log format 6. Format 6 keeps format 5's frame layout; what it adds is permission to log the P10 encodings (the replica channel, a replica-origin create, MirrorAttach, a gap watermark), which a format-5 build refused as
CapacityExceeded{Encoding}. The 5 → 6 migration changes only the log: batches, batch hashes, idempotency records and frame checksums are unchanged, the old log is kept aslog.v5.bak, and packs, keys, projections and modes stay format 5's. A format-6 build opens a format-5 log only afterctx migrate(T119,crates/contextdb-store/tests/p10_migrate.rs). The legacy fixture writer now replays through the kernel, so fixtures can hold branches and merges. - Merges and mirrors. A merge takes no replica-origin state (head, base, tags, revisions, visibility) and makes no mirror visible; a mirror's artifacts (none can exist) are excluded as a defence. After classification and authorisation (
MergeUnauthorized) and before the plan, a carried rule whose premise or reference is a mirror revision the target cannot see, or a taken ValidationRecord whose curvec names one, isMirrorLag(the SPEC names rules only; a validation would otherwise land with an invisible curvec). Merge-time A5 exempts mirrors by origin, as commit-time A5 does — PROP13 caught the oracle missing this exemption on its first 300 seeds. - Proposals and publish (milestone 4).
- The local layer replies alike for a record its author cannot read and for one that does not exist:
Unauthorized(Read)naming only what the author named. The one exception is creating a taken key (LogicalExists, SPEC's global key namespace), hidden queued proposals' keys included. Team administration ops (SetTeamAccess,TeamShred,Compact) may be proposed by the store owner only. - A queued proposal is visible to its author, the store owner, and principals who may read every lane it writes; listings show nothing else, not even a count. A team-layer rejection that only a hidden proposal causes is a bare
QueueConflictat enqueue (not yet covered by a test: it needs a hidden proposal that changes a team-layer outcome while the local layer passes, e.g. through the state limit). preparebuilds one entry per call within the limits; the hook repeats prepare → sign → begin → push while proposals remain. A proposal depending on one in flight (published, not yet decided) waits for that outcome.- The policy version compared at the linearization point is opaque to the team crate; the daemon passes the epoch of the access document in force.
- Outcomes come from the decided entries the store recorded during import (and log replay):
accepted,rejected{code}; a published proposal whose commit the tracking ref does not contain after a fetch is queued again. - ReplicationLag and the strict gap (milestone 5).
ReplicationLagis an overlay on the SD13 summary, applied at read time: when a mirror of team T is in the read's L2-witness closure (the same support set asObservationLag, Sem heads included; a direct read of a mirror included) andlive_pos["team:<hex>"]is absent or differs from the branch's watermark, a summary ofPENDING(StructuralUnknown|Semantic)orCERTIFIEDbecomesPENDING(ReplicationLag); UNAVAILABLE, CONFLICTED, STALE andObservationLagkeep precedence. Nothing is stored in L0/L1/L2 or inDimensions. The daemon expresses every lag cause of §8.3 (tip ahead of the watermark, pending announce, fetch in flight, stalled import) by what it puts inlive_posfor the team scope; validation reports the scope inUnknown{lag}with code scopes. Forstrict_no_aba, the branch's in-memory change log records the epochs ofgap: truewatermark ops per team scope; a vector item that is a mirror of that team is a strict change when one falls after itssince_epoch. Ateam:watermark advancing is not a strict change (only code anchors' scopes are). The oracle takes the gaps as a separate per-epoch input (cert_validate_oracle_gaps) that the test derives from the batches, becauseInputshas an on-disk encoding and gains no field.catch_upwrites through aWriter(the kernel, or the daemon's store), so tests can record every intermediate state. T116 (crates/contextdb-team/tests/t116_certs.rs) checks every case of §13 against the oracle. - Routing a write (milestone 5). The kernel decides first (
WHAT_IFon the single writer): a batch it accepts is local, and every P9 refusal (Unauthorized(Read)for a hidden name included) is returned as is. OnlyReservedNamespace,ReplicaReadOnly, orUnknownRefon a batch naming ateam/key, which the kernel decides after references resolve and after P9's checks, send the batch tofrontend::translate. Classification is by write target:CreateLogicalwith a team key in the same team's lane, andAddRevision,SetHead, base changes and tags on a team record becomeNew,Revise,SetHead,SetBase,SetTags; a rule whose conclusion is a team record becomesAddRule(premises and references asPin/Cur/Refof the same team, elseTeamDepOutside);Rebindof such a rule is disable plus add.ExpectHeadsis a read, not a target: in a team proposal its entries becomeExpectops first (a local record there isTeamDepOutside); in a local batch an entry naming a team key that is only queued (in the author's overlay, not mirrored) isUnpublished. Team and local targets together, or two teams, areMixedTeamBatch. Not portable and kept as the kernel's refusal: aSempremise in a team rule (O6), localdirson a mirror (Q9), a team key in a non-team lane (ReservedNamespace). Expected values come from the team as this edge sees it — the replica with the author's readable queued proposals applied — because a mirror's base is the team status on the head only (§5.1) and mirrors carry no rules: a local batch can name a team rule only if it adds it. T109 (crates/contextdb-team/tests/frontend.rs). - The daemon (milestone 5). Joined teams (
<data>/teams/<hex id>/: the replica's anchor and decision log, the proposal queue, andconfigwith the git work tree, the bound member and key, and the O5 publish settings) are opened at start and owned by the commit actor.TeamImport(at start, everylag_checkof 2 s, andctx team sync) imports each team's tracking refs and then brings every open branch up through the actor's own group commit, each batch carrying the mirror payloads from the replica; a refused branch isReplicaStalledwith the branch named, and import stops are recorded. Reads takelive_posfor team scopes from shared in-memory state: the tracking ref's tip as last read, withheld while an announce is pending or import is stopped. A fetch in flight is a pending announce: the fetch hook writes the announce durably before git moves the ref, andctxdruns no fetch of its own (anin_flightcounter that was never incremented was removed; review finding 13). A write the kernel refuses as a team write (Service::commitandctx_commit) goes to the actor'sTeamRoute: translated against the author's overlays and queued, answeredProposed{team, id}(protocol 8:Proposed,TeamLines,TeamSync); a store with no joined team never takes this path. Team-layer refusals useTxError::Team{code}, whosecodeis the SPEC name the client sees. ctx team(milestone 5).createwrites the genesis (SetTeamAccesswith the creator as admin and member,--lanes written by*membersand curated by*admins), signs it withssh-keygen -Y sign -n git(a.pubkey path uses the agent,-U; the signature is verified in-process against the key before use), pushes it with hooks off, then joins.joinadds the fetch refspec, fetches in the caller's environment, takes the team id from the out-of-band genesis entry, builds the replica in the CLI process (beforectxdopens the directory), binds the member listed for--key(NotTeamMemberotherwise; the half-built directory is removed), writesconfig, and asks a runningctxdto open and import it (TeamOpen).publishruns §7.2 steps 5–10 by hand — fetch and sync, prepare (a confirm listing prints its token), sign, begin (again onPolicyChanged/QueueChanged), push with hooks off (a non-fast-forward isTeamPublishRefusedand a retry, at most 3), sync and show the outcomes. Tested with the real binary, real git and real SSH keys (crates/contextdb-cli/tests/p10_team_cli.rs).- The announce fence in
ctxd(milestone 5).TeamAnnounce{team, ref, oid, pid}records the announce in the pending set under the lock reads take, then acknowledges;TeamWithdrawremoves it;TeamNotifyqueues an import without waiting. The durable form is<data>/teams/<hex>/announce(ref oid pidlines), appended and fsynced by the hook under an exclusiveflockonannounce.lock;ctxdreads every team's file after its sockets are bound and rewrites it, under the same lock, only to drop resolved lines, so a concurrent append is never lost. Each import resolves pending announces after reading the tip: one is done when the tracking ref contains its OID, or when its git process is gone (kill(pid, 0)) and the ref does not contain it. Tests: lag while an announce is pending, kept while its process lives, withdrawn, dropped for a dead process, resolved by the import that brings its OID. - The hook dispatcher (milestone 5). Every ContextDB hook is one fixed script,
exec ctx git-hook <name> <hooks dir> "$@". It buffers the input ofpre-pushandreference-transaction, runs the user's original hook (kept as<name>.contextdb-original) with the same arguments and input, then the components registered in<hooks dir>/contextdb.components:anchors(P5a scan onpost-commit,post-checkout,post-merge),anchors-gate(P5apre-pushgate),team(reference-transaction,post-merge,pre-push).ctx anchors hooks install|uninstallandctx team joinregister components; a hook no component uses gets its original back, and P5a's old scripts are replaced in place.reference-transaction: a failing user hook is returned as is; inpreparedevery new team OID is appended to the announce file (fsynced, under the flock), then sent to a listeningctxdwith a 500 ms acknowledgement bound — failure vetoes;abortedwithdraws;committednotifies.pre-push: refuses deletingrefs/contextdb/team/*and uploadingrefs/contextdb/remotes/*; runs a bounded sync (fetch andTeamSyncwithinpush_timeout); runs the P5a gate (lag only warns, O7); then, for teams whose remote name and URL this push uses, publishes under aflockedpublish.lock(the kernel releases a dead holder's) unless the push is a dry run. The push's arguments are found by walking up from the hook's parent (/proc/<pid>/cmdlineon Linux; on macOSps -ww -o args=, sinceunsafeis forbidden in the workspace andKERN_PROCARGS2needs it: an argument containing a space splits, which in git's push grammar can only add dry runs, never hide-n) and parsed with git's option grammar (-n,--dry-runand its abbreviations, grouped short options,--no-dry-run,--,-ovalues); an alias, or arguments not found, skips publish with a warning. Publish failures fail the code push only withstrict_push. In a partial clone,committedalso starts a detachedctx team fetch-missing:git rev-list --objects --missing=printover the new team commits (lazy fetching off) names what the clone lacks, which is fetched by OID through the promisor remote beforectxdis notified again (§8.1 step 2, Q13);joinfetches the genesis entry's objects the same way, and retries an import that reportsReplicaIncompletewith the OIDs it names. Tested with real git and real processes: a dry run publishes nothing, a real push publishes and the proposal is accepted, a fetch on the other clone imports through the hooks alone, a blobless clone joins and its plaingit fetchleaves no team object missing, and deleting the team ref is refused. - Leaving (milestone 5).
ctx team leave --yesasksctxd(TeamLeave), which recordsleavingdurably in the team's directory first, then writes on every open branch (archived ones are not written) one replica-channel batch retracting every base of the team's mirrors and setting the watermark to the sentinelleft, then deletes the team's directory; the CLI then deletes the tracking refs and, with no team left in the data directory, the fetch refspec and the hook component. A team opened withleavingrecorded is never imported or caught up: its next import finishes the leave (Q12). Ateam:scope whose watermark isleftnever lags, in the kernel and in the oracle, since nothing in it is base. Tests: the mirror and its dependents unsupported after a leave, the watermarkleft, the directory gone, a second leave refused; a recorded leave finished at the next start without mirroring a newer root entry. ctx team why(milestone 5).TeamWhy(store owner, admin socket) answers from the replica: the record's head, its status at the root with the replica's sequence, whether the head is base, and every rule concluding the head with its premises and references namedpath@content— never by replica ids (m15).ctx team rebuild(milestone 5).TeamStore::rebuildmoves the decision log aside, recreates the replica from the trust anchor — the genesis, or the last verified checkpoint entry, which import now writes toanchorwhen it follows a successor (Q13) — imports from git, and deletes the old log only once the new one is complete (on failure it is put back).ctxdthen catches every branch up with ordinary batches; a branch whose position the new history no longer holds is caught up across a gap (§5.2). The local op_log is never rewritten. Tests: a genesis rebuild reaches the same digest and history; an edge that followed aCompacthas the checkpoint entry as its anchor and rebuilds from it; through the daemon, a rebuild leaves the branch's state and certification unchanged.- The
proposedmarker (milestone 5).Item(protocol 8) carriesproposed: [(proposal id, local author)]: the pending proposals that write the record, from the shared team state, which the actor refreshes whenever a queue changes (enqueue, publish steps, import). The single redaction point keeps, for a principal other than the store owner, only its own proposals — stricter than §6.2 allows (a proposal whose every lane the reader may read could be shown), never looser; no count of the others is shown.ctx_readshows the ids asproposed. ctx team compact,prune,rejoin(milestone 6).TeamCompact(admins; the bound member must be an admin of the team document) answers step 1 when noCompactis pending: Σc from the replica at the tip and a fresh proposal id,ckpt(Σc, n+1)written to the repository, and the unsignedCompactentry ong<n>. With aCompactpending it answers step 2: the replica is Σc, the checkpoint is rebuilt and checked against the committed tree (a mismatch is refused as a bug), and the unsigned successorFong<n+1>.ctx team compactsigns and pushes step 1, syncs, then step 2;--resumedoes step 2 only; a non-fast-forward successor push means another admin's successor stands;--force-refreplaces a squattedg<n+1>.ctx team statusshows the generation, a digest prefix andCompactPending.ctx team prune --yesdeletes the remote's generations older than the one this edge follows, with hooks off.ctx team rejoin --genesis <oid>is leave then join with the same repository, key and remote. Tested with real processes: a crash after step 1 (CompactPending),--resume, the follower at the same generation and digest, publishing in generation 1, and prune.- Catch-up before a merge (milestone 6, Q1). With a team joined, a
Mergerequest first runs an import, which catches every open branch up, so a carried rule naming a mirror the root already accepted is notMirrorLagonly because this edge lagged. Tested: a root entry fetched but not imported is on both branches after the merge. - T113 with real hooks (milestone 6).
Options::team_lag_check(default 2 s;Nonedisables it) lets the fence test run withoutlag_check. With real hooks and every read issued at once: a fetch with hooks disabled reads CERTIFIED on the old state until a sync (declared, §2.3); a durable, acknowledged announce whosecommittednotify is lost makes reads lag at once until an import resolves it; withctxddown during the fetch the hook leaves the durable announce, and after the restart no read is a stale CERTIFIED; actxdthat accepts the announce but never acknowledges makes the fetch fail and the ref does not move (crates/contextdb-cli/tests/p10_fence.rs). PROP18 passes at 10,000 seeds on the remote Linux host (release build, 5b5243e): 18,487 proposals published in 8,225 entries, 607 conflicted, 8,014 refused at enqueue, 3,097 seeds with a moved tip. - T114, the publish rows of §7.4 (milestone 6). Through the daemon, with restarts between steps: prepared but never begun leaves the proposals queued and the next publish rebuilds; begun then a crash before the push leaves
published, and the next fetch finds the entry absent and queues it again; pushed with the outcome unknown, the next fetch finds it and takesAcceptedfrom the replica; a confirm listing survives a restart,--yes <token>publishes exactly the listed set (not a proposal queued after it), an unknown token is refused. The test found that a restartedctxdrefused team writes asReservedNamespaceuntil its first import: joined teams are now registered at spawn, without a live position, so routing works at once and reads lag until the import. - T115 and Q4 (milestone 6). On
mainand a fork, localPinandCurdependents of a mirror: a rootRetractBaseon the head makes every dependent STALE, and restoring the base recovers them; a root supersede makes both STALE, thePinone asStale(Unsupported)rather thanSupersededPinnedPremise— the mirror's old head loses its base as the head moves (§5.1), and SEMANTICS checks "no L0" before inspecting the witness; the head moving back recovers both. Every branch changes in the same import. - Shred and catch-up (milestone 6, §11, Q6). Before catch-up writes any branch, each import runs the local shred step: for every content in the replica's shred set not yet shredded here, a store-owner
ShredContentonmainas its own batch — skipped, with a warning, when a local record that is not a mirror holds the bytes (m5). The P9 purge follows afterctx team syncand everylag_check. Catch-up batches never carry bytes already shredded here; the kernel's replica exemption creates such a mirror revision unavailable. T117's test found the store refusing those bytes (ContentShredded) and stalling the branch, before this fix. Tested: a record created and team-shredded in one import (the shred step first, no stall); team-shredded bytes a local record holds are kept; after a local shred of a mirror's bytes, a root entry reusing them is mirrored without a stall. - A publish racing an import (milestone 6). A flaky run of the CLI test showed an accepted proposal left
queued: an import between step 7 and the push (alag_check) found the entry absent and requeued it, and once the entry landedreconcilelooked only atpublishedproposals. Now the publish lock (flockonpublish.lock) is held by every publish, by hand or frompre-push, from step 4 until its outcome is known;ctxdrequeues an absentpublishedproposal only while no publish holds it; and a pending proposal the chain decided takes its outcome whatever its local state. A deterministic test covers both: an import with the lock held leaves the proposalpublished, and without the lock it is requeued but still endsAcceptedwhen its entry lands. Q11 (a git alias forpush -npublishes nothing; an oversized proposal isProposalTooLarge) is tested too. ctx team access,shred,hooks(milestone 6).access --file team.toml(§9.1) andshred --content <hex>(§11) queue aSetTeamAccessorTeamShredproposal throughTeamPropose(store owner, admin socket; the proposal in portableCXTBform, through the same queue and both layers); they publish on the next push orctx team publish, and the root decides admin rights.hooks off|onremoves or restores the team component of the dispatcher, and the announce fence with it (§2.3). Tested: a key not in the document cannot join (NotTeamMember); the admin adds a member, who joins with their own key, proposes and publishes signed as themselves, and the admin's edge imports it.- G6, the bare-remote trial (owner decision 2026-11-17: this trial only; the ≥5-day real-remote part is skipped, as for P9).
crates/contextdb-cli/tests/p10_g6_trial.rsat 78b1911 on this machine (macOS): two clones of one bare remote, alice (admin) and bob (writer) with their own SSH keys, twoctxdwith the defaultlag_check, real hooks, scripted agents on both edges for 60 rounds. Report (docs/gates/p10-g6/report.json): 167 proposals in 116 entries, 12 refused at enqueue (counted by the driver without their error codes), 120 code pushes with 0 blocked, 60 digest checks with 0 mismatches, 126 probe checks after root head moves with 0 misses (every changed record invalidated its probe on both edges within that round's fetch), 5,942 lag checks with 0 persisting, the longest fetch-to-import 337 ms; final queue states 167 Accepted and 1 Conflicted, 0 lost. The agents are scripted, not LLM-driven. Rerun at 023ed9d, after the review fixes (hook pid, announce resolution): the same counts, 0 lost, 0 blocked, 0 mismatches, 0 misses, 0 persisting lag; the longest fetch-to-import 736 ms;report.jsonis this run's. - G4 fuzz smoke (milestone 6). Six new targets —
team_batch(CXTB canonical),team_doc(binary and TOML round trip),team_commit(both object formats),team_sshsig(garbage never verifies),team_checkpointandteam_accept(hostile entries after a real genesis) — ran 601 s each on the remote Linux host at 4f5b4e6 with no crash: 66,452,225, 6,190,200, 77,350,840, 6,922,808, 44,818,741 and 7,168,271 runs. The 24 h run follows. - G4, the 24 h fuzz run (owner decision 2026-11-18 on
team_doc). Seven targets ran in parallel on the remote Linux host from 2026-11-17 14:24 with-max_total_time=86400 -rss_limit_mb=4096(cargo fuzz run -O, ASan), built from the tree of 2026-11-17 14:21 (after 10ac668, before the G8 review fixes). Between that tree and 023ed9d no fuzzed code changed:doc,ops,commit,gitobj,sshsig,checkpoint, the replica'sacceptandcontextdb-protoare identical, andreplica.rsonly gainedsigned_by_author, which no target calls. Results, all with 0 crashes, panics or assertion failures:
| Target | Runs | Time | Final RSS |
|---|---|---|---|
ipc_request |
3,795,880,624 | 86,401 s | 796 MB |
team_accept |
915,941,131 | 86,401 s | 472 MB |
team_batch |
8,015,167,628 | 86,401 s | 539 MB |
team_checkpoint |
4,348,361,486 | 86,401 s | 537 MB |
team_commit |
8,290,181,732 | 86,401 s | 698 MB |
team_sshsig |
933,810,067 | 86,401 s | 721 MB |
team_doc |
≈ 264,380,000 | ≈ 17.4 h | stopped at 4,095 MB |
Deviation: team_doc ran ≈ 17.4 h, not 24 h. libFuzzer stopped it with out-of-memory (used: 4099Mb; limit: 4096Mb), while the live heap at that moment was 47 MB in 48,917 chunks. RSS had grown steadily from 571 MB (1.5 M runs) to 4,095 MB (264 M runs). The saved input alone runs in 2 ms with a 36 MB peak, and one pass over the whole corpus (86,243 inputs) peaks at 684 MB, both without error. A 45-minute comparison from the same corpus (2026-11-18) separates the cause: the ASan build grew from 372 MB to 987 MB in 9,682,081 runs, while a build with -s none stayed at 58–60 MB from 0.75 M to 43,622,264 runs. The growth is ASan's allocator retaining freed memory, not a leak in the target, which keeps no state between runs. The owner accepted the 17.4 h run with this evidence instead of a 24 h rerun.
- G4, kill points and hostile refs. Kill points: T114's catch-up killed after any batch (prop19.rs), every publish crash row (t114_every_publish_crash_row_recovers), import restart and a torn decision log, a checkpoint join and an interrupted ctx team rebuild (import.rs), leave after a crash, and compaction killed after step 1 (CompactPending, --resume; p10_team_cli.rs). Hostile and rewritten refs: tracking-ref cases (a stale ancestor, a deleted ref, a rewritten remote with unrelated history, a wrong genesis; tracking_ref_cases), replace refs and grafts (replace_refs_and_grafts_never_change_what_is_imported), a squatted g1 (p10_ctx_team_compact_resume_follow_and_prune), and hostile entries after a real genesis (the team_accept target). All ran in G1's workspace run at 023ed9d.
- G5 (milestone 6), on the remote Linux host, release builds. First measurement (625cbb1): import of 10,000 entries 217.92 s (budget 60 s) and a one-entry catch-up on 10 branches 503.69 ms (budget 50 ms), both over. Profiling found work proportional to the whole state per entry; fixed in 29337bd (exact running checkpoint totals with an upper-bound fast path; the history re-projects only touched records; one decision-log sync per import; catch-up limited to changed records), 3d6b969 and 6948ff2 (the import walks only the new tail; hooks connect without a ps liveness check; fetch-missing only in partial clones). Results after the fixes:
| Budget | Result (commit) |
|---|---|
| import 10,000 entries ≤ 60 s | 7.51 s, 7.70 s, 7.71 s, 8.08 s (29337bd–6948ff2); 7.70 s with every object hashed (023ed9d); 7.92 s (bfe1668) |
| join 10,000 entries on 10 branches ≤ 120 s | 0.75 s, 10 batches; resident 37,960 → 105,828 KiB (3d6b969); 0.81 s, 38,072 → 105,708 KiB (023ed9d); 0.89 s, 38,088 → 105,624 KiB (bfe1668) |
| catch up one entry on 10 branches ≤ 50 ms | 10.17 ms, 10 batches (6948ff2); the one-entry import itself 41.29 ms. 8.90 ms and 39.83 ms (023ed9d); 9.14 ms and 34.67 ms (bfe1668) |
publish ten proposals ≤ 2 s added to git push |
+277.5 ms p50 (6948ff2); +275.3 ms (023ed9d); +281.5 ms (bfe1668); +360.0 ms (7a6e2da: publish runs one more prepare round after the last entry) |
| team-ref fetch: announce and acknowledgement ≤ 50 ms | +40.8 ms p50 (6948ff2); +31.6 ms (023ed9d); +36.0 ms (bfe1668); +30.8 ms (7a6e2da) |
reference-transaction ≤ 20 ms added to git commit |
not met: +50.18 ms p50 (6948ff2). On the same host a trivial reference-transaction hook that only reads its input adds 40 ms per commit (22 → 62 ms; git runs the hook three times per transaction, ~13 ms per process start here), so no hook of this kind meets 20 ms there; ContextDB's adds about 10 ms over that floor. The script starts ctx only for a team tracking ref (a35c056). Owner decision (2026-11-17): the budget is re-baselined to ≤ 20 ms over a trivial hook that only reads its input, measured in the same run (p10_g5_hooks.rs now times that series too); at 023ed9d, 60 commits each: team hooks 63.74 ms p50, a trivial hook 63.41 ms, no hook 16.68 ms, so +0.33 ms over the trivial hook (budget 20 ms): met; +47.06 ms over no hook. Over the trivial hook: +5.61 ms (bfe1668), +4.31 ms (7a6e2da); met. |
| compact and join 100 MiB | checkpoint 0.06 s, checkpoint join 0.48 s, 104,864,328 checkpoint bytes; peak resident 720,888 KiB (reported). 0.07 s, 0.49 s, peak 719,784 KiB (023ed9d); 0.07 s, 0.49 s, peak 719,804 KiB (bfe1668) |
| recall p99 with 10⁴ mirrors within +10 % | three runs at 2·10⁴ records: −8.8 %, +6.2 %, +9.2 % (baseline p99 10.75, 10.11, 10.89 ms) (6c05509) |
| - G3 at 023ed9d (remote Linux host, release). PROP17, PROP18, PROP19 and PROP13 at 10,000 seeds each: all pass. PROP17 outcomes cover every rejection code of the generator; PROP18 published 18,487 proposals in 8,225 entries, with 607 conflicted and 8,014 refused at enqueue; PROP19 ran 245,225 catch-up batches, 14,100 of them split, and saw 152,727 root changes. The T114 catch-up kill points ran at 10,000 seeds: 42,032 kill points, 9,596 seeds with more than one batch, every branch equal to the uninterrupted run. The G-LAG property ran at 300 seeds: 854 states with an unmirrored actual tip, none read CERTIFIED. | |
- Reruns after the owner's review (2026-11-18). G1 at bfe1668 and again at 7a6e2da: scripts/check.sh exit 0 with 181 test result: ok lines, on the remote Linux host. G3 at bfe1668 (release): PROP17, PROP18, PROP19 and PROP13 at 10,000 seeds, all pass; PROP19 ran 255,006 catch-up batches; 20,791 catch-ups took more than one batch, 13,751 of them on seeds limited to 1–3 new revisions per batch; 152,727 root changes seen; the T114 kill points 42,032 (9,596 seeds with more than one batch); the new kill test of limited catch-ups 43,941 kill points, 40,532 of them before any watermark; G-LAG at 300 seeds with 850 unmirrored states checked, none CERTIFIED. G5: the results are in the table above. G6 rerun at 7a6e2da on this machine (60 rounds): the same counts as before (167 proposals in 116 entries, 12 refused at enqueue, 0 lost, 0 blocked pushes, 0 digest mismatches, 0 probe misses, 0 persisting lag), the longest fetch-to-import 760 ms; report.json is this run's. G4 (fuzz) and G7 were not rerun: no fuzzed code changed, and outside P10 code the only change is Kernel::replica_record, a new accessor. |
|
- G7 (remote Linux host, rustc 1.95.0, release unless noted). The earlier phases' suites ran on P10 code, with P9's seed variables (CONTEXTDB_P9_ACCESS_SEEDS, _WRITE_SEEDS, _MERGE_SEEDS, _SHRED_SEEDS, _READ_SEEDS) set to 10,000 for the whole run. All three parts exited 0. |
|
- g7-p8.sh: |
|
- gate-regression.sh: the P0–P3 properties at 10,000 seeds (paranoid); the bounded exhaustive run, depth 6 (770 states, 11,275 transitions, 0 violations) and depth 8 for the report (1,711 states, 30,350 transitions, 0 violations); store and daemon crash injection at 1,000 runs per point and PROP10 at 10,000 seeds; the P4, P5a and P5b suites with PROP12 at 10,000 fixed seeds. |
|
- g3-p6.sh: PROP13 at 10,000 seeds and PROP11 per branch. |
|
| - The P7 properties at 10,000 seeds, and the P7 kill points (25 runs per job step, debug). | |
| - 1,800 s of P7 stress: 102,916 moves, 0 store errors, 0 violations. | |
| - The P8 G4 kill points (debug). | |
- g3-p8.sh: PROP14 at 10,000 seeds (120,000 queries). |
|
- The P9 suites in release: PROP15's read half at 10,000 seeds (39,812 hidden and 36,613 shown pairs). PROP15's write and merge halves and PROP16 ran inside gate-regression.sh with their seed variables at 10,000. They passed, but those tests print no counts. |
|
| - Independent implementation review (G8, 2026-11-17). A non-implementing reviewer read the P10 code against ADR 0018 r0.6 and SPEC SD21. It reported six major and seven minor findings. All thirteen are fixed; each fix, except finding 7's, has a regression test: |
| # | Finding | Disposition |
|---|---|---|
| 1 | The dry-run parser missed --signed (it consumed the next argument) and the --dr abbreviation |
Fixed in githooks.rs: git's option grammar, so --dr is a dry run and --d is ambiguous. Unit cases added. |
| 2 | An announce was dropped because the tip it was compared with was stale | Fixed: a dead process's announce is dropped only after a fresh read of the ref shows its object. Test: an_announce_is_dropped_only_by_a_ref_read_after_its_process_ended. |
| 3 | At startup, reads were served before the announce file was read | Fixed: all listeners are bound, then the announce files are read, then the accept threads start. |
| 4 | A publish push moved the tracking ref without an announce | Fixed: ctx team publish and the compaction pushes announce their own ref update first. |
| 5 | prepare conflicted the dependents of a skipped proposal, and an oversized proposal could never publish |
Fixed: dependents of a deferred proposal are deferred too, and enqueue refuses a proposal one entry cannot hold (ProposalTooLarge). Test: a_dependent_of_a_deferred_proposal_waits_too_and_oversized_is_refused. |
| 6 | client_txn_id was ignored for team proposals: a retry queued a duplicate, and an id could be used both by a proposal and by a local commit |
Fixed: the enqueue frame (tag 3) records the id and the request hash. A retry answers the same Proposed. Another request under the id gets TxnIdReuse, and so does a proposal under an id the kernel has committed. The actor refuses a local write whose id a proposal holds. Test: a_client_txn_id_is_idempotent_across_proposals_and_local_commits, which includes a restart. |
| 7 | When a proposal also failed against the visible overlay, the refusal gave the full overlay's reason, which could describe a hidden proposal | Fixed: the visible attempt's reason is given. Dependencies on hidden proposals stay, since the proposal was checked on top of them; a dependent's reason is only dependency. No dedicated test. |
| 8 | During CompactPending, publish did not wait, and the tip of the terminal generation caused lag |
Fixed: prepare refuses with CompactPending, and the lag tip is the successor ref's while a Compact is pending. |
| 9 | Decisions were recorded from an EntryRejected whose signature was never checked, so anyone could push an entry naming another member's proposals |
Fixed: a rejected entry decides proposals only when its Ctx-Author signed it under the document in force (Replica::signed_by_author). Test: a_rejected_entry_decides_proposals_only_when_its_author_signed_it. |
| 10 | The team shred step checked only local records | Fixed: artifact payloads, ValidationRecord metadata and resolution notes are also checked. Notes are found by an op-log scan, which runs only when there is something to shred. Kept contents are remembered per process. Test: a_team_shred_keeps_bytes_a_local_artifact_or_note_holds (artifact and note). |
| 11 | Git reads followed replace refs and grafts, and did not check that object bytes hash to the requested id | Fixed: every git call sets GIT_NO_REPLACE_OBJECTS=1 and points GIT_GRAFT_FILE at a path that does not exist. read_objects hashes each object and refuses a mismatch. Test: replace_refs_and_grafts_never_change_what_is_imported; without the environment change, the import diverges. |
| 12 | Crash windows: create_from_checkpoint wrote the anchor before the Join frame, and an interrupted rebuild left log.rebuild behind |
Fixed: the Join frame is durable before the anchor, so a crash in between leaves no joined team. open puts an interrupted rebuild's log.rebuild back. Tests in import.rs. |
| 13 | The gate notes claimed a fetch-in-flight counter that was never incremented | Fixed: the counter was removed and the note corrected. A fetch in flight is a pending announce. |
Finding 11 hashes every object at import. The G5 import figure above predates it and will be measured again.
Verification of the fixes (second independent review, 2026-11-17). A second non-implementing reviewer checked 9188343 against the thirteen findings. It found 10 closed, 2 and 3 partial, and these new defects, all fixed or declared:
| # | Finding | Disposition |
|---|---|---|
| N1 (blocker) | Finding 2's rule left the announce of a compaction's Compact on g0 pending forever, because a successor has no parent, so every read over the team lagged permanently after a compaction |
Fixed: an announce on a ref import does not follow resolves at once — another remote's ref, a generation other than the followed one, any ref while a Compact is pending. While a Compact is pending, the lag tip is the last decided entry, so a squatted successor ref does not lag reads. Tests: the real-hook compaction test in p10_team_cli.rs (no announce left pending after following g1; fails without the fix), and an_announce_is_dropped_only_by_a_ref_read_after_its_process_ended. |
| N2 (major) | The announce recorded the hook shell's pid, not git's: the script piped into exec ctx, and the last element of a pipeline runs in a forked subshell, which exits before git moves the ref, so finding 2 stayed open in real use |
Fixed: the script passes the input as a here-document, so ctx replaces the hook shell and its parent is git. Test: the_team_hook_replaces_the_hook_shell (fails with the pipeline). |
| N3 (major, narrow) | The lease was written after the announce files were read, so a hook running in between found no daemon and wrote its announce to a file already read | Fixed: the lease and the discovery record are written before the announce files are read. |
| M1 | A member's own entry rejected for its signature (a key missing from the document) left its proposals Published forever |
Fixed: rejected entries are recorded by commit id, and reconcile rejects the proposals of the entry this edge pushed. Test in import.rs. |
| M2 | Rebuild crash windows: no directory fsync after removing log.rebuild; a rebuild that followed a successor moved the anchor, so a restore could pair the old log with the new anchor |
Fixed: the anchor is set aside with the log and restored with it (anchor first), with directory fsyncs. Test in import.rs. |
| M3 | Metadata of a ValidationRecord replaced for the same (rule, vector) was not protected from a team shred | Fixed: the op-log scan also covers RecordValidation.meta. Declared: with kept content, the first import after each start scans the op log once on the actor thread. |
| M4 | Announces were recorded for any remote's team refs | Fixed in the hook (only the team's own remote) and in resolution (N1). |
| M5 | The dry-run parser misread abbreviated value options (--pu -n) and abbreviated negations (--no-dr) |
Fixed: git's rule — an exact name or a unique prefix of a git push long option or its no- form; an ambiguous one cannot tell. Unit cases added. |
| M6 | Nits: older binaries truncate the queue at a tag-3 frame; the team idempotency hash omits expect_cert_valid; leaving a team frees its proposals' ids |
Declared. Downgrading across format 6 is unsupported. The flag has no effect once a write is proposed. Leaving deletes the queue. |
| T1 | The checkpoint-join crash test does not distinguish the old order from the new | Declared: the order is checked by reading the code; the test covers a rerun after the crash. |
The owner's review (2026-11-18), after G4. Four findings, all fixed in bfe1668 (O1's publish loop in the commit after it); each test fails on the code before it.
| # | Finding | Disposition |
|---|---|---|
| O1 (P1) | Publish packed a SetTeamAccess proposal with others into one entry; accept refuses such an entry whole (SoleOpRequired), so every proposal in it was rejected |
Fixed: a proposal with a sole op takes an entry of its own, and nothing after it in queue order joins that entry or overtakes it. Test: a_team_access_proposal_takes_an_entry_of_its_own (publish.rs; before the fix the first entry held all three proposals). The note above said the hook repeats prepare → push while proposals remain, but publish stopped after one entry, so such a proposal would have waited for the next push; it now publishes entry after entry until nothing is left (three tries per entry against a moving ref). Test: one ctx team publish sends an agent write and a team document as two entries in p10_a_team_on_orphan_branches (one entry with the old loop). |
| O2 (P1) | A rejoin whose chain gave an existing mirror key another kind or lane was accepted: the mirror kept the old kind and lane while the watermark moved on, so local state and authorisation no longer matched the root (ADR §8.7 and SPEC require TeamKeyMismatch) |
Fixed: TeamOpen refuses such a team with TeamKeyMismatch and does not open it, ctx team join then removes the team directory it created, and catch-up refuses before any batch when a projection changes a mirror key's kind or lane (Kernel::replica_record). Tests: a_rejoin_that_changes_a_mirror_keys_kind_is_refused (daemon; before the fix the rejoin answered UpToDate) and catch_up_refuses_a_mirror_key_with_another_kind_or_lane (prop19.rs). |
| O3 (P1) | Catch-up numbered new revisions in a u16: 65,536 new records in one step overflowed (a panic in debug builds, wrong RevRef::New slots in release) |
Fixed: slots are counted without bound, and a step needing more than 65,536 new revisions (MAX_NEW_REVISIONS) first commits its records and revisions in batches of that size, with no base bit set and no watermark; its last batch moves heads, bases and the watermark. Each batch is diffed from the branch's actual state, so a crash between them resumes. Tests: a_catch_up_past_65536_new_revisions_is_split (65,537 records; before the fix "attempt to add with overflow" at catchup.rs:330), PROP19 with half its seeds limited to 1–3 new revisions per batch, and a_catch_up_in_revision_batches_killed_after_any_batch_recovers (between batches the branch holds its position's projection plus revisions that are not base). |
| O4 (P2) | The orphan-branch fallback (O4, SPEC SD21.2) was specified but missing: every ref was a custom ref | Fixed: ctx team create|join --orphan-branch keep the chain on refs/heads/contextdb-team/<id>/g<n> (the team config's refs branch), fetched into the same tracking refs, so import and the announce fence are unchanged. A join checks the remote with git ls-remote and refuses the wrong layout, naming the flag; publish and compaction push to the team's layout; prune, the pre-push deletion guard and the own-push announce follow it. Test: p10_a_team_on_orphan_branches (real processes: create, publish, a refused and an accepted join, a later sync, the deletion guard). |