oc_chat
Loading...
Searching...
No Matches
plan_fold_gate Namespace Reference

Classes

class  Region
class  Check

Functions

list[str] evaluate (str text, Check check)
list[str] _manifest_problems ()
str|None read_source (str rel_path, bool worktree)
str|None read_plan (bool worktree)
int run (bool worktree)
int main (list[str]|None argv=None)

Variables

 _REPO = Path(__file__).resolve().parent.parent
str PLAN = "oc_chat/plans/completed/151-monorepo-migration.md"
str DEFERRED = "tools/151_deferred_sol20_tooling.md"
dict _SOURCES = {"plan": PLAN, "deferred": DEFERRED}
int _REGION_MAX = 20000
 _T8_CLOSE = Region("T8 close order", "close order (ONE canonical list", "Pin the mechanism as")
 _T1_STEP3 = Region("T1 step 3 (fetch)", "OC_MIGRATION_BRANCH=<pinned>", "**⚠️")
 _T2_D4 = Region("T2 D4 step", "D4 — distribution-SUPPLY fix", "D5 — ONE")
 _T0_LEDGER = Region("§2.1 ledger schema", "ledger_schema_version, tranche", "**")
 _S24_ROLLBACK = Region("§2.4 rollback", "rollback of the structural move", "###")
 _T1_REHEARSAL = Region("T1 rehearsal Gate", "the rehearsal runs on a MERGED", "**")
 _T0_GATE = Region("T0 Gate", "each anchor tag (`pre-oc-chat-merge`", "free-space PER-VOLUME BUDGET receipt")
 _T8_MIRROR
 _AC22_ATOMIC = Region("AC row 22 (T8 close)", "| 22 | **T8 (close):**", "| T8 report;")
 _S10_VARS = Region("§1.0 canonical vars", "ACTIVE_FREEZE_PATH = <dispatch-pinned", "```")
 _T2_GATE = Region("T2 Gate (workspaces row)", "the scm `root`-DEPTH re-derivation recorded", "report-T2.")
 _T8_FAILPATH
 _T8_GATE_BLOCKED
 _S7_V = Region("§7(v) fold-evidence protocol", "(v) THE MECHANICAL FOLD-LANDING GATE", "| # | Check |")
tuple _BLOCKED_WINDOW
tuple _MANIFEST_WINDOW
 _AC11 = Region("AC row 11 (runtime-state boundary)", "| 11 | **Runtime-state boundary", "| 12 |")
 _AC18 = Region("AC row 18 (T2 D5 + settings)", "| 18 | **T2 D5 + settings", "| 19 |")
dict MANIFEST
list CHECKS

Detailed Description

Fold-landing gate for review-hardened plans (built for plan 151).

Purpose
-------
What this is — and, honestly, what it is NOT (2026-07-15, reviews 151/R17+R18).
This is a **region-scoped exact-substring checker**. For each folded finding it
asserts:

  * NEW  — the new mechanism's literal appears INSIDE the finding's executing
           region (a bounded span between two anchor strings — a step, a Gate,
           an AC row), **not merely somewhere in the document**. This is the
           capability whose absence let the v1 gate certify step-landings that
           were only in prose (Opus R18 O18-P0-1: the `/save` check passed while
           the T8 step had no `/save`).
  * GONE  — the retired literal and its listed paraphrases appear nowhere outside
           the sanctioned historical narrative.

It is **NOT** semantic paraphrase detection. The ``gone`` lists are a hand-curated
exact-substring denylist, case-sensitive; an unforeseen rewording is not caught.
The v1 tool over-claimed "concept-aware"; that claim is RETRACTED. A deterministic
checker cannot prove a concept is gone — so a MANDATORY HUMAN CONCEPT AUDIT remains
part of the fold procedure (plan §7(iii)); this gate is the mechanical floor under
it, not a replacement for it.

It is also NOT a completeness proof. ``CHECKS`` is reconciled against ``MANIFEST``
(the review-finding IDs it must cover) so the denominator cannot silently shrink by
deleting a check — but a finding nobody added to the manifest is still uncovered.

V30 (Sol R25 SOL25-03): the R24 lifecycle literals are the smallest complete OPERATIVE
contracts (the T8 custody phrase with its ledger-hash equality; the freeze-marker
baseline comparison) instead of bare tokens — Sol executed two single-leg mutations
that deleted the safety action while keeping the token, and the V29 checks stayed
green; both are now pinned regression tests. The three T8 blocked-path surfaces
(step / Gate / AC 22) are checked per-surface, and the receipt enumerates every
audited source. Still a phrase floor, not a lifecycle proof.

