Section 05 — Per-Plan SSOT + On-the-Fly Cross-Plan Route
Cites §01 north star (invariants 3, 4, 5). Grounded in Pass 1B + N4/N5. Builds on §03 per-plan serve_next; feeds §06 engine route-walk.
Intelligence Reconnaissance
Run 2026-05-28:
scripts/intel-query.sh dag-ascii scripts-first-restructure— §05 linear-walk position: §04 → §05 → §06; §03 is the transitive substrate predecessor (05→04→03A→03) per [ori:plans/scripts-first-restructure/00-overview.md:110].scripts/intel-query.sh plan-status scripts-first-restructure— §03/§03Astatus: complete; §04 self-convert in-progress; §05 depends_on [“04”] (INV-19 single-predecessor; §03 transitively via §04→§03A→§03) per [ori:plans/scripts-first-restructure/index.md].scripts/intel-query.sh file-symbols scripts/plan_corpus/per_plan_route.py— per-planserve_nextwalk + deferred-candidate handling at [ori:scripts/plan_corpus/per_plan_route.py:113] (INV-20 strict-forward-only concern for §05.1).scripts/intel-query.sh file-symbols scripts/plan_corpus/lexorank.py— lexorank key core KEPT unchanged;(key, plan, id)comparator fields sourced from [ori:scripts/plan_corpus/graph.py:149].scripts/intel-query.sh file-symbols scripts/plan_corpus/graph.py— per-planGraphscope +serve_next/relocate/escalate/mergeat [ori:scripts/plan_corpus/graph.py:176]; cross-plan merge sits ON TOP, never insideGraph.scripts/intel-query.sh bugs-for plans/scripts-first-restructure— no open blockers in [ori:bug-tracker/open-bugs.json].
Results summary: §05 sits at the §04 → §05 → §06 boundary; lexorank + per-plan Graph core verified present and KEPT-unchanged; the cross-plan route is a derived read-only merge layered over per-plan serve_next, sourced from the (key, plan, id) fields on existing Node; per_plan_route.py:113 deferred-candidate walk-past is the INV-20 concern §05.1 must close.
Goal
See frontmatter. Per-plan plan.json is SSOT; the cross-plan walk is a derived read-only merge, not a stored artifact.
05.1 — Cross-plan comparator + on-the-fly merge
- Implement the cross-plan worklist: call §03 per-plan
serve_nextper plan, merge candidates viasorted(key=lambda n: (n.key, n.plan, n.id))(N5: deterministic, uses existingNodefields, no rebase).planbreaks bare-key collisions across independently-authored plans;idis the final tiebreak (realNodefields perscripts/plan_corpus/graph.py:85—id/plan/key, NOTplan_id/node_id). - No stored global route file; the merged order is computed each pass (snapshot semantics: one merge per serve_next pass).
- Name the cross-plan API
serve_next_with_cross_plan; it merges per-planserve_nextcandidates viasorted(key=lambda n: (n.key, n.plan, n.id))and returns at most one cross-plan-ready node (per00-overview.mdINV-20). - Enforce INV-20 strict-forward-only at the per-plan walk:
scripts/plan_corpus/per_plan_route.py:113MUST returnNoneon a deferred active cross-plan-hint candidate rather than walking past it to subsequent same-plan nodes (a deferred predecessor blocks the plan’s progress; it is NOT skipped). Pin with a regression test asserting no walk-past. - All-cross-plan-blocked §05→§06 handoff: when every plan’s
serve_next_with_cross_plancandidate is deferred (cross-planhint_needsunsatisfied), the merge yields no ready node; the §06 engine route-walk consumes this as the named canonical exit_reasonno_cross_plan_ready_node(no halt) per00-overview.mdinvariant 6 zero-halts; §06 MUST register it inscripts/plan_corpus/exit_reasons.pyCANONICAL_EXIT_REASONS+EXIT_REASON_ROUTING(caller_actionlog_and_skip, exit_code 0) before the route-walk emits it. Pin parity: the sameno_cross_plan_ready_nodeoutcome holds whether reached via empty corpus or all-deferred candidates. - Subsection close (05.1) — all
[x];status: complete.
05.2 — Retire D2 artifacts; keep the core
- Remove/repurpose
route_coexistence.route_graph_path+append_nodes_to_route(:36/:83) + the globalroute_aware_next_actionpath (:64) — no globalroute-graph.jsonlin the per-plan model. - KEEP
lexorank.py(all),graph.pyserve_next/relocate/escalate/merge (Pass 1B: plan-agnostic),route_check.py(per-dir), the.route-migrated/dispatch_modemarker concept (repurposed: “plan.json carries nodes” is the signal). - Cross-plan
hint_needs= status-lookup (§03.3 contract); relocation strictly intra-plan (refinement 4). - Subsection close (05.2) — all
[x];status: complete.
05.3 — routing.md §1 taxonomy → flat group labels (refinement 8)
- Resolve
routing.md §1placement-taxonomy fate under flat-nodes: proposal / architectural / phase-local become flatgrouplabels on nodes (not directory-routing). Document the mapping; updaterouting.md §1accordingly (out-of-compiler-rigor edit). Mapping landed inrouting.md §1 Flat-node group-label mapping(proposal→group: proposal, architectural→group: architectural, phase-local→group: phase-local, bug→group: bug; non-ordering per INV-15). - Subsection close (05.3) — all
[x];status: complete.
05.R Third Party Review Findings
- None.
05.N Completion Checklist
- 05.1-05.3
[x]andstatus: complete. - All success criteria have
[x]checkboxes. -
pytestroute suite green (comparator determinism incl. colliding bare keys + duplicate-plan + duplicate composite (plan, id) fixtures; negative-pin bare graph.serve_next against cross-plan hints; per_plan_route.py:113 no-walk-past regression; all-cross-plan-blocked §05→§06 handoff parity; cross-plan merge byte-identity; intra-plan-only relocate; cycle-impossibility preserved). (2026-05-28: route suite 41 pass — per_plan_route + route_dispatch + route_check + route_coexistence) -
python -m scripts.plan_corpus check plans/scripts-first-restructure/section-05-*.mdexit 0. (2026-05-28: exit 0) -
/tpr-reviewpassed (final, full-section). (2026-05-28: /review-plan ran 2 /tpr-review rounds; review_pipeline verify-done; SIGNIFICANT REWORK APPLIED; reviewed:true)
References
- Pass 1B:
route_coexistence.py:36/64/83,graph.py:149/176,lexorank.py. - N5 comparator
(key, plan, id); refinement 3 (determinism), 4 (scoped walk), 8 (taxonomy). - §01 invariants 3, 4, 5.
HISTORY
- 2026-05-28 — Autopilot auto-cure: review_plan_redispatch_loop reset_lost_dispatch (autopilot_run_id=055648421ae546529423a); chain log recorded a phantom /review-plan dispatch but section frontmatter showed zero review evidence; chain counter reset and /review-plan re-dispatched (per state-discipline.md §4 Hard-abort terminal-state semantics + skill-control-contract.md §Autopilot Mode unified hook-failure continuation clause).
- 2026-05-28 — Orchestrator close-out-loop gap (dogfood pass 4): §05 reached
reviewed: true+ close-out-resolved (terminal review marker) but §05.R / §05.N lifecycle subsections remainnot-started, matching NONE of the close-out states cleanly (needs_close_outrequires not-resolved;needs_status_complete_fliprequires all-subsections-complete incl. lifecycle;needs_review_plan_dispatchrequires reviewed:false). The deadlock fwd_active=False cure (run 1780008258-9cfc6327) routes §05 to_emit_review_plan_for_pre_review, which no-ops (“close-out already applied”), and the roadmap re-emits the same dispatch — a roadmap↔review-plan no-op loop the review-chain trip-guard did not converge. §05.N gates verified GREEN out-of-band (route suite 33 pass;plan_corpus checkexit 0; review pipeline TPR ran). Tooling fix needed: the fwd_active=False deadlock cure must route through the close-out state machine (State-A→/review-plan; State-B→status-flip; State-C→pre-review) rather than unconditionally to pre-review; AND lifecycle subsections (§NN.R/§NN.N) need an auto-completion path at section close. Tracked for a follow-up /improve-tooling cure; §05 substantively complete pending the routing fix. - 2026-05-29 — §07A v7 route schema supersedes the v6 flat-node route model: the route schema v7 two-level
plan.json(sections[]+ flatwork_items[], per §07A +decisions/04-sections-work-items-split.md) supersedes §05’s v6 flat-nodenodes[]route model; §05’s v6 route model stayscompletebut the v7 route model is two-level (sections carry the linear lexorank chain, work_items are the flat movable units) per §07A.4.