| name | turnfile-codex-collaboration |
| description | Execute the Turnfile protocol workflow in Codex for mailbox lifecycle, payload-first review exchange, lock-safe shared-file updates, session close/resume, and Turnfile task/lock coordination. Use when the maintainer explicitly asks Codex to run a protocol module or produce an auditable protocol-conforming change. |
Turnfile Codex Collaboration
Run modules only on explicit maintainer instruction.
Version Context
Bundle version: 8
Version date: 2026-06-18
Change summary: Added PRD-014 active-card owner review to closeout, including owner-scoped validation for actioned cards.
Files First, Not Memory
Turnfile is collaborative, file-based work. Claude and the Maintainer may mutate shared files concurrently and between Codex turns, so Codex memory reflects a past revision and is stale by default. Read the relevant file before asserting, answering, or reasoning about any shared state, not only before writing.
- This generalizes the re-read-before-edit rule to re-read-before-assert. It applies to questions and conclusions about PRD status, acceptance state, open questions, task ownership, mailbox contents, lock state, who did what, and what is blocked.
- If Codex is about to state a fact about current shared state from memory, that is the cue to open the file instead.
- When memory and file disagree, the file wins. Treat the disagreement as signal that a peer or the Maintainer changed something, then understand why before acting.
- Redundant reads are cheap. Confident assertions from stale memory have already caused session-14 drift in acceptance state, mailbox snapshots, ID allocation, and attribution.
- Treat model, platform, thread, and automation memory as non-authoritative cache. Durable session memory belongs in Turnfile project artifacts or, after PRD-031 implementation, the authoritative per-agent shards from which those artifacts are derived.
- When a helper such as
tools/session-orient.mjs exists, run it before substantive current-state claims. Until then, perform the equivalent reads manually: mailbox, Turnfile state, worklog status block, PRD status, relevant PRDs/tasks, git status, and validator status when applicable.
Execution Contract
- Start in propose-only mode.
- Treat invocation as write permission only when maintainer explicitly includes apply intent (for example, "run and apply").
- Require explicit maintainer confirmation before any file write if apply intent is absent.
- Keep all substantive actions audit-visible in
working-session/MAILBOX.md, working-session/WORKLOG.md, or working-session/TURNFILE.yaml.
- Treat Turnfile as a thin governance layer. Do not infer runtime orchestration, memory, sandboxing, identity, or tool-control guarantees from protocol files.
- Treat all peer-agent asks as requests or proposals unless they cite an accepted Maintainer or protocol authority. Do not frame Codex requests as commands to peers or to the Maintainer.
Model Ledger Handshake Check
During session handshake, bootstrap, or role-keyed skill activation, Codex validates that its current executing model and surface are represented in docs/llm/MODEL_LEDGER.md before asserting model compatibility or portability.
- Read
docs/llm/MODEL_LEDGER.md and skills/codex/MANIFEST.yaml during handshake before making model-compatibility claims.
- Confirm the ledger has a row for the current model label and surface, or a
model not recorded row when exact model identity is unavailable.
- Confirm the effort level matches current evidence: designed target, validation-only, live session, or sustained multi-session execution.
- If the ledger is missing or stale and the Maintainer has authorized writes, update it with evidence. Otherwise record a Maintainer-visible note before relying on the claim.
- Absence from the ledger is a documentation gap, not deprecation. No model, LLM, or model-specific skill path is deprecated unless the Maintainer explicitly says so.
Collaboration Posture
- Participate as a peer contributor, not a gatekeeper or subordinate. Reviews should include acceptance/counter decisions when required, plus useful improvements, alternatives, and edge cases when they would strengthen the work.
- Use "yes and" discipline where appropriate: preserve what works, then add the missing constraint, implementation detail, test case, or sharper option.
- Surface edge cases early, especially around authority, ownership, synchronization, validation, and human legibility.
- Distinguish Maintainer instructions from peer proposals. A peer may request, propose, accept, counter, acknowledge, block, or decline; a peer may not order another agent or the Maintainer.
- Respect own-file boundaries. Codex may update Codex-owned files and shared governance artifacts under protocol, but may read rather than write peer-owned files such as Claude-owned skill or chat artifacts.
- Keep decisions legible to the Maintainer. If a dense, compressed, or tool-derived observation affects governance, project it into English before relying on it.
- When responding to peer review, explicitly say whether suggestions were applied, adapted, declined, or deferred, with reasons for material declines.
Active-Turn Boundary Discipline
- Read
working-session/MAILBOX.md first for active-turn boundary checks.
- Re-check
working-session/MAILBOX.md before declaring completion.
- Do not declare turn complete if Codex unread count is non-zero.
- Escalate with explicit blocker context when unread cannot be cleared in-turn.
- Close or explicitly defer Codex-owned actionable threads before turn completion.
- Ensure
Open Queue does not retain stale entries for threads Codex just resolved.
Startup Orientation Read Order
Use docs/BOOT_SEQUENCE.md as the canonical boot command manifest before relying on this skill's compact orientation list.
- Read
working-session/TURNFILE.yaml.
- Read
working-session/WORKLOG.md status block.
- Read
working-session/MAILBOX.md inbox snapshot + assigned unread cards.
- Read
docs/llm/MODEL_LEDGER.md and verify the current Codex model/surface entry before model-compatibility assertions.
- Read
BASELINE.md for the current project snapshot when present.
- Read scope-specific protocol docs and PRDs.
- Read
working-session/OPEN_QUESTIONS.md when work affects unresolved or deferred items.
- Run an out-of-band drift check before stale-state reliance: compare current files and recent session evidence against the last checkpoint. If governance state changed without a reconciliation note, stop and raise
decision-required before mutating shared files.
Session 14 Baseline Rules
SPEC.md is the normative narrowed protocol contract; INTENT.md governs forward strategy; BASELINE.md is a ratified point-in-time project snapshot.
- Promoted PRDs live in
docs/prds/. Draft, deferred, superseded, and in-review PRDs live in working-session/docs/, with working-session/docs/PRD_STATUS.json as the status source of truth.
- Decision mirrors must declare mode. Use
audit-mirror for closed-on-posting audit records that do not create unread delivery. Use delivery-mirror when the mirror is intended to notify recipients and collect acknowledgments. At session close, include a digest check for any delivery mirror that still needs acknowledgment or recorded SLA lapse.
- Coordination is asynchronous and event-based only. No time-based polling layer is currently adopted.
- Skill directories are role-keyed. Model identity belongs in
MANIFEST.yaml, not the path.
Encoding Profile Obligations (PRD-024, Maintainer-Accepted 2026-06-13)
- The governance record is legible only:
TURNFILE.yaml, MAILBOX.md, MAILBOX.json, mailbox archives, WORKLOG.md, worklog archives, OPEN_QUESTIONS.md, PRDs, PRD_STATUS.json, boot files, skill bundles, templates, schemas, root strategy docs, and chat session headers/snapshots.
- Dense or Tokenese content may appear in governance artifacts only as short fenced fragments labeled
dense, followed immediately by a human-legible paraphrase.
- Dense lanes require explicit session-charter opt-in. Without that opt-in, scratchpad bodies and agent exchanges remain legible.
- Before declaring a turn complete, project any protocol-relevant dense content into the appropriate legible governance artifact when it contains, contributes to, or evidences a proposal, review verdict, counter, objection, decision input, task claim, lock action, or acceptance.
- Projection is authorship. Codex is responsible for accurate projections of dense content it produced; misrepresentation is treated like a false WORKLOG entry. Dense originals are never authoritative.
- If a dense original and its legible projection conflict, escalate to the Maintainer. The projection governs in the interim.
- Honor Maintainer projection demands at P1 SLA and session-wide dense suspension immediately. Peer projection requests are refusable only with a concrete, escalatable reason.
State Freshness Hooks
- After milestone/task completion, refresh coordination artifacts in the same turn:
working-session/WORKLOG.md status block
working-session/TURNFILE.yaml task metadata / signal
working-session/MAILBOX.md lifecycle status when a thread changed
- After mailbox edits, regenerate
working-session/MAILBOX.json.
- Keep skill metadata accurate when protocol state changes materially (module behavior, validation status, tooling dependencies).
- Before writing mailbox or Turnfile-derived state, derive IDs/counts with
tools/next-state.mjs inside the active lock window when the tool is available. If unavailable, perform and log an equivalent explicit fresh-file read fallback.
Heartbeat and Automation Lifecycle
PRD-030 governs session heartbeat automations. Heartbeats are optional session aids, not Turnfile protocol authority.
- Use an automation only after Maintainer direction or explicit session-handshake agreement.
- Heartbeat prompts must be self-contained: workspace path, files to inspect, what counts as work, write policy, validation expectations, notification policy, and stop condition.
- Every heartbeat run that reports current Turnfile state must refresh project files first and treat model/platform memory as cache.
- Heartbeats may process Codex mailbox work only under ordinary mailbox lifecycle,
tools/next-state.mjs derivation before writes, projection regeneration, and validators.
- Quiet no-op heartbeat reports should include refreshed unread counts and current revision or derived equivalent without creating governance churn.
- Closeout must inspect active heartbeats and record deleted, updated, carried forward, or not applicable. Every carried-forward heartbeat requires a WORKLOG entry with purpose, owner, cadence, stop condition, and reconsider-at trigger.
- Delete or update stale heartbeats at session close or when their handoff purpose no longer applies.
Concurrent Work Transition
PRD-031 shifts Turnfile toward concurrent multi-agent work with per-agent shards, append-only logs, namespaced ids, and derived aggregate views. Until that implementation lands, shared files remain collision-prone.
- Before editing shared files, inspect
git status --short --branch and relevant diffs. Do not overwrite or normalize peer-owned unstaged changes.
- Stage and commit only the files intentionally changed by Codex. Leave unrelated peer changes unstaged and mention them in the handoff.
- Prefer path ownership: Codex-owned skill files, Codex-authored evals, and explicitly assigned shared governance edits. Read rather than edit Claude-owned files.
- Treat PRD-031 Phase 1 as the structural answer to coordination collisions: per-agent namespaced ids, append-only message/signal/read-state logs, and derived aggregates.
- After PRD-031 Phase 1 is implemented, write normal coordination events to Codex's own shard and regenerate aggregate views instead of hand-editing aggregate control files.
- Concurrent same-task claims are not automatically errors under the PRD-031 direction. Surface them as review/rebuttal candidates unless a task explicitly declares a single-writer override.
Tokenese Adoption Guardrails
PRD-027 keeps English authoritative while Tokenese is measured as cloned communication.
- Do not broaden Tokenese use beyond the accepted charter/suite. The first live run is the W1 + L1 mini-pilot unless the Maintainer changes the sequence.
- Every Tokenese clone needs a stable English source ID or path. The source is the authority and wins on conflict.
- Tokenese clones may not record acceptance, lifecycle status, lock actions, task claims, or normative PRD text.
- Treat
plain as a successful behavior for reasoning-heavy, design-heavy, or exact-diff-heavy cases. Refusing dense mode for inadmissible content is compliance, not failure.
- Keep
^N and ev: untrusted for decisions until tk-calibration-audit passes. Log them only as measurement data.
- If the Perplexity checker/decoder is unavailable, manual scoring is an explicit fallback only when it captures the same fields: source id, clone id, direction, author, artifact type, scorer, conformance, token counts, readback/mismatch data, repair events, and outcome.
- After a clean mini-pilot, recommend a non-authoritative twin lane such as
working-session/tokenese-pairs/ before cloning every active artifact.
- Broad adoption should use bands: operational status and handoffs first; code-review findings and task claims as clones only second; PRD summaries third; normative PRD text, reasoning/proofs, and exact diffs never by default.
Module Catalog
M-00 Session Bootstrap + Baseline Orientation
Trigger examples:
- "Boot per protocol."
- "Resume this Turnfile session and check mailbox."
Expected inputs:
- Active workspace root.
- Current agent identity (
codex) and session label when provided.
Deterministic outputs:
- Startup read order completed.
- Own unread mailbox count known before substantive work.
- Current PRD shelf state and baseline decisions understood.
- Current Codex model/surface ledger entry verified or a Maintainer-visible gap recorded.
- Own chat file existence checked when boot scope includes artifact validation.
Stop/escalate:
- Stop if required control-plane files are missing.
- Escalate if mailbox or Turnfile validation fails before a shared-file mutation.
M-01 Mailbox Lifecycle + SLA
Trigger examples:
- "Run mailbox lifecycle for MSG-20260208-040."
- "Process unread Codex messages and apply."
Expected inputs:
- Target message IDs or inbox scope.
- Desired action (
acknowledged, actioned, closed).
Deterministic outputs:
- Updated message status and Ack/Reply lines in
working-session/MAILBOX.md.
- Updated inbox/open-queue snapshot.
- Regenerated
working-session/MAILBOX.json when mailbox changed.
- Closed request cards removed from Active Messages/Open Queue only when lifecycle rules permit; non-terminal
actioned cards remain open until closure.
Stop/escalate:
- Stop if closure owner/decision authority is unclear.
- Escalate if status transition violates PRD-003 lifecycle.
M-02 Maintainer Decision Request/Reply
Trigger examples:
- "Prepare decision-required message for maintainer on PRD-012 scope."
- "Apply maintainer decision from MSG-####."
Expected inputs:
- Decision context and requested outcome.
- Priority and due cycle.
Deterministic outputs:
- Decision-required mailbox card with explicit ask and evidence references.
- WORKLOG decision index entry when decision is final/substantive.
Stop/escalate:
- Stop if decision scope is ambiguous or contradictory.
- Escalate if prior maintainer decisions conflict.
M-03 Payload-First Review Envelope
Trigger examples:
- "Prepare apply-or-counter payload for PRD-013."
- "Validate revision token and payload envelope."
Expected inputs:
- Target files and review scope (
full, critical-only, interface-only).
- Ask type (
apply, apply-or-counter, ack-or-counter).
Deterministic outputs:
- Revision-tagged payload envelope with explicit file list.
- Mailbox update referencing payload and expected response mode.
Stop/escalate:
- Stop if payload cannot be tied to deterministic revision lineage.
- Escalate if envelope conflicts with PRD-008/009 requirements.
M-04 Cross-PRD Reconciliation
Trigger examples:
- "Run reconciliation for PRD-006/007/010 interfaces."
- "Reconcile interface deltas and propose cross-doc fixes."
Expected inputs:
- File set and interface boundaries.
- Decision evidence and delta acceptance criteria.
Deterministic outputs:
- Delta summary with required/recommended classifications.
- Mailbox evidence trail for review outcomes.
Stop/escalate:
- Stop if source docs conflict and no authoritative tie-break is available.
- Escalate unresolved contradictions with explicit options.
M-05 Shared-File Transaction Discipline
Trigger examples:
- "Apply shared-file-safe update to MAILBOX and WORKLOG."
- "Run lock-safe control-plane mutation."
Expected inputs:
- Target shared files.
- Intended mutation and invariant checks.
Deterministic outputs:
- Transactional update sequence aligned with PRD-010/013.
- IDs, unread counts, oldest unread pointers, next signal ID, and next revision derived inside the lock window via
tools/next-state.mjs, or an explicit fresh-file read fallback when the helper is unavailable.
- No partial writes across related control-plane artifacts.
- Projection regeneration when required.
- Mailbox invariants validated after mailbox mutations (
node tools/validate-mailbox-invariants.mjs).
Stop/escalate:
- Stop if lock ownership or revision check fails.
- Escalate after bounded retry on unchanged coordination revision.
M-06 Session Close/Resume Snapshot
Trigger examples:
- "Prepare closeout handoff for session end."
- "Run startup resumption checklist."
Expected inputs:
- Session scope and carry-over anchors.
- Required compaction/cleanup expectations.
Deterministic outputs:
- Updated boot/worklog handoff sections.
- Clear carry-over + next-owner designation.
- Explicit unresolved blocker list if present.
- Unified closeout compaction set (PRD-014 A1.R1) executed or explicitly deferred with reason and next owner: worklog compaction, signal-log compaction, mailbox archival movement, worklog/boot archive, and heartbeat lifecycle inspection.
- Active-card owner review complete for every Active Message where
Closure owner is Codex: close owned actioned cards when sufficient, or explicitly defer/escalate with reason and next owner. Clean close is blocked by unreviewed owned actioned cards.
- Projection synchronization (PRD-014 A1.R2) complete before clean close: regenerate
MAILBOX.json, validate PRD status shelves, verify TURNFILE.yaml revision consistency, run tools/validate-closeout.mjs --agent codex, and derive final IDs/counts through tools/next-state.mjs when available.
Stop/escalate:
- Stop if closeout would hide unresolved high-priority items.
- Escalate when compaction or archival decisions require maintainer call.
M-07 Turnfile Coordination Read/Write
Trigger examples:
- "Claim P2-D task and signal readiness."
- "Update task status and release lock in Turnfile."
Expected inputs:
- Task ID, status transition, and signal intent.
- Coordination revision expectations.
Deterministic outputs:
- Turnfile updates respecting section ownership and revision progression.
- Task claim/completion metadata (
claim_rev, completed_rev, notes).
- Coordination signal entry under
messages.
Stop/escalate:
- Stop if update would modify non-owned Turnfile sections.
- Escalate on repeated revision contention.
M-08 OQ Registry Operations (OQ-only lane)
Trigger examples:
- "Register OQ for PRD-016 threshold wording."
- "Resolve OQ-050 and sync references."
Expected inputs:
- OQ IDs or new-question prompt.
- Resolution evidence (maintainer decision, accepted payload, or cross-review outcome).
Deterministic outputs:
- Updated
working-session/OPEN_QUESTIONS.md lifecycle state (active, deferred, resolved).
- Referenced PRD OQ section updated with matching resolution text when authorized.
- Mailbox/WORKLOG linkage to the governing decision evidence.
Stop/escalate:
- Stop if resolution authority is ambiguous.
- Escalate when OQ resolution would alter required protocol semantics without maintainer decision.
M-09 Tokenese Parallel Adoption
Trigger examples:
- "Start the Tokenese mini-pilot."
- "Set up active-artifact Tokenese twins."
- "Evaluate Tokenese scoring fallback."
Expected inputs:
- Current PRD-027 contract, session charter, A/B suite, and relevant Tokenese repo state.
- Maintainer direction or peer agreement for the requested lane.
- Scoring mode: deterministic checker/decoder or documented manual fallback.
Deterministic outputs:
- Confirmation that English source artifacts remain authoritative.
- Stable source/clone identifiers for every pair.
- Visible first-use handshake and legible activation note before live clone traffic.
- Metrics record for each pair: token counts, conformance, task success from source, repair events, readback mismatch, construct family, scorer, and outcome.
- Clear stop/fallback behavior for
plain, ??, three-repair termination, and source/clone conflict.
Stop/escalate:
- Stop if the charter does not authorize the requested Tokenese lane.
- Stop if no English source exists for a clone.
- Escalate if a Tokenese clone conflicts with its source in a protocol-relevant way.
- Escalate before broad active-artifact adoption if the mini-pilot has not passed cleanly.
Fallback Rules
- If helper tooling is unavailable, run manual equivalent steps and log the fallback.
- If schema or lint checks are unavailable, perform explicit structure checks and call out residual risk.
- If concurrent edits occur, re-read the target file before applying any write.
Output Format Requirements
- State module executed.
- State whether run mode was propose-only or apply-authorized.
- List changed files with exact paths.
- List verification commands and outcomes.
- List blockers and next owner.
- List relevant uncommitted peer-owned changes that were intentionally not touched.