V31 (operator re-scope directive 2026-07-16 + Fable/Sol R26): the plan's evidence-layer
dispatch gates were retired by operator directive (threat-matched for a sole-operator,
local, reversible migration), so SOL25-01/SOL25-01-probe/SOL25-01-vars (the
authenticated-ledger dispatch gate), TERRA22-04 (the SOL20-04 pre-dispatch commit at
AC 22), and S23-P1-3 (the retired section-1.0 commit variable) are RETIRED from
CHECKS+MANIFEST — their anchor text no longer exists in the plan. SOL25-04 is
RETARGETED to the simple one-commit receipt form of section 7 clause v, and the
SOL25-02 blocked-path window is WIDENED over the two new close items. New checks:
F26-01 (the T2 PRESERVE equality oracle), F26-02-step/-gate/-ac22 (the terminal
artifact manifest blocked-path item, per surface), F26-03 (the rollback-copy and
DACL-save blocked-path items), R25-01-root (the durable-root declaration — Sol R26
mutation C, executed false-green at V30, now red), and V31-T8-RECONCILE (the kept T8
terminal-transition contract at AC 22). The V30 claim that each new check carried a
single-leg adversarial test was FALSE for five of the nine (Sol R26 SOL26-05); the
test suite now carries a META-TEST mapping every manifest fid to a named test or the
documented untested-phrase-floor list, failing on drift.

Usage
-----
    python tools/plan_fold_gate.py            # gate the committed HEAD blob (authoritative)
    python tools/plan_fold_gate.py --worktree # gate the working tree (iterating a fold)

Responsibilities
----------------
- :class:`Region` — a bounded span of the plan, located between two anchor strings.
- :class:`Check` — one finding: its ``new`` literal + the ``region`` it must land in,
  plus whole-document ``gone`` literals.
- :data:`CHECKS` / :data:`MANIFEST` — the fold set and the review IDs it must cover.
- :func:`evaluate` — THE single production predicate: returns the problems for one
  check against the plan text (the tests call this — they do not re-implement it).
- :func:`read_plan` / :func:`run` / :func:`main`.

Exit codes
----------
- 0 — every check passed and the manifest is covered.
- 1 — a finding did not land at its region, a retired literal survived, or the
      manifest/checks disagree.
- 2 — the plan file could not be read.

Diagnostics
-----------
Domain: OC_CHAT.MAIN
Levels:
    L2 — lifecycle events (the pass/fail tally)
    L3 — semantic details
    L4 — deep tracing

Contracts
---------
- The committed blob (``git show HEAD:<plan>``) is authoritative; ``--worktree`` is
  only for iterating a fold before committing.
