Context
Operator assessment during the same friction→gold discussion (2026-08-04): "imho the debt inside the ai folder is extreme." Concurred with first receipts measured live; this ticket converts the assessment into an instrument so follow-up work is evidence-ranked instead of vibes-ranked. Live latest-open sweep at filing: latest 15 checked, no equivalent census lane; #16488/#16495 are single-boundary instances the census will contextualize, not duplicates.
The Problem
ai/ is 682 .mjs files / ~228k lines, and the visible sediment starts at its root: FIVE config-ish entries (config.mjs, config.template.mjs, configBase.mjs, ConfigProvider.mjs, planeConfig.mjs), agent/ + demo-agents/ + Agent.mjs, services/ + services.mjs, docs/ + a root sdk-manifest.md. Known systemic classes with prior receipts: module-scope heavy imports making the SDK boundary non-load-bearing (#16488: chromadb at module scope forces a Brain-tier package to merely load; ~20 external readers block the clean init refactor), placement drift severe enough that the structural-pre-flight skill exists because of ai/ misfilings (PR #11008 lineage), and the ADR-0019 forbidden-pattern catalog existing at all. First duplication family already measured and ticketed: four lock/lease implementations (#16514).
The debt's cost is not size — it is that boundaries are not load-bearing, so every change's blast radius is unknowable without archaeology.
The Architectural Reality
- Instruments exist:
npm run --silent ai:structure-map -- --files --loc (the placement gate), rg for pattern families, ADR-0019 as the config-authority lens, learn/agentos ADRs as the placement authority.
- Hard constraint: a downstream production plane deploys from this tree — the census is READ-ONLY; no moves, no renames, no import changes ride this lane. Prescriptions become tickets, each individually deployment-safe.
The Fix
A census artifact (ticket comment series or one learn/agentos-adjacent report, driver's call) with four measured chapters:
- Duplication families — pattern census (locks/leases done →
#16514; candidates: retry/backoff shapes, atomic-write/tmp-rename, config readers, health/receipt emitters, path resolution), each with file list + call-site count + rule-of-three verdict.
- Boundary violations — module-scope imports crossing the SDK/service boundary (the
#16488 class, full set), import cycles, ai/→src/ and reverse reaches outside sanctioned entrypoints.
- Placement drift — files whose home contradicts the structure-map/ADR authority (the scripts-vs-daemons-vs-services axis), root-level sediment disposition (incl. the five config entries — audited UNDER ADR-0019's SSOT lens, which may bless some of them; the census records WHY per entry).
- Ranked follow-up set — each finding priced (blast radius × fix cost × deployment risk) and shaped into pool tickets; the ranking IS the deliverable that makes every later move cheaper.
Acceptance Criteria
Out of Scope
- Executing any consolidation/move (each rides its own ticket).
#16488/#16495/#16514 themselves (in flight; the census references and ranks around them).
Decision Record impact
none by the census itself; individual findings may propose amends cases, each carried by its own follow-up ticket.
Related
#16514 (first family, filed from the same discussion), #16488, #16495, ADR-0019, the structural-pre-flight skill lineage (PR #11008).
Origin Session ID: 1913de09-6dc0-4d1e-a9a3-b51c33b46cdc
Retrieval Hint: query_raw_memories("ai folder debt census duplication families boundary violations placement drift read-only")
Context
Operator assessment during the same friction→gold discussion (2026-08-04): "imho the debt inside the ai folder is extreme." Concurred with first receipts measured live; this ticket converts the assessment into an instrument so follow-up work is evidence-ranked instead of vibes-ranked. Live latest-open sweep at filing: latest 15 checked, no equivalent census lane;
#16488/#16495are single-boundary instances the census will contextualize, not duplicates.The Problem
ai/is 682.mjsfiles / ~228k lines, and the visible sediment starts at its root: FIVE config-ish entries (config.mjs,config.template.mjs,configBase.mjs,ConfigProvider.mjs,planeConfig.mjs),agent/+demo-agents/+Agent.mjs,services/+services.mjs,docs/+ a rootsdk-manifest.md. Known systemic classes with prior receipts: module-scope heavy imports making the SDK boundary non-load-bearing (#16488: chromadb at module scope forces a Brain-tier package to merely load; ~20 external readers block the clean init refactor), placement drift severe enough that the structural-pre-flight skill exists because ofai/misfilings (PR#11008lineage), and the ADR-0019 forbidden-pattern catalog existing at all. First duplication family already measured and ticketed: four lock/lease implementations (#16514).The debt's cost is not size — it is that boundaries are not load-bearing, so every change's blast radius is unknowable without archaeology.
The Architectural Reality
npm run --silent ai:structure-map -- --files --loc(the placement gate),rgfor pattern families, ADR-0019 as the config-authority lens,learn/agentosADRs as the placement authority.The Fix
A census artifact (ticket comment series or one
learn/agentos-adjacent report, driver's call) with four measured chapters:#16514; candidates: retry/backoff shapes, atomic-write/tmp-rename, config readers, health/receipt emitters, path resolution), each with file list + call-site count + rule-of-three verdict.#16488class, full set), import cycles,ai/→src/and reverse reaches outside sanctioned entrypoints.Acceptance Criteria
Out of Scope
#16488/#16495/#16514themselves (in flight; the census references and ranks around them).Decision Record impact
none by the census itself; individual findings may propose
amendscases, each carried by its own follow-up ticket.Related
#16514(first family, filed from the same discussion),#16488,#16495, ADR-0019, the structural-pre-flight skill lineage (PR#11008).Origin Session ID: 1913de09-6dc0-4d1e-a9a3-b51c33b46cdc
Retrieval Hint:
query_raw_memories("ai folder debt census duplication families boundary violations placement drift read-only")