LearnNewsExamplesServices
Frontmatter
id14307
titleArchitecture structure-map generator — committable JSON current-map
stateClosed
labels
enhancementaiarchitecture
assigneesneo-gpt
createdAtJun 28, 2026, 11:36 PM
updatedAtJul 2, 2026, 8:20 AM
githubUrlhttps://github.com/neomjs/neo/issues/14307
authorneo-opus-grace
commentsCount2
parentIssue14304
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtJul 2, 2026, 8:20 AM

Architecture structure-map generator — committable JSON current-map

Closed v13.1.0/archive-v13-1-0-chunk-7 enhancementaiarchitecture
neo-opus-grace
neo-opus-grace commented on Jun 28, 2026, 11:36 PM

Context

Operator-directed (@tobiu) — the first concrete artifact of the v13.2 architecture program (#14304), and its cheapest high-leverage piece. The Brain's structure is a stale 2/10 snapshot (per #14304); the cheapest first heal is a generated current-map: always-accurate (vs rotted hand-docs — DreamPipeline.md cites ai/daemons/DreamService.mjs, a path that does not exist), standalone-useful for onboarding (the "where's the code?" reaction), and the baseline both the migration (Lane 1) and the immune-system lint (Lane 2) consume.

The operator's bar: we will not get the architecture 100% right; 80–90% + continuous iteration is the win — which is why this tooling matters. It makes the iteration cheap and visible: generate → enforce → iterate.

Precedent (V-B-A'd): #12247 (CLOSED) already lints learn/tree.json against the learn/ folder tree — the same generate-vs-declared shape, proven. This applies it to ai/.

The Problem

The folder structure is invisible — no one scans it before placing files (the V-B-A'd root cause of the rot: diagnostics/recovery/Dream all misplaced because no one looked). Hand-maintained structure docs rot. There is no always-accurate, machine-readable map of "what's where."

The Architectural Reality

  • The map is generated from the live tree (always accurate), never hand-written.
  • It is a pure generator — emit the current structure; the intended-vs-actual comparison is a downstream consumer (the Lane-2 lint + the enforcement).
  • Placement: it is operator/CI tooling about ai/, so buildScripts/ai/ (next to the other build tools) — NOT inside ai/ (the inspector must not live inside the inspected).
  • CLI convention V-B-A'd: commander is already a package.json dep + the buildScripts/ standard (build/all, create/addConfig) — use it; no new dep.
  • Dual-use: Lane 1 (migration before/after baseline) + Lane 2 (immune-system generator-half).

The Fix

A commander CLI under buildScripts/ai/ that walks a configurable root (default ai/) and emits deterministic, sorted JSON of the folder structure:

  • Default: per-folder { path, fileCount }.
  • --files: include file names.
  • --loc: include lines-per-file — prefer code-LOC (excluding comments) per the cohesion-budget principle (counts catch folder-bloat > 7; LOC catches file-bloat like the 2,476-line services/graph "helper"; together = the cohesion/size budget).
  • Output sorted/stable → committable + cleanly diffable (the diff is the drift signal on a PR).

Designed-for-enforcement (the trajectory — not this ticket's deliverable)

This tool is built to be enforced downstream (operator's vision): a "what-belongs-where" sanity-check at ticket-work time + a placement check at PR-review time, both consuming this JSON + the forthcoming intended-SSOT (Lane 0 / #14304). Those enforcement integrations are follow-on tickets (they require the intended-SSOT to exist); this ticket delivers the standalone generator they will consume.

Acceptance Criteria

  • A commander CLI under buildScripts/ai/ (per the existing buildScripts/ convention) emits deterministic, sorted JSON of the folder structure (per-folder {path, fileCount}) for a configurable root (default ai/).
  • --files includes file names; --loc includes LOC per file (prefer code-LOC excluding comments).
  • Output is deterministic (sorted) → two runs on an unchanged tree are byte-identical (committable + diffable).
  • Pure generator (no intended-vs-actual comparison); documented as the input for the future Lane-2 lint + ticket-work / PR-review enforcement.
  • An ai:structure-map npm script + a one-line usage doc.

Out of Scope

  • The intended-SSOT / declared placement map (Lane 0 / #14304).
  • The enforcement integrations (ticket-work sanity-check, PR-review placement-check) — follow-on; they need the intended-SSOT.
  • The actual migration (Lane 1) — this is its baseline tool, not the migration.

Avoided Traps

  • Hand-written map: rejected — it rots (DreamPipeline.md proves it). Generate it.
  • Non-deterministic output: rejected — kills the diff-as-drift-signal; sort everything.
  • Baking in the intended-comparison: rejected — keep it a pure generator (one job, composable); the lint is a separate consumer.
  • Placing it in ai/: rejected — it is tooling about ai/, so buildScripts/ai/.

Related

#14304 (v13.2 architecture epic — parent) · #14305 (Lane-2 immune-system sandbox — the consumer) · #14302 (Lane-1 structure sandbox — the migration baseline) · #12247 (the learn/tree.json lint precedent) · learn/agentos/DreamPipeline.md (the rotted-doc anchor).

Live latest-open sweep: checked at creation; no equivalent structure-tooling ticket exists (#12247 precedent is CLOSED + scoped to learn/).

Origin Session ID: f4454a29-afc5-4897-a66c-a8c2c9460d55

Handoff Retrieval Hints: "folder-structure map generator committable JSON buildScripts/ai"; "architecture current-map counts loc deterministic diff drift-signal".

Authored by Grace (@neo-opus-grace, Claude Opus 4.8). Operator-directed; Euclid-buildable.

tobiu referenced in commit 5a73675 - "feat(ai): add deterministic structure-map generator (#14307) (#14390) on Jul 2, 2026, 8:20 AM
tobiu closed this issue on Jul 2, 2026, 8:20 AM