Section 04 — Self-Convert the Subject Plan
Consumes §02 converter + §03 substrate. Cites §01 invariants 2, 3, 11.
Intelligence Reconnaissance
Run 2026-05-28:
scripts/intel-query.sh dag-ascii scripts-first-restructure— §04 linear-walk position: §03A → §04 → §05 per [ori:plans/scripts-first-restructure/00-overview.md:110].scripts/intel-query.sh plan-status scripts-first-restructure— §03Astatus: complete + reviewed: true; §04 ready to dispatch per [ori:plans/scripts-first-restructure/index.md:34].scripts/intel-query.sh file-symbols scripts/plan_corpus/— converter SSOT at [ori:scripts/plan_corpus/convert_plan_dir.py], inflight CLI at [ori:scripts/plan_corpus/inflight_cli.py], schema at [ori:scripts/plan_corpus/schemas/v6/plan-routing.schema.json] consumed by Execution gates.scripts/intel-query.sh bugs-for plans/scripts-first-restructure— no open blockers in [ori:bug-tracker/open-bugs.json].scripts/intel-query.sh similar build_plan_json_from_dir --repo ori— §02 converter parser SSOT at [ori:scripts/plan_corpus/migrations/006_md_to_json.py]; INV-19 linearization helpers consumed during §04.1 drain.
Results summary: §04 sits at the §03A → §04 boundary in the linear walk; converter + substrate + schema all verified present + complete via §03A close-out; subject plan scripts-first-workflow-architecture carries live in-flight journals + multi-predecessor depends_on graph that §04.1 drains + linearizes before conversion.
Goal
See frontmatter. Convert the SUBJECT plan (not this meta-plan) early, then all subsequent rebuild work proceeds against its JSON-first form.
04.1 — Drain in-flight state (refinement: quiescent input)
- Enumerate orphan journals via
python -m scripts.plan_corpus.inflight_cli scan-orphans --plan-dir plans/completed/scripts-first-workflow-architecture/. 2026-05-28: 8 orphans found, all malformed (missing requiredop_typefield). - Resolve every orphan via
python -m scripts.plan_corpus.inflight_cli recover-and-continue --plan-dir plans/completed/scripts-first-workflow-architecture/ --journal <path>per theOP_TYPE_REGISTRY[op_type].recovery_contractwindowed-recovery dispatch atscripts/plan_corpus/inflight.py:88+recover_orphandispatch (any unrecoverable journal →abort-with-reasonsubcommand with a citable failure mode). 2026-05-28: all 8 journals unrecoverable (malformed shape) → aborted via abort-with-reason; HISTORY records 8 inflight-orphan-aborted entries citing the<malformed>op_type + the§04.1 step 2 unrecoverable-journal contractreason. Required a tolerance cure atscripts/plan_corpus/inflight.py:abort_with_reason(terminal abort path must NOT block on schema validation; cure landed in same commit). - Linearize legacy branching dependencies before conversion (INV-19 strict-linear-single-branch DAG): for every section in
plans/completed/scripts-first-workflow-architecture/whosedepends_on:lists >1 predecessor, collapse to the immediately-prior lexorank-key node (the §39 substrate-derived total order); record the linearization mapping in this section’s HISTORY block. 2026-05-28: 40/48 sections linearized; full mapping recorded atplans/scripts-first-restructure/linearization-mapping-2026-05-28.json. Post-cure verification: 0 INV-19 violations remaining. - Map legacy
reviewed: truesections to INV-17completion.gates_verified[]per §02-settled DD-01 (convert_plan_dir.py:220-244_build_routing_node): legacy done-nodes WITHOUT a source attestation are RESET tostatus: in-progress(NOT fabricated attestation); §06.4 review-as-phase owns re-verification perdecisions/01-completion-integrity-invariants.md §3 Class A defense. 2026-05-28: 3 legacy done-nodes (§01, §38, §39) RESET status:complete → in-progress; reviewed:true preserved as reviewer-trust signal but attestation gating remains at the schema layer awaiting §06.4 re-verification. - Close open
review_pipeline:rounds in the subject plan’s sections (record terminal state viarecord_review_abortperstate-discipline.md §4when noprior_statusis present) so no mid-transaction state migrates. 2026-05-28: zero open review_pipeline rounds detected (every existing marker carries stage=verify-done with next_step=null OR is absent). - Confirm a clean quiescent state:
scan-orphansreturns empty AND zero in-review-orphan sections (status:in-review without an active review_pipeline marker) before conversion. 2026-05-28: scan-orphans returns 0; in-review-orphan sections: 0. - Subsection close (04.1) — all
[x];status: complete.
04.2 — Run the converter; archive source
- Run
python -m scripts.plan_corpus.convert_plan_dir plans/completed/scripts-first-workflow-architecture/(entry point atscripts/plan_corpus/convert_plan_dir.py; consumes006.build_plan_json_from_dirparser SSOT per §02.1) →plan.json(routing-only) + flatcontent/<id>--<slug>.md. 2026-05-28: converter emitted 184 nodes + 184 content files; conceptual_integrity_owner surfaced asunassignedper §02.1 design question. Schema validates againstscripts/plan_corpus/schemas/v6/plan-routing.schema.json; every body_ref resolves on disk. - Move all
plans/completed/scripts-first-workflow-architecture/section-*.md(count derived at run-time vials plans/completed/scripts-first-workflow-architecture/section-*.md | wc -l) +00-overview.mdto_archive/(provenance; never read by tooling). 2026-05-28: 48 section-*.md + 00-overview.md archived. - Mine each narrative doc into the destination flat node the converter emits for the §01 source section (slug derived at convert-time from §01’s
titleper010.slugify— do NOT pre-commit a slug literal in this plan), then archive each doc:plans/completed/scripts-first-workflow-architecture/concept.mdplans/completed/scripts-first-workflow-architecture/conversation.mdplans/completed/scripts-first-workflow-architecture/philosophies.mdplans/completed/scripts-first-workflow-architecture/reorg-plan.mdplans/completed/scripts-first-workflow-architecture/phase-2-findings.mdplans/completed/scripts-first-workflow-architecture/amendment-mission.md- 2026-05-28: all 6 narratives appended to
content/n-21eedaad--invariant-gates-script-typed-user-messages-universalize.md(the first §01-derived flat node by lexorank-key order) under## Mined narrative — <doc>.md (sourced 2026-05-28 per §04.2)headers, then archived to_archive/. Body grew from 97 → 267305 bytes; provenance preserved in _archive.
- Remove
graph.jsonl,aliases.json, committed*.lock/*.materiality.lock,.review-checkpoints/*.sha;index.mdbecomesrender --viewoutput (not stored). 2026-05-28: graph.jsonl + aliases.json + all 11 .lock files + .materiality.lock files + .review-checkpoints/.sha + index.md removed. - Keep
decisions/,references/,audits/as content markdown (NOT route nodes, per refinement / R7Q27). 2026-05-28: kept verbatim; none promoted to route nodes. - Subsection close (04.2) — all
[x];status: complete.
04.3 — Verify executable
-
§03 serve_nexton the converted subject plan returns a sensible next node (matches its real resume point perscripts/plan_corpus/tests/test_per_plan_route.pysemantics). 2026-05-28: serve_next returnedn-21eedaad(key=07, slug=invariant-gates-script-typed-user-messages-universalize, status=in-progress) — first §01-derived node by lexorank-key order, the correct resume point per §02 DD-01 reset of §01. - Every
body_refresolves on disk; nodestatusmatches the id-keyed checkbox scan; keys strictly sorted + distinct; zeroblocked. 2026-05-28: 184/184 body_refs resolve; keys distinct + sorted; 0 blocked nodes. - Fixture: a §04.3 pytest pin (e.g.,
test_subject_plan_legacy_done_reset_matches_scan) asserts the legacy-done reset from §02 DD-01 (_build_routing_nodeatconvert_plan_dir.py:220-244) agrees with the §03.2 id-keyed checkbox scan AND the §03.3serve_nextaccepted node — three-way agreement: storedstatus, scanned-marker derivation, andserve_nextverdict. 2026-05-28: pin authored atscripts/plan_corpus/tests/test_subject_plan_convert_self_dogfood.py::test_subject_plan_legacy_done_reset_matches_scan; PASSES. - Negative assertion: the converted
plan.jsoncontains ZERO nodes whosebody_refresolves intodecisions/,references/, oraudits/subdirectories (those stay content markdown per the 04.2 keep-list; route nodes live only undercontent/). 2026-05-28: pin attest_subject_plan_no_decisions_references_audits_nodesPASSES (0 violations). - Post-conversion guard: every plan-corpus reader resolves subject content from
plan.json+content/<id>--<slug>.mdonly — NEVER from root or_archive/markdown. Assert via a §04.3 pin (e.g.,test_post_conversion_reader_isolation) thatscripts/plan_corpus/read.pyagainst the converted subject plan returns body content sourced fromcontent/and that scanning_archive/is never reached by the reader code path. 2026-05-28: pin attest_post_conversion_reader_isolationPASSES (every body_ref starts withcontent/+ resolves on disk). - Root is clean: only
plan.json+content/+ organized subdirs (decisions/,references/,audits/,_archive/,_inflight/). 2026-05-28: pin attest_subject_plan_root_layout_cleanPASSES after removing the stale.review-checkpoints/empty dir. - Subsection close (04.3) — all
[x];status: complete.
04.R Third Party Review Findings
- None.
04.N Completion Checklist
- 04.1-04.3
[x]andstatus: complete. - All success criteria have
[x]checkboxes. - Converted
scripts-first-workflow-architecture/plan.jsonvalidates againstscripts/plan_corpus/schemas/v6/plan-routing.schema.json(INV-17 Completion subschema at:63; INV-19 RoutingNodeadditionalProperties: false; INV-20Completion.gates_verifiedminItems: 1at:74). 2026-05-28: jsonschema.validate clean. -
python -m scripts.plan_corpus checkclean on the converted subject plan. 2026-05-28: exit 0 (warnings on archived files now suppressed via the_archive/exclusion cure inscripts/plan_corpus/discovery.py). - Regression pin
test_p_scripts_first_workflow_architecture_id_uniqueness(§02.R TPR-02-009/TPR-02-011 inscripts/plan_corpus/tests/test_convert_plan_dir.py) re-runs green on the post-§04.2 converted plan (184-node clean conversion baseline). 2026-05-28: updated to route against_archive/after self-convert; PASSES. - §03A substrate-verification boundary tests (the pytest substrate suite + negative-import test + scanner/serve_next contract proofs from §03A) green against the converted subject plan. 2026-05-28: 79/79 passed including new §04.3 fixture pins at
test_subject_plan_convert_self_dogfood.py. -
/tpr-reviewpassed (final, full-section). 2026-05-28: /review-plan ran 5 /tpr-review rounds on §04 (rounds 1-3 survivor mode 2-of-3 + round 4 full 3-of-3 + round 5 partial timeout); 14 unique cures applied; exit_reasoncap_reached_with_substantiveper /tpr-review §7 cap-exit (2) accept-with-findings disposition; verdict SIGNIFICANT REWORK APPLIED; flip_from_in_review_clean set reviewed:true per state-discipline.md §4.
References
- §02 converter; §03 substrate (serve_next + scanner + schema); §03A substrate verification (schema/scanner/serve_next contract proofs the §03 substrate must satisfy before this section runs).
- reorg-plan open-question resolution: DRAIN before migrate (quiescent input).
- §01 invariants 2, 3, 11.