Authored by Claude Opus 4.7 (Claude Code). Session 5572d9a5-558d-4bea-b416-e31496c289c4.
FAIR-band: in-band [verify @ merge-gate]
Resolves #11848
Summary
Sub 12 (final) of Epic #11831 — collapses buildScripts/ai/ (19 files) into ai/scripts/<cat>/ mirroring Sub 11's thematic structure. The "build vs ai" split was historical-random; neither folder mapped to genuine build-pipeline boundaries. After this Sub, buildScripts/ai/ directory deleted entirely; buildScripts/ reverts to apps/release/util only.
Evidence: L1 (moved-spec subsuites 220/220 pass; 1995 pass / 21 pre-existing flakes on full unit; zero refs to moved files in failures) → L1 required for substrate refactor.
Source moves (19)
maintenance/ (12): backup, buildKbAgentFaqs, defragChromaDB, defragSQLiteDB, downloadKnowledgeBase, ingestTenant, kbPushClient, recreateGraphDb, restore, syncGithubWorkflow, syncKnowledgeBase, uploadKnowledgeBase
migrations/ (1): migrateMemoryCore
diagnostics/ (1): mcpHealthcheck
runners/ (4): roadmapPlanner, runAgent, runGoldenPath, runSandman
setup/ (1): initServerConfigs
buildScripts/ai/ directory removed.
Test moves (12)
Mirror source by category. One pre-existing spec util/check-chore-sync.spec.mjs tests buildScripts/util/check-chore-sync.mjs (non-AI) — left in place as out-of-scope for Sub 12.
External consumer rewrites (34 files)
Substring sweep buildScripts/ai/X.mjs → ai/scripts/<cat>/X.mjs applied to:
package.json: 16 npm script paths (ticket listed 11; actual count 16 including prepare hook + ai:sync-github-workflow + ai:sync-kb)
ai/deploy/docker-compose.yml: 2 paths
- 2 integration specs (
BackupRestoreWipe, KBBackupRestoreWipe)
ai/daemons/orchestrator/{Orchestrator,TaskDefinitions}.mjs
ai/services/knowledge-base/DatabaseService + memory-core variant
- Multiple unit specs
Manual V-B-A fixes (sweep-missed patterns)
Composite of lessons from Subs 9/10/11:
TaskDefinitions.mjs kbSync + backup args: refactored awkward path.resolve(scriptDir, '../../ai/scripts/maintenance/X') → path.join(scriptDir, 'maintenance', 'X') for consistency with Sub-11's summary pattern. Matching daemon.spec.mjs assertions updated.
laneCManualScriptLeaseAdoption.spec: refactored single scriptDir variable (was 'buildScripts/ai' literal) into per-file path map because tests span maintenance/ + runners/ categories. Updated HML import regex + substring assertions for new '../../daemons/orchestrator/services/...' source path. Added explicit Neo + core imports (latent cross-spec coupling exposed by isolated-worker location, like sweepExpiredTasks in Sub 11).
peer-architecture.spec: REPO_ROOT depth +1; regex updated from ai\/services\.mjs → \/services\.mjs (source now uses '../../services.mjs' not '.../ai/services.mjs').
restore-hardening.spec: repoRoot path.resolve depth +1.
- Doc-string updates: 19
@module buildScripts/ai/X annotations + 3 test.describe('buildScripts/ai/...') strings rewritten for new paths.
V-B-A composite lesson (logged through Subs 9/10/11/12)
Cross-cutting folder moves need ALL of:
- Substring sweep for explicit path strings in imports / regex literals
- Relative-path proximity grep for paths missing the literal source-folder segment
path.join(scriptDir, X) audit for filename-as-arg patterns that bypass substring sweeps
- Isolated-worker Neo-import check for cross-spec coupling (specs that relied on sibling-spec transitive Neo loading)
- Doc-string + describe-name cleanup for non-code references that won't break runtime but indicate stale shape-of-mind
Test Evidence
- Moved-spec subsuites (
maintenance/ + runners/ + diagnostics/ + setup/ + orchestrator/): 220/220 pass
- Full unit suite: 1995 pass / 21 fail / 2 skip / 24 did-not-run. All 21 failures verified pre-existing flakes (
Authorization, checkAllAgentIdle×2, checkSunsetted×5, resumeHarness, trioWakeCooldown, QueryReRanker, SessionSummarization, TextEmbeddingService.retry, WriteSideInvariant, grid×7, Teleportation×2); zero references to moved files in any failure.
Post-Merge Validation
Deltas from ticket
- npm scripts: ticket listed 11; actual update was 16 (also includes
prepare, ai:sync-github-workflow, ai:sync-kb)
- Doc-string updates: ticket didn't enumerate
@module annotations or test.describe strings — both updated for substrate hygiene
- TaskDefinitions cleanup: ticket didn't mandate the
path.join(scriptDir, 'maintenance', X) refactor but I applied it for consistency with Sub-11's summary pattern. Functionally equivalent to the awkward path.resolve(scriptDir, '../../ai/scripts/maintenance/X') form, cleaner to read.
Depends on
Closes Epic
After this Sub merges, Epic #11831 is complete. Folder structure:
ai/daemons/orchestrator/ — masterclass refactor + cluster co-location (Subs 1/8)
ai/daemons/{bridge,kb-alerting,kb-gc,kb-reconciliation}/ — per-daemon co-location (Sub 9)
ai/services/{graph,ingestion}/ — cross-daemon services bucket (Sub 10)
ai/scripts/{lifecycle,migrations,diagnostics,setup,lint,maintenance,runners}/ — thematic split (Subs 11/12)
buildScripts/ — genuine build-pipeline only
Per @tobiu's "you and me" instruction: no peer-review broadcast on this lane.
Authored by Claude Opus 4.7 (Claude Code). Session 5572d9a5-558d-4bea-b416-e31496c289c4.
FAIR-band: in-band [verify @ merge-gate]
Resolves #11848
Summary
Sub 12 (final) of Epic #11831 — collapses
buildScripts/ai/(19 files) intoai/scripts/<cat>/mirroring Sub 11's thematic structure. The "build vs ai" split was historical-random; neither folder mapped to genuine build-pipeline boundaries. After this Sub,buildScripts/ai/directory deleted entirely;buildScripts/reverts to apps/release/util only.Evidence: L1 (moved-spec subsuites 220/220 pass; 1995 pass / 21 pre-existing flakes on full unit; zero refs to moved files in failures) → L1 required for substrate refactor.
Source moves (19)
maintenance/(12):backup,buildKbAgentFaqs,defragChromaDB,defragSQLiteDB,downloadKnowledgeBase,ingestTenant,kbPushClient,recreateGraphDb,restore,syncGithubWorkflow,syncKnowledgeBase,uploadKnowledgeBasemigrations/(1):migrateMemoryCorediagnostics/(1):mcpHealthcheckrunners/(4):roadmapPlanner,runAgent,runGoldenPath,runSandmansetup/(1):initServerConfigsbuildScripts/ai/directory removed.Test moves (12)
Mirror source by category. One pre-existing spec
util/check-chore-sync.spec.mjstestsbuildScripts/util/check-chore-sync.mjs(non-AI) — left in place as out-of-scope for Sub 12.External consumer rewrites (34 files)
Substring sweep
buildScripts/ai/X.mjs→ai/scripts/<cat>/X.mjsapplied to:package.json: 16 npm script paths (ticket listed 11; actual count 16 includingpreparehook +ai:sync-github-workflow+ai:sync-kb)ai/deploy/docker-compose.yml: 2 pathsBackupRestoreWipe,KBBackupRestoreWipe)ai/daemons/orchestrator/{Orchestrator,TaskDefinitions}.mjsai/services/knowledge-base/DatabaseService+ memory-core variantManual V-B-A fixes (sweep-missed patterns)
Composite of lessons from Subs 9/10/11:
TaskDefinitions.mjskbSync + backup args: refactored awkwardpath.resolve(scriptDir, '../../ai/scripts/maintenance/X')→path.join(scriptDir, 'maintenance', 'X')for consistency with Sub-11'ssummarypattern. Matchingdaemon.spec.mjsassertions updated.laneCManualScriptLeaseAdoption.spec: refactored singlescriptDirvariable (was'buildScripts/ai'literal) into per-file path map because tests spanmaintenance/+runners/categories. Updated HML import regex + substring assertions for new'../../daemons/orchestrator/services/...'source path. Added explicit Neo + core imports (latent cross-spec coupling exposed by isolated-worker location, like sweepExpiredTasks in Sub 11).peer-architecture.spec: REPO_ROOT depth +1; regex updated fromai\/services\.mjs→\/services\.mjs(source now uses'../../services.mjs'not'.../ai/services.mjs').restore-hardening.spec: repoRootpath.resolvedepth +1.@module buildScripts/ai/Xannotations + 3test.describe('buildScripts/ai/...')strings rewritten for new paths.V-B-A composite lesson (logged through Subs 9/10/11/12)
Cross-cutting folder moves need ALL of:
path.join(scriptDir, X)audit for filename-as-arg patterns that bypass substring sweepsTest Evidence
maintenance/+runners/+diagnostics/+setup/+orchestrator/): 220/220 passAuthorization,checkAllAgentIdle×2,checkSunsetted×5,resumeHarness,trioWakeCooldown,QueryReRanker,SessionSummarization,TextEmbeddingService.retry,WriteSideInvariant, grid×7,Teleportation×2); zero references to moved files in any failure.Post-Merge Validation
npm run ai:backup/ai:restore/ai:sync-kbetc. (16 npm scripts touched) — verify entry paths resolveai/scripts/maintenance/pathsai/scripts/maintenance/initServerConfigs.mjspathDeltas from ticket
prepare,ai:sync-github-workflow,ai:sync-kb)@moduleannotations ortest.describestrings — both updated for substrate hygienepath.join(scriptDir, 'maintenance', X)refactor but I applied it for consistency with Sub-11's summary pattern. Functionally equivalent to the awkwardpath.resolve(scriptDir, '../../ai/scripts/maintenance/X')form, cleaner to read.Depends on
Closes Epic
After this Sub merges, Epic #11831 is complete. Folder structure:
ai/daemons/orchestrator/— masterclass refactor + cluster co-location (Subs 1/8)ai/daemons/{bridge,kb-alerting,kb-gc,kb-reconciliation}/— per-daemon co-location (Sub 9)ai/services/{graph,ingestion}/— cross-daemon services bucket (Sub 10)ai/scripts/{lifecycle,migrations,diagnostics,setup,lint,maintenance,runners}/— thematic split (Subs 11/12)buildScripts/— genuine build-pipeline onlyPer @tobiu's "you and me" instruction: no peer-review broadcast on this lane.