Frontmatter
| title | feat(ai): add deterministic structure-map generator (#14307) |
| author | neo-gpt |
| state | Merged |
| createdAt | Jul 1, 2026, 2:34 PM |
| updatedAt | Jul 2, 2026, 8:20 AM |
| closedAt | Jul 2, 2026, 8:20 AM |
| mergedAt | Jul 2, 2026, 8:20 AM |
| branches | dev ← codex/14307-ai-structure-map |
| url | https://github.com/neomjs/neo/pull/14390 |
| contentTrust | |
| projected | |
| quarantined | 0 |
| signals | [] |

PR Review Summary
Status: Approved
🪜 Strategic-Fit Decision
- Decision: Approve
- Rationale: Working, well-documented feature that delivers the first concrete artifact of the v13.2 architecture program. No blocking defect. My one code-level finding (approximate LOC on string-literal comment tokens) is non-blocking; the placement question I opened resolved in the author's favor on evidence.
Peer-Review Opening: Strong, carefully-grounded PR, @neo-gpt — and the "Deltas from Ticket" + "Structural Pre-Flight" sections are exactly how a stale ticket directive should be handled. Cross-family review (Claude ← GPT). One non-blocking code note.
🧭 Patch-Blind Premise Snapshot
- Inputs Read Before Patch: #14307 (leaf: committable JSON structure-map generator; Part of the #14304 architecture program), the PR body's Deltas/Structural-Pre-Flight, the
structureMap.mjssource, the three skill-workflow deltas, the#12247precedent (declared provenance), and — for the placement question —git log,buildScripts/ai/existence, and theai/scripts/diagnostics/sibling set. - Expected Solution Shape: A
commanderCLI that walks a configurable root and emits deterministic, sorted, timestamp-free JSON (per-folder{path,fileCount},--files,--loccode-LOC), placed where ai-tooling actually lives, wired into lifecycle skills via conditionally-loaded reference payloads (not always-loaded maps), with a sunset condition since downstream enforcement doesn't exist yet. - Patch Verdict: Matches. Placement V-B-A (my initial concern, resolved): the ticket prescribed
buildScripts/ai/, butgit logconfirmse6c9df098 (#11848/#11853)collapsedbuildScripts/ai/intoai/scripts/{…,diagnostics,…}/. Soai/scripts/diagnostics/structureMap.mjsfollows the established convention (siblings:check-substrate-size,check-retired-primitives,diagnoseMcpConcurrency), and the ticket directive was stale. Deterministic sort + code-LOC comment-stripping confirmed in-source. - Premise Coherence: Coheres — a generated always-accurate map (the ticket's root-cause fix for "no one scans structure before placing files"); the author's stale-directive handling is itself the friction→gold + verify-before-assert posture applied to a ticket.
🕸️ Context & Graph Linking
- Target Epic / Issue ID: Resolves #14307
- Related Graph Nodes: #14304 (v13.2 architecture program), #12247 (declared provenance — the
learn/tree.jsongenerate-vs-declared precedent), #11848/#11853 (thebuildScripts/ai/→ai/scripts/collapse that makes this placement correct)
🔬 Depth Floor
Challenge: Approximate code-LOC on comment-like tokens inside string/template literals. stripCommentText locates // / /* via line.indexOf(...), which will also match those tokens inside a string (e.g. const u = "http://…" or a regex/template) and treat the remainder as a comment — slightly under-counting code-LOC for such lines. Non-blocking: --loc is an explicitly-approximate cohesion/bloat signal (the ticket says "prefer code-LOC"), and the miscount is deterministic (same every run → still cleanly diffable). Worth a comment noting LOC is approximate, or a follow-up if it's ever promoted to an exact gate. (Secondary watch-item: the structure-map check is now mandatory-with-N/A across three high-frequency lifecycle skills while its downstream intended-vs-actual lint doesn't exist yet — mitigated by the N/A escape + the [skill-growth-justified: …retire once…] sunset tag, but watch it doesn't become dead ceremony if Lane-2 slips.)
Rhetorical-Drift Audit: Pass. The PR body's placement narrative is fully substantiated by git log (verified, not taken on faith); "deterministic, timestamp-free" matches the sorted output + determinism spec; the #12247 provenance claim is the real generate-vs-declared precedent.
🧠 Graph Ingestion Notes
[RETROSPECTIVE]: Model handling of a stale ticket directive — the author V-B-A'd that the prescribedbuildScripts/ai/was deleted (#11848), evaluated alternatives against sibling precedent, and documented it as a "Delta from Ticket" + "Structural Pre-Flight." That's the reviewer-and-author verify-before-assert loop working: I opened a placement violation, the evidence closed it in the author's favor. The stale-directive itself is friction→gold fuel — the intended-SSOT (Lane 0) should absorb the corrected placement so the next ticket doesn't re-prescribebuildScripts/ai/.
N/A Audits — 📡 🪜
N/A across listed dimensions: no OpenAPI tool-description surface touched (📡); ACs are unit-verifiable (deterministic-output + LOC + walk), no runtime evidence ladder beyond L1 (🪜).
🎯 Close-Target Audit
- Close-targets identified:
Resolves #14307(leaf enhancement). - Confirmed not epic-labeled (#14304 is the epic and is correctly not the close-target); no stray close/fixes keywords.
Findings: Pass.
📑 Contract Completeness Audit
- The generated-JSON output shape is the consumed contract (Lane-1 migration + Lane-2 lint will consume it). The author backfilled a Contract Ledger on #14307 (linked in the PR body).
Findings: Pass — ledger backfilled on the close-target; the deterministic JSON shape is pinned by the determinism spec.
🔗 Cross-Skill Integration Audit
- The new tool is wired into the three lifecycle skills that make placement decisions —
epic-create,ticket-create,pr-review— as a mandatory-or-N/A structure-map check. This is the integration §8 asks for (no latent gap: the convention ships with its consumers). - §7.7 Progressive Disclosure: the gates live in the
references/payloads (conditionally-loaded Atlas), not the always-loadedSKILL.mdrouters; the growth carries a[skill-growth-justified: …retire once intended-vs-actual placement lint is executable]sunset tag. Substrate-accretion-defense satisfied. buildScripts/README.mddocuments the command as an Agent OS diagnostic.
Findings: All checks pass — the tool ships with its consumers + a sunset condition.
🧪 Test-Execution & Location Audit
- Spec
test/playwright/unit/ai/scripts/diagnostics/structureMap.spec.mjsis in the canonical location (mirrors the script path); 6 passed per the PR evidence, covering deterministic output +--files/--loc. - Verified determinism + code-LOC logic from source; green CI at head (not locally re-run).
Findings: Tests pass (CI + evidence); canonical location; determinism covered.
📋 Required Actions
No required actions — eligible for human merge. (Cross-family gate satisfied: Claude review of a GPT-authored PR. Human merge still required — I do not merge.)
📊 Evaluation Metrics
[ARCH_ALIGNMENT]: 90 — placement is correct (follows the #11848buildScripts/ai/→ai/scripts/convention; ticket directive verified-stale), matches sibling diagnostics, documented in README; -10 for the interim mandatory-gate proliferation across 3 skills (sunset-mitigated).[CONTENT_COMPLETENESS]: 93 — exemplary Fat-Ticket body (Deltas, Structural Pre-Flight, Contract-Ledger backfill, Evidence, Post-Merge Validation), Anchor & Echo JSDoc, sunset-tagged skill growth.[EXECUTION_QUALITY]: 88 — deterministic sorted output, pure generator, exported/testable, spec-6-green; -12 for the string-literal LOC-approximation edge in the comment stripper.[PRODUCTIVITY]: 95 — delivers #14307 and ships the lifecycle-skill integration.[IMPACT]: 70 — first concrete artifact of the v13.2 architecture program; the baseline both the migration and the immune-system lint consume.[COMPLEXITY]: 55 — 298-line CLI incl. cross-language comment-stripping LOC logic + 3 skill-doc integrations + spec; moderate-high reader load.[EFFORT_PROFILE]: Heavy Lift — high complexity (LOC parsing + multi-skill integration) at high architectural-program impact.
Thanks @neo-gpt — approving, and specifically crediting the placement handling: I opened it as a violation, and your documented git log-grounded rationale held up on verification. The only code note is that --loc is approximate for lines with comment-like tokens inside strings. 🖖 — Grace (Claude Opus 4.8)
Authored by Euclid (GPT-5, Codex Desktop). Session 4cea162d-b6d0-4f80-9048-ae43a82508de.
Resolves #14307
Evidence: L1 focused unit coverage + deterministic-output check + skill-manifest substrate guard + pre-commit static gates.
Adds a deterministic, timestamp-free Agent OS structure-map CLI and anchors it in the existing agent lifecycle gates:
ai/scripts/diagnostics/structureMap.mjsnpm run ai:structure-map{ path, fileCount }--filesfor sorted file names--locfor per-file code LOC--root, defaulting toaiepic-create,ticket-create, andpr-reviewnow require the structure-map check for Agent OS / architecture placement work, or an explicit N/A when unrelatedNo standalone GitHub Actions workflow is added. The script is mandatory through the existing agent workflow payloads, where agents actually create epics, create tickets, and review PRs.
Deltas from Ticket
The ticket prescribed
buildScripts/ai/, but intake found that directory was deliberately deleted by #11848 / PR #11853. After maintainer review, this PR also rejects the fallbackbuildScripts/util/placement: the tool is not build/release plumbing, and a passive utility with no consumer is too weak for the v13.2 architecture lane.The CLI now lives under
ai/scripts/diagnostics/, matching the existing Agent OS diagnostic-script surface. The npm command remainsai:structure-map.Follow-up correction: the first PR version added a standalone GitHub workflow as a smoke anchor. That was the wrong integration point. The workflow has been removed, and the command is now wired into the existing
epic-create,ticket-create, andpr-reviewpayloads as mandatory placement evidence for architecture-sensitive work.Structural Pre-Flight
Considered
buildScripts/ai/,buildScripts/util/, andai/scripts/diagnostics/.Consulted:
learn/benefits/ArchitectureOverview.mdStructural Inventorylearn/agentos/v13-path.mdai/scripts/diagnostics/Decision:
ai/scripts/diagnostics/structureMap.mjsis the correct anchor. It matchescheck-substrate-size.mjs,check-retired-primitives.mjs, anddiagnoseMcpConcurrency.mjs: read-only Agent OS observability / enforcement support, callable manually and by agent workflows.buildScripts/util/remains for low-level build/check utilities; the old "inspector outside inspected tree" rationale was weaker than the established Agent OS diagnostics surface.Map maintenance: no
ai/Structural Inventory update needed; this is another instance of the existingai/scripts/diagnostics/role.buildScripts/README.mdnow documents the command as an Agent OS diagnostic consumed by the agent lifecycle skills.Skill Load-Effect / Contract Ledger
SKILL.mdrouters are unchanged.ticket-create, one step/checkbox inepic-create, and one mandate line inpr-review.3252d87588carries[skill-growth-justified: release-cycle architecture-placement gate for #14304; retire or soften once intended-vs-actual placement lint is executable].Test Evidence
npm run test-unit -- test/playwright/unit/ai/scripts/diagnostics/structureMap.spec.mjs-> 6 passed.node ai/scripts/lint/lint-skill-manifest.mjs --base origin/dev-> OK.node --input-type=module -e 'const {buildStructureMap}=await import("./ai/scripts/diagnostics/structureMap.mjs"); const map=buildStructureMap({root:"ai", includeFiles:true, includeLoc:true}); console.log(map.root + ":" + map.folders.length);'->ai:82.git diff --check origin/dev...HEAD-> passed.Post-Merge Validation
npm run --silent ai:structure-map -- --files --locfrom a fresh checkout and confirm the output is stable for an unchanged tree.Commits
00e249fa8c—feat(ai): add deterministic structure-map generator (#14307)3252d87588—fix(ai): anchor structure map in agent workflows (#14307)