@cleocode/core 2026.4.58 → 2026.4.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/index.js +488 -11
  2. package/dist/index.js.map +3 -3
  3. package/dist/internal.js +497 -13
  4. package/dist/internal.js.map +3 -3
  5. package/dist/memory/graph-queries.d.ts.map +1 -1
  6. package/dist/store/agent-registry-accessor.d.ts +1 -1
  7. package/dist/store/brain-accessor.d.ts +57 -1
  8. package/dist/store/brain-accessor.d.ts.map +1 -1
  9. package/dist/store/brain-schema.d.ts +738 -0
  10. package/dist/store/brain-schema.d.ts.map +1 -1
  11. package/dist/store/brain-sqlite.d.ts.map +1 -1
  12. package/dist/store/nexus-schema.d.ts +1 -1
  13. package/dist/system/health.d.ts.map +1 -1
  14. package/dist/validation/doctor/checks.d.ts +7 -0
  15. package/dist/validation/doctor/checks.d.ts.map +1 -1
  16. package/migrations/drizzle-brain/20260416000001_t673-retrieval-log-plasticity-columns/migration.sql +57 -0
  17. package/migrations/drizzle-brain/20260416000002_t673-plasticity-events-expand/migration.sql +44 -0
  18. package/migrations/drizzle-brain/20260416000003_t673-page-edges-plasticity-columns/migration.sql +44 -0
  19. package/migrations/drizzle-brain/20260416000004_t673-new-plasticity-tables/migration.sql +73 -0
  20. package/package.json +8 -8
  21. package/src/memory/__tests__/brain-retrieval-m1.test.ts +250 -0
  22. package/src/memory/__tests__/brain-schema-m2-m3.test.ts +418 -0
  23. package/src/memory/__tests__/brain-schema-m4.test.ts +494 -0
  24. package/src/memory/brain-retrieval.ts +1 -1
  25. package/src/memory/graph-queries.ts +14 -0
  26. package/src/store/agent-registry-accessor.ts +1 -1
  27. package/src/store/brain-accessor.ts +120 -0
  28. package/src/store/brain-schema.ts +373 -1
  29. package/src/store/brain-sqlite.ts +123 -0
  30. package/src/system/health.ts +4 -1
  31. package/src/validation/doctor/checks.ts +107 -0
  32. package/src/validation/protocols/protocols-markdown/research.md +1 -1
@@ -667,6 +667,111 @@ export function checkLegacyAgentOutputs(projectRoot?: string): CheckResult {
667
667
  };
668
668
  }
669
669
 
