Project Context Governor
Maintain useful project context without revalidating everything on every chat. Separate loading from verification, sample routine claims, and force checks only when risk or conflicting evidence requires them.
Principles
- Prefer current code, Git state, tests, and runtime evidence over summaries or memories.
- Use memory for navigation, never as proof.
- Keep facts, interpretations, decisions, plans, and negative results distinct.
- Supersede wrong records; never silently rewrite history or hide conflict.
- Load context cheaply. Activation alone does not require verification.
- Spend verification budget by risk, staleness, change impact, and reproducible sampling.
- Respect scope. Status and review requests remain read-only unless state-file changes are authorized.
Select a workflow
- Bootstrap: Organize or onboard a repository. Reuse existing state systems before proposing new files.
- Orient: Resume substantial work. Load the smallest relevant context; normally do not verify it.
- Reconcile: After authorized meaningful changes, update only affected claims when context-file writes are in scope.
- Audit: Perform periodic, sampled, conflict-triggered, or requested validation.
- Repair context: Supersede a wrong claim and identify downstream claims needing review.
Bootstrap
- Read applicable
AGENTS.md plus existing architecture, status, plan, decision, and task artifacts.
- Prefer configured code-graph tools for discovery. Index only when no usable index exists or audit policy selects refresh.
- Reuse existing sources of truth. Do not create parallel documents.
- If setup is authorized and no equivalent store exists, use
.codex/project-context/ from references/state-schema.md.
- Record the baseline revision and freshness. Do not claim a full audit unless one ran.
Orient cheaply
- Load applicable instructions and compact current state.
- State the last verified revision/date and known stale or disputed items.
- Load only claims relevant to the requested outcome.
- Apply references/audit-policy.md.
- If no check is due, proceed and label material unverified assumptions.
- If a check is due, verify only selected claims or affected areas unless a full audit is selected.
Reconcile
- Capture outcome, affected scope, evidence, blockers, and next action.
- Mark dependent claims stale when invalidation conditions match.
- Never convert a chat assertion into confirmed fact.
- Append superseding claim records instead of deleting contradicted history.
- Keep
AGENTS.md for durable rules, not progress.
- If writes are not authorized, return a proposed state update.
Handle a context anomaly
When any material context conflict or suspected false premise appears:
- Emit a
CONTEXT_INTEGRITY_ALERT before continuing dependent development.
- Quarantine the affected claim as
DISPUTED or STALE; do not use it as a premise.
- Find the earliest identifiable record, commit, diff, decision, or conversation that introduced the premise.
- Review every directly dependent modification made since that point, including affected commits, files, tests, configuration, decisions, tasks, and derived claims.
- Trace one additional dependency hop when a direct dependent changed public behavior, persisted state, authorization, deployment, or safety controls.
- Bound the review to the dependency cone. Escalate to
FULL only when the origin or blast radius cannot be bounded, multiple foundational claims conflict, or high-risk integrity is involved.
- Separate context correction from business-code repair. Do not modify business code without authorization.
- Preserve the original record and append a superseding correction with evidence.
Do not resume work that depends on a quarantined claim until it is confirmed, replaced, or the user explicitly accepts the uncertainty.
Verify and reflect
Run scripts/choose_verification.py for reproducible routine sampling. Seed decisions with project identity, revision, date bucket, risk, and policy version.
For selected claims ask:
- Which assumptions support this claim?
- What current evidence could disprove it?
- Did relevant code, configuration, dependencies, or runtime state change?
- Were plan, implementation, test, deployment, and authorization confused?
- Do code, tests, docs, graph data, and runtime evidence conflict?
- Would independent review reach the same conclusion without the stored summary?
Classify results as CONFIRMED, INFERRED, PROPOSED, DISPUTED, STALE, or INVALIDATED.
Detect changes and measure cost
Run scripts/detect_project_change.py before a polling audit. It hashes project content while excluding Git internals, generated caches, dependencies, and its own state file.
- On
baseline-initialized or no-change, do not run a model audit.
- On
project-status-change, run a focused orientation or audit according to the verification policy.
- Store only the detector state in
.codex/project-context/watch-state.json; do not treat it as project evidence.
- Keep true event delivery separate from detection. A Codex scheduled task polls; a hook or watcher must invoke the detector for immediate delivery.
Run scripts/benchmark_context_cost.py to compare full-text orientation input with the compact governed context. Report file bytes and timings as measured values, token counts as estimates unless a model usage event was captured.
Boundaries
- Never edit business code merely to make memory correct.
- Never run broad tests or refresh expensive indexes only because the skill loaded.
- Never treat confidence as evidence.
- Never auto-edit governance, durable decisions, authorization, or promotion during unattended audits; propose changes for review.
- Prefer read-only scheduled audits and isolated worktrees when audits may produce changes.
Output
For routine use report: context source and freshness; verification decision and reason; current outcome; material stale/disputed items; and one next action.
For bootstrap, repair, or full audit also report evidence examined, claims superseded, residual uncertainty, and proposed state-file changes.
When an anomaly exists, report:
CONTEXT_INTEGRITY_ALERT and severity: warning, high, or critical.
- Quarantined claim IDs and the conflicting evidence.
- Earliest known introduction point.
- Directly dependent modifications reviewed or still pending.
- Whether the blast radius is bounded.
- Safe next action and whether user authorization is required.
1---2name: project-context-governor3description: Maintain low-cost, evidence-backed project context across Codex chats and report context-integrity anomalies. Use when importing or organizing a repository, starting or resuming substantial project work, asking for project status or next steps, reconciling progress after meaningful changes, detecting stale or conflicting conclusions, tracing earlier changes based on a wrong premise, or running periodic project-memory audits. Avoid routine use for isolated trivial tasks unless explicitly invoked.4license: Apache-2.05---67# Project Context Governor89Maintain useful project context without revalidating everything on every chat. Separate loading from verification, sample routine claims, and force checks only when risk or conflicting evidence requires them.1011## Principles12131. Prefer current code, Git state, tests, and runtime evidence over summaries or memories.142. Use memory for navigation, never as proof.153. Keep facts, interpretations, decisions, plans, and negative results distinct.164. Supersede wrong records; never silently rewrite history or hide conflict.175. Load context cheaply. Activation alone does not require verification.186. Spend verification budget by risk, staleness, change impact, and reproducible sampling.197. Respect scope. Status and review requests remain read-only unless state-file changes are authorized.2021## Select a workflow2223- **Bootstrap**: Organize or onboard a repository. Reuse existing state systems before proposing new files.24- **Orient**: Resume substantial work. Load the smallest relevant context; normally do not verify it.25- **Reconcile**: After authorized meaningful changes, update only affected claims when context-file writes are in scope.26- **Audit**: Perform periodic, sampled, conflict-triggered, or requested validation.27- **Repair context**: Supersede a wrong claim and identify downstream claims needing review.2829## Bootstrap30311. Read applicable `AGENTS.md` plus existing architecture, status, plan, decision, and task artifacts.322. Prefer configured code-graph tools for discovery. Index only when no usable index exists or audit policy selects refresh.333. Reuse existing sources of truth. Do not create parallel documents.344. If setup is authorized and no equivalent store exists, use `.codex/project-context/` from [references/state-schema.md](references/state-schema.md).355. Record the baseline revision and freshness. Do not claim a full audit unless one ran.3637## Orient cheaply38391. Load applicable instructions and compact current state.402. State the last verified revision/date and known stale or disputed items.413. Load only claims relevant to the requested outcome.424. Apply [references/audit-policy.md](references/audit-policy.md).435. If no check is due, proceed and label material unverified assumptions.446. If a check is due, verify only selected claims or affected areas unless a full audit is selected.4546## Reconcile47481. Capture outcome, affected scope, evidence, blockers, and next action.492. Mark dependent claims stale when invalidation conditions match.503. Never convert a chat assertion into confirmed fact.514. Append superseding claim records instead of deleting contradicted history.525. Keep `AGENTS.md` for durable rules, not progress.536. If writes are not authorized, return a proposed state update.5455## Handle a context anomaly5657When any material context conflict or suspected false premise appears:58591. Emit a `CONTEXT_INTEGRITY_ALERT` before continuing dependent development.602. Quarantine the affected claim as `DISPUTED` or `STALE`; do not use it as a premise.613. Find the earliest identifiable record, commit, diff, decision, or conversation that introduced the premise.624. Review every directly dependent modification made since that point, including affected commits, files, tests, configuration, decisions, tasks, and derived claims.635. Trace one additional dependency hop when a direct dependent changed public behavior, persisted state, authorization, deployment, or safety controls.646. Bound the review to the dependency cone. Escalate to `FULL` only when the origin or blast radius cannot be bounded, multiple foundational claims conflict, or high-risk integrity is involved.657. Separate context correction from business-code repair. Do not modify business code without authorization.668. Preserve the original record and append a superseding correction with evidence.6768Do not resume work that depends on a quarantined claim until it is confirmed, replaced, or the user explicitly accepts the uncertainty.6970## Verify and reflect7172Run `scripts/choose_verification.py` for reproducible routine sampling. Seed decisions with project identity, revision, date bucket, risk, and policy version.7374For selected claims ask:75761. Which assumptions support this claim?772. What current evidence could disprove it?783. Did relevant code, configuration, dependencies, or runtime state change?794. Were plan, implementation, test, deployment, and authorization confused?805. Do code, tests, docs, graph data, and runtime evidence conflict?816. Would independent review reach the same conclusion without the stored summary?8283Classify results as `CONFIRMED`, `INFERRED`, `PROPOSED`, `DISPUTED`, `STALE`, or `INVALIDATED`.8485## Detect changes and measure cost8687Run `scripts/detect_project_change.py` before a polling audit. It hashes project content while excluding Git internals, generated caches, dependencies, and its own state file.8889- On `baseline-initialized` or `no-change`, do not run a model audit.90- On `project-status-change`, run a focused orientation or audit according to the verification policy.91- Store only the detector state in `.codex/project-context/watch-state.json`; do not treat it as project evidence.92- Keep true event delivery separate from detection. A Codex scheduled task polls; a hook or watcher must invoke the detector for immediate delivery.9394Run `scripts/benchmark_context_cost.py` to compare full-text orientation input with the compact governed context. Report file bytes and timings as measured values, token counts as estimates unless a model usage event was captured.9596## Boundaries9798- Never edit business code merely to make memory correct.99- Never run broad tests or refresh expensive indexes only because the skill loaded.100- Never treat confidence as evidence.101- Never auto-edit governance, durable decisions, authorization, or promotion during unattended audits; propose changes for review.102- Prefer read-only scheduled audits and isolated worktrees when audits may produce changes.103104## Output105106For routine use report: context source and freshness; verification decision and reason; current outcome; material stale/disputed items; and one next action.107108For bootstrap, repair, or full audit also report evidence examined, claims superseded, residual uncertainty, and proposed state-file changes.109110When an anomaly exists, report:111112- `CONTEXT_INTEGRITY_ALERT` and severity: warning, high, or critical.113- Quarantined claim IDs and the conflicting evidence.114- Earliest known introduction point.115- Directly dependent modifications reviewed or still pending.116- Whether the blast radius is bounded.117- Safe next action and whether user authorization is required.