- Historical-scope decision (Opus R17 O17-P1-4): ``gone`` targets a retired concept's
  OPERATIVE phrasing; a dated statement of fact ("renamed from X", "branch Y is merged
  and deleted") is allowed, which is why ``gone`` lists operative phrasings not bare
  nouns.

Dependencies
------------
- oc_diagnostics (structured debug logging via _dbg)

Function Documentation

◆ _manifest_problems()

list[str] plan_fold_gate._manifest_problems ( )
protected
Return problems if CHECKS and MANIFEST have drifted (a required finding uncovered, or a check not in the manifest).

Definition at line 392 of file plan_fold_gate.py.

Here is the caller graph for this function:

◆ evaluate()

list[str] plan_fold_gate.evaluate ( str text,
Check check )
THE production predicate. Return the problems for ``check`` against ``text``
(empty list == pass). Tests call THIS — they do not re-implement it (SOL18-01).

Definition at line 356 of file plan_fold_gate.py.

Here is the caller graph for this function:

◆ main()

int plan_fold_gate.main ( list[str] | None argv = None)
CLI entry point.

Definition at line 459 of file plan_fold_gate.py.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_plan()

str | None plan_fold_gate.read_plan ( bool worktree)
Return the plan text (back-compat shim over :func:`read_source`).

Definition at line 418 of file plan_fold_gate.py.

Here is the call graph for this function:

◆ read_source()

str | None plan_fold_gate.read_source ( str rel_path,
bool worktree )
Return a source file's text: the committed HEAD blob (authoritative) or the worktree.
Generalizes ``read_plan`` so a CROSS-FILE check can gate a second file (V29 SOL24-03).

Definition at line 403 of file plan_fold_gate.py.

Here is the caller graph for this function:

◆ run()

int plan_fold_gate.run ( bool worktree)
Evaluate every check, print the labelled receipt, return the process exit code.

Definition at line 423 of file plan_fold_gate.py.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ _AC11

plan_fold_gate._AC11 = Region("AC row 11 (runtime-state boundary)", "| 11 | **Runtime-state boundary", "| 12 |")
protected

Definition at line 206 of file plan_fold_gate.py.

◆ _AC18

plan_fold_gate._AC18 = Region("AC row 18 (T2 D5 + settings)", "| 18 | **T2 D5 + settings", "| 19 |")
protected

Definition at line 207 of file plan_fold_gate.py.

◆ _AC22_ATOMIC

plan_fold_gate._AC22_ATOMIC = Region("AC row 22 (T8 close)", "| 22 | **T8 (close):**", "| T8 report;")
protected

Definition at line 170 of file plan_fold_gate.py.

◆ _BLOCKED_WINDOW

tuple plan_fold_gate._BLOCKED_WINDOW
protected
Initial value:
1= ("`tag_receipt_sha256` re-check**, "
2 + "**independent rollback-copy verified**, "
3 + "**archive+parent DACL `/save` verified**, "
4 + "lock, smoke, intact-check")

Definition at line 195 of file plan_fold_gate.py.

◆ _MANIFEST_WINDOW

tuple plan_fold_gate._MANIFEST_WINDOW
protected
Initial value:
1= ("final report-hash, **`terminal_artifact_manifest` compute + read-back**"
2 ", final ledger-append")

Definition at line 201 of file plan_fold_gate.py.

◆ _REGION_MAX

int plan_fold_gate._REGION_MAX = 20000
protected

Definition at line 120 of file plan_fold_gate.py.

◆ _REPO

plan_fold_gate._REPO = Path(__file__).resolve().parent.parent
protected

Definition at line 113 of file plan_fold_gate.py.

◆ _S10_VARS

plan_fold_gate._S10_VARS = Region("§1.0 canonical vars", "ACTIVE_FREEZE_PATH = <dispatch-pinned", "```")
protected

Definition at line 173 of file plan_fold_gate.py.

◆ _S24_ROLLBACK

plan_fold_gate._S24_ROLLBACK = Region("§2.4 rollback", "rollback of the structural move", "###")
protected

Definition at line 163 of file plan_fold_gate.py.

◆ _S7_V

plan_fold_gate._S7_V = Region("§7(v) fold-evidence protocol", "(v) THE MECHANICAL FOLD-LANDING GATE", "| # | Check |")
protected

Definition at line 183 of file plan_fold_gate.py.

◆ _SOURCES

dict plan_fold_gate._SOURCES = {"plan": PLAN, "deferred": DEFERRED}
protected

Definition at line 119 of file plan_fold_gate.py.

◆ _T0_GATE

plan_fold_gate._T0_GATE = Region("T0 Gate", "each anchor tag (`pre-oc-chat-merge`", "free-space PER-VOLUME BUDGET receipt")
protected

Definition at line 167 of file plan_fold_gate.py.

◆ _T0_LEDGER

plan_fold_gate._T0_LEDGER = Region("§2.1 ledger schema", "ledger_schema_version, tranche", "**")
protected

Definition at line 162 of file plan_fold_gate.py.

◆ _T1_REHEARSAL

plan_fold_gate._T1_REHEARSAL = Region("T1 rehearsal Gate", "the rehearsal runs on a MERGED", "**")
protected

Definition at line 164 of file plan_fold_gate.py.

◆ _T1_STEP3

plan_fold_gate._T1_STEP3 = Region("T1 step 3 (fetch)", "OC_MIGRATION_BRANCH=<pinned>", "**⚠️")
protected

Definition at line 160 of file plan_fold_gate.py.

◆ _T2_D4

plan_fold_gate._T2_D4 = Region("T2 D4 step", "D4 — distribution-SUPPLY fix", "D5 — ONE")
protected

Definition at line 161 of file plan_fold_gate.py.

◆ _T2_GATE

plan_fold_gate._T2_GATE = Region("T2 Gate (workspaces row)", "the scm `root`-DEPTH re-derivation recorded", "report-T2.")
protected

Definition at line 174 of file plan_fold_gate.py.

◆ _T8_CLOSE

plan_fold_gate._T8_CLOSE = Region("T8 close order", "close order (ONE canonical list", "Pin the mechanism as")
protected

Definition at line 159 of file plan_fold_gate.py.

◆ _T8_FAILPATH

plan_fold_gate._T8_FAILPATH
protected
Initial value:
1= Region("T8 step failure path (blocked-path set)",
2 "Failure path: if ANY close gate fails", "write a NON-terminal")

Definition at line 178 of file plan_fold_gate.py.

◆ _T8_GATE_BLOCKED

plan_fold_gate._T8_GATE_BLOCKED
protected
Initial value:
1= Region("T8 Gate (blocked-path set)",
2 "non-terminal BLOCKED path taken on any failed close gate",
3 "never `Completed` before the final ledger entry lands")

Definition at line 180 of file plan_fold_gate.py.

◆ _T8_MIRROR

plan_fold_gate._T8_MIRROR
protected
Initial value:
1= Region("T8 terminal transition (canonical close step 6)",
2 "LIFT the freeze (a marker removal, not a failure-capable gate)", "NEVER the artifact root")

Definition at line 168 of file plan_fold_gate.py.

◆ CHECKS

list plan_fold_gate.CHECKS

Definition at line 241 of file plan_fold_gate.py.

◆ DEFERRED

str plan_fold_gate.DEFERRED = "tools/151_deferred_sol20_tooling.md"

Definition at line 115 of file plan_fold_gate.py.

◆ MANIFEST

dict plan_fold_gate.MANIFEST
Initial value:
1= {
2 "O16-P1-1", "O16-P1-3", "V17-1", "V17-3", "V17-4", "V17-6",
3 "13b", "SOL16-01", "O16-P2-1", "O16-P2-2", "O17-P1-4", "O17-P2-2",
4 "SOL17-01", "SOL17-03",
5 # R18 non-landing cluster (O18-P1-1) — must land at executing sites:
6 "SOL14-07-rollback-tags", "SOL16-03-parent-acl", "D4-gate-ac",
7 "O19-P1-1", "SOL14-04",
8 # R23: every V27 fold landed at ONE leg and left a sibling STALE. These checks make a
9 # future sibling-leg miss FAIL the gate (Terra R23 + Sonnet5 R23). (TERRA22-04 and
10 # S23-P1-3 were RETIRED at V31 with the operator re-scope — the SOL20-04 pre-dispatch
11 # commit gate they anchored on is removed from the plan.)
12 "TERRA23-01", "S23-P1-2", "OPUS22",
13 # R24: the META-PROBLEM fold — generalize the gate to LIFECYCLE + CROSS-FILE misses
14 # (Opus R24 + Sol R24). Each has an adversarial-revert test.
15 "R24-01", "R24-02", "SOL24-01", "SOL24-03", "SOL24-03-status", "OPUS22-AC11", "OPUS22-AC18",
16 # R25 (Opus R25 + Sol R25): operative-contract literals, per-surface blocked-path
17 # checks, and the durable receipt pin. (V30 claimed each carried a single-leg
18 # adversarial test — FALSE for five of the nine, Sol R26 SOL26-05; the meta-test in the
19 # test suite now enforces the mapping. SOL25-01/-probe/-vars — the hard ledger dispatch
20 # gate — were RETIRED at V31 with the operator re-scope; SOL25-04 is RETARGETED to the
21 # simple one-commit §7(v) receipt form.)
22 "R24-02-schema", "R25-01",
23 "SOL25-02-step", "SOL25-02-gate", "SOL25-02-ac22", "SOL25-04",
24 # V31 (operator re-scope 2026-07-16 + Fable/Sol R26 + the executed rehearsal): the
25 # PRESERVE oracle, the terminal-artifact-manifest blocked-path item (per surface), the
26 # rollback-copy/DACL-save items, the durable-root declaration (Sol R26 mutation C), and
27 # the kept T8 terminal-transition contract. Each has a single-leg test (meta-test-mapped).
28 "F26-01", "F26-02-step", "F26-02-gate", "F26-02-ac22", "F26-03",
29 "R25-01-root", "V31-T8-RECONCILE",
30}

Definition at line 210 of file plan_fold_gate.py.

◆ PLAN

str plan_fold_gate.PLAN = "oc_chat/plans/completed/151-monorepo-migration.md"

Definition at line 114 of file plan_fold_gate.py.