670
+ // ============================================================================
671
+ // Check: Canonical RCASD Paths (ADR-045)
672
+ // ============================================================================
673
+
674
+ /**
675
+ * Validate that artifacts are at canonical RCASD paths per ADR-045.
676
+ * Detects drift: deprecated flat dirs, misplaced agent outputs, etc.
677
+ *
678
+ * @task T708 (scaffolding path drift validator)
679
+ */
680
+ export function checkCanonicalRcasdPaths(projectRoot?: string): CheckResult {
681
+ const root = projectRoot ?? process.cwd();
682
+ const cleoDir = join(root, '.cleo');
683
+ const failures: string[] = [];
684
+
685
+ // 1. Check for deprecated flat directories with content
686
+ const deprecatedDirs = ['research', 'consensus', 'specs', 'decomposition'];
687
+ for (const dir of deprecatedDirs) {
688
+ const dirPath = join(cleoDir, dir);
689
+ if (existsSync(dirPath)) {
690
+ try {
691
+ const entries = (require('node:fs').readdirSync(dirPath) as string[]).filter(
692
+ (e) => !e.startsWith('.'),
693
+ );
694
+ if (entries.length > 0) {
695
+ failures.push(
696
+ `deprecated .cleo/${dir}/ contains files (should migrate to .cleo/rcasd/{epicId}/${dir}/)`,
697
+ );
698
+ }
699
+ } catch {
700
+ // directory exists but can't read; skip
701
+ }
702
+ }
703
+ }
704
+
705
+ // 2. Check for misplaced audit files at .cleo/rcasd/ root
706
+ const rcasdPath = join(cleoDir, 'rcasd');
707
+ if (existsSync(rcasdPath)) {
708
+ try {
709
+ const rootFiles = (require('node:fs').readdirSync(rcasdPath) as string[]).filter((e) =>
710
+ e.endsWith('.md'),
711
+ );
712
+ if (rootFiles.length > 0) {
713
+ failures.push(
714
+ `misplaced .md files in .cleo/rcasd/ root (audit-*.md, etc. should be in .cleo/agent-outputs/)`,
715
+ );
716
+ }
717
+ } catch {
718
+ // directory exists but can't read; skip
719
+ }
720
+ }
721
+
722
+ // 3. Check for claudedocs legacy location
723
+ const claudedocsPath = join(root, 'claudedocs');
724
+ if (existsSync(claudedocsPath)) {
725
+ try {
726
+ const agentOutputs = join(claudedocsPath, 'agent-outputs');
727
+ if (existsSync(agentOutputs)) {
728
+ failures.push(
729
+ `legacy claudedocs/agent-outputs/ directory exists (should migrate to .cleo/agent-outputs/)`,
730
+ );
731
+ }
732
+ } catch {
733
+ // path exists but can't read; skip
734
+ }
735
+ }
736
+
737
+ // 4. Check for @see references pointing to deprecated paths in source code
738
+ // (This is a sample check; full validation should be done at lint time)
739
+ // For now, just provide guidance in the message.
740
+
741
+ if (failures.length > 0) {
742
+ return {
743
+ id: 'canonical_rcasd_paths',
744
+ category: 'configuration',
745
+ status: 'warning',
746
+ message: `Canonical path drift detected (ADR-045): ${failures.join('; ')}`,
747
+ details: {
748
+ issues: failures,
749
+ canonical: {
750
+ rcasdStages: '.cleo/rcasd/{epicId}/{stage}/{epicId}-{stage}.md',
751
+ agentOutputs: '.cleo/agent-outputs/{taskId}-{slug}.md',
752
+ publishedSpecs: 'docs/specs/SPEC-NAME.md',
753
+ },
754
+ },
755
+ fix: 'cleo upgrade (migrates old paths) or manually move files per ADR-045',
756
+ };
757
+ }
758
+
759
+ return {
760
+ id: 'canonical_rcasd_paths',
761
+ category: 'configuration',
762
+ status: 'passed',
763
+ message: 'All artifacts at canonical RCASD paths (ADR-045 compliant)',
764
+ details: {
765
+ canonical: {
766
+ rcasdStages: '.cleo/rcasd/{epicId}/{stage}/{epicId}-{stage}.md',
767
+ agentOutputs: '.cleo/agent-outputs/{taskId}-{slug}.md',
768
+ publishedSpecs: 'docs/specs/SPEC-NAME.md',
769
+ },
770
+ },
771
+ fix: null,
772
+ };
773
+ }
774
+
670
775
  // ============================================================================
671
776
  // Check: CAAMP marker integrity
672
777
  // ============================================================================
@@ -1166,6 +1271,8 @@ export function runAllGlobalChecks(cleoHome?: string, projectRoot?: string): Che
1166
1271
  checkCoreFilesNotIgnored(projectRoot),
1167
1272
  checkSqliteNotTracked(projectRoot),
1168
1273
  checkLegacyAgentOutputs(projectRoot),
1274
+ // ADR-045 canonical paths check (T708)
1275
+ checkCanonicalRcasdPaths(projectRoot),
1169
1276
  // Injection chain checks (T5153)
1170
1277
  checkCaampMarkerIntegrity(projectRoot),
1171
1278
  checkAtReferenceTargetExists(projectRoot),
@@ -43,7 +43,7 @@ This protocol activates when the task involves:
43
43
  |-------------|-------------|
44
44
  | RSCH-001 | MUST NOT implement code or make changes to codebase |
45
45
  | RSCH-002 | MUST document all sources with citations |
46
- | RSCH-003 | MUST write findings to `claudedocs/agent-outputs/` |
46
+ | RSCH-003 | MUST write findings to `.cleo/agent-outputs/` |
47
47
  | RSCH-004 | MUST append entry to `MANIFEST.jsonl` |
48
48
  | RSCH-005 | MUST return only completion message (no content in response) |
49
49
  | RSCH-006 | MUST include 3-7 key findings in manifest entry |