@codeledger/engine 0.7.0

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 (129) hide show
  1. package/dist/ccs/index.d.ts +11 -0
  2. package/dist/ccs/index.d.ts.map +1 -0
  3. package/dist/ccs/index.js +10 -0
  4. package/dist/ccs/index.js.map +1 -0
  5. package/dist/ccs/score.d.ts +61 -0
  6. package/dist/ccs/score.d.ts.map +1 -0
  7. package/dist/ccs/score.js +250 -0
  8. package/dist/ccs/score.js.map +1 -0
  9. package/dist/ecl/index.d.ts +9 -0
  10. package/dist/ecl/index.d.ts.map +1 -0
  11. package/dist/ecl/index.js +9 -0
  12. package/dist/ecl/index.js.map +1 -0
  13. package/dist/ecl/ledger.d.ts +84 -0
  14. package/dist/ecl/ledger.d.ts.map +1 -0
  15. package/dist/ecl/ledger.js +235 -0
  16. package/dist/ecl/ledger.js.map +1 -0
  17. package/dist/index.d.ts +54 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +56 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/iole/expansion-ladder.d.ts +51 -0
  22. package/dist/iole/expansion-ladder.d.ts.map +1 -0
  23. package/dist/iole/expansion-ladder.js +153 -0
  24. package/dist/iole/expansion-ladder.js.map +1 -0
  25. package/dist/iole/failure-vector.d.ts +21 -0
  26. package/dist/iole/failure-vector.d.ts.map +1 -0
  27. package/dist/iole/failure-vector.js +156 -0
  28. package/dist/iole/failure-vector.js.map +1 -0
  29. package/dist/iole/index.d.ts +19 -0
  30. package/dist/iole/index.d.ts.map +1 -0
  31. package/dist/iole/index.js +17 -0
  32. package/dist/iole/index.js.map +1 -0
  33. package/dist/iole/intent-decomposition.d.ts +33 -0
  34. package/dist/iole/intent-decomposition.d.ts.map +1 -0
  35. package/dist/iole/intent-decomposition.js +252 -0
  36. package/dist/iole/intent-decomposition.js.map +1 -0
  37. package/dist/iole/intent-signature.d.ts +37 -0
  38. package/dist/iole/intent-signature.d.ts.map +1 -0
  39. package/dist/iole/intent-signature.js +112 -0
  40. package/dist/iole/intent-signature.js.map +1 -0
  41. package/dist/iole/outcome-score.d.ts +25 -0
  42. package/dist/iole/outcome-score.d.ts.map +1 -0
  43. package/dist/iole/outcome-score.js +128 -0
  44. package/dist/iole/outcome-score.js.map +1 -0
  45. package/dist/isc/index.d.ts +8 -0
  46. package/dist/isc/index.d.ts.map +1 -0
  47. package/dist/isc/index.js +8 -0
  48. package/dist/isc/index.js.map +1 -0
  49. package/dist/isc/score.d.ts +27 -0
  50. package/dist/isc/score.d.ts.map +1 -0
  51. package/dist/isc/score.js +347 -0
  52. package/dist/isc/score.js.map +1 -0
  53. package/dist/license/index.d.ts +14 -0
  54. package/dist/license/index.d.ts.map +1 -0
  55. package/dist/license/index.js +11 -0
  56. package/dist/license/index.js.map +1 -0
  57. package/dist/license/parse.d.ts +42 -0
  58. package/dist/license/parse.d.ts.map +1 -0
  59. package/dist/license/parse.js +106 -0
  60. package/dist/license/parse.js.map +1 -0
  61. package/dist/license/publicKey.d.ts +37 -0
  62. package/dist/license/publicKey.d.ts.map +1 -0
  63. package/dist/license/publicKey.js +48 -0
  64. package/dist/license/publicKey.js.map +1 -0
  65. package/dist/license/verify.d.ts +33 -0
  66. package/dist/license/verify.d.ts.map +1 -0
  67. package/dist/license/verify.js +82 -0
  68. package/dist/license/verify.js.map +1 -0
  69. package/dist/orchestrator/index.d.ts +10 -0
  70. package/dist/orchestrator/index.d.ts.map +1 -0
  71. package/dist/orchestrator/index.js +10 -0
  72. package/dist/orchestrator/index.js.map +1 -0
  73. package/dist/orchestrator/orchestrator.d.ts +44 -0
  74. package/dist/orchestrator/orchestrator.d.ts.map +1 -0
  75. package/dist/orchestrator/orchestrator.js +182 -0
  76. package/dist/orchestrator/orchestrator.js.map +1 -0
  77. package/dist/policy-sim/index.d.ts +8 -0
  78. package/dist/policy-sim/index.d.ts.map +1 -0
  79. package/dist/policy-sim/index.js +8 -0
  80. package/dist/policy-sim/index.js.map +1 -0
  81. package/dist/policy-sim/simulate.d.ts +18 -0
  82. package/dist/policy-sim/simulate.d.ts.map +1 -0
  83. package/dist/policy-sim/simulate.js +61 -0
  84. package/dist/policy-sim/simulate.js.map +1 -0
  85. package/dist/provenance/graph.d.ts +42 -0
  86. package/dist/provenance/graph.d.ts.map +1 -0
  87. package/dist/provenance/graph.js +139 -0
  88. package/dist/provenance/graph.js.map +1 -0
  89. package/dist/provenance/index.d.ts +8 -0
  90. package/dist/provenance/index.d.ts.map +1 -0
  91. package/dist/provenance/index.js +8 -0
  92. package/dist/provenance/index.js.map +1 -0
  93. package/dist/sce/index.d.ts +15 -0
  94. package/dist/sce/index.d.ts.map +1 -0
  95. package/dist/sce/index.js +14 -0
  96. package/dist/sce/index.js.map +1 -0
  97. package/dist/sce/slice-builder.d.ts +35 -0
  98. package/dist/sce/slice-builder.d.ts.map +1 -0
  99. package/dist/sce/slice-builder.js +198 -0
  100. package/dist/sce/slice-builder.js.map +1 -0
  101. package/dist/sce/symbol-graph.d.ts +21 -0
  102. package/dist/sce/symbol-graph.d.ts.map +1 -0
  103. package/dist/sce/symbol-graph.js +187 -0
  104. package/dist/sce/symbol-graph.js.map +1 -0
  105. package/dist/team-ledger/index.d.ts +8 -0
  106. package/dist/team-ledger/index.d.ts.map +1 -0
  107. package/dist/team-ledger/index.js +8 -0
  108. package/dist/team-ledger/index.js.map +1 -0
  109. package/dist/team-ledger/ledger.d.ts +48 -0
  110. package/dist/team-ledger/ledger.d.ts.map +1 -0
  111. package/dist/team-ledger/ledger.js +208 -0
  112. package/dist/team-ledger/ledger.js.map +1 -0
  113. package/dist/team-metrics/index.d.ts +8 -0
  114. package/dist/team-metrics/index.d.ts.map +1 -0
  115. package/dist/team-metrics/index.js +8 -0
  116. package/dist/team-metrics/index.js.map +1 -0
  117. package/dist/team-metrics/metrics.d.ts +42 -0
  118. package/dist/team-metrics/metrics.d.ts.map +1 -0
  119. package/dist/team-metrics/metrics.js +156 -0
  120. package/dist/team-metrics/metrics.js.map +1 -0
  121. package/dist/team-policy/index.d.ts +8 -0
  122. package/dist/team-policy/index.d.ts.map +1 -0
  123. package/dist/team-policy/index.js +8 -0
  124. package/dist/team-policy/index.js.map +1 -0
  125. package/dist/team-policy/policy.d.ts +35 -0
  126. package/dist/team-policy/policy.d.ts.map +1 -0
  127. package/dist/team-policy/policy.js +100 -0
  128. package/dist/team-policy/policy.js.map +1 -0
  129. package/package.json +49 -0
@@ -0,0 +1,187 @@
1
+ /**
2
+ * SCE — Symbol Graph
3
+ *
4
+ * Extracts a symbol-level dependency graph from TypeScript source files
5
+ * using regex-based AST approximation (no external parser dependencies).
6
+ *
7
+ * Deterministic: same input → same output. No randomness, no embeddings.
8
+ */
9
+ import { readFileSync } from 'fs';
10
+ // ─── Extraction Patterns ─────────────────────────────────────────────────────
11
+ const PATTERNS = [
12
+ // exported function declarations
13
+ { kind: 'function', re: /^export\s+(?:async\s+)?function\s+(\w+)/m },
14
+ // exported arrow functions (export const foo = ...)
15
+ { kind: 'function', re: /^export\s+const\s+(\w+)\s*=\s*(?:async\s*)?\(/m },
16
+ // exported classes
17
+ { kind: 'class', re: /^export\s+(?:abstract\s+)?class\s+(\w+)/m },
18
+ // exported interfaces
19
+ { kind: 'interface', re: /^export\s+interface\s+(\w+)/m },
20
+ // exported type aliases
21
+ { kind: 'type', re: /^export\s+type\s+(\w+)\s*=/m },
22
+ // exported enums
23
+ { kind: 'enum', re: /^export\s+(?:const\s+)?enum\s+(\w+)/m },
24
+ // re-exports with rename: export { foo as Bar }
25
+ { kind: 'function', re: /^export\s+\{[^}]*\}/m },
26
+ // default export (named function/class)
27
+ { kind: 'function', re: /^export\s+default\s+(?:async\s+)?function\s+(\w+)/m },
28
+ { kind: 'class', re: /^export\s+default\s+class\s+(\w+)/m },
29
+ ];
30
+ // Import patterns
31
+ const IMPORT_RE = /^import\s+(?:type\s+)?(?:\{[^}]+\}|\w+|\*\s+as\s+\w+)(?:\s*,\s*(?:\{[^}]+\}|\w+))*\s+from\s+['"]([^'"]+)['"]/mg;
32
+ const REQUIRE_RE = /require\(['"]([^'"]+)['"]\)/g;
33
+ // ─── Public API ───────────────────────────────────────────────────────────────
34
+ /**
35
+ * Extract a SymbolGraph from a set of source file paths.
36
+ *
37
+ * Each node represents a named exported symbol. Edges track which symbols
38
+ * import (and thus depend on) symbols from other files.
39
+ */
40
+ export function buildSymbolGraph(filePaths) {
41
+ const nodes = new Map();
42
+ const fileSymbols = new Map(); // path → exported symbol names
43
+ // Pass 1: extract symbols from each file
44
+ for (const filePath of filePaths) {
45
+ let src;
46
+ try {
47
+ src = readFileSync(filePath, 'utf8');
48
+ }
49
+ catch {
50
+ continue;
51
+ }
52
+ const symbols = extractSymbols(filePath, src);
53
+ fileSymbols.set(filePath, symbols.map((s) => s.name));
54
+ for (const sym of symbols) {
55
+ const id = nodeId(filePath, sym.name);
56
+ nodes.set(id, sym);
57
+ }
58
+ }
59
+ // Pass 2: build import edges
60
+ for (const filePath of filePaths) {
61
+ let src;
62
+ try {
63
+ src = readFileSync(filePath, 'utf8');
64
+ }
65
+ catch {
66
+ continue;
67
+ }
68
+ const importedPaths = extractImportPaths(src);
69
+ for (const importPath of importedPaths) {
70
+ // Resolve relative import to an absolute path (best-effort)
71
+ const resolved = resolveImport(filePath, importPath, filePaths);
72
+ if (!resolved)
73
+ continue;
74
+ const importedSyms = fileSymbols.get(resolved) ?? [];
75
+ const localSyms = fileSymbols.get(filePath) ?? [];
76
+ // Add edges: every local symbol depends on every imported symbol
77
+ // (conservative; proper AST would give exact bindings)
78
+ for (const localSym of localSyms) {
79
+ const localId = nodeId(filePath, localSym);
80
+ const node = nodes.get(localId);
81
+ if (!node)
82
+ continue;
83
+ for (const importedSym of importedSyms) {
84
+ const importedId = nodeId(resolved, importedSym);
85
+ if (!node.dependencies.includes(importedId)) {
86
+ node.dependencies.push(importedId);
87
+ }
88
+ }
89
+ }
90
+ }
91
+ }
92
+ return {
93
+ nodes: Object.fromEntries(nodes),
94
+ file_count: filePaths.length,
95
+ symbol_count: nodes.size,
96
+ };
97
+ }
98
+ /**
99
+ * Extract all exported symbols from a TypeScript source file.
100
+ */
101
+ export function extractSymbols(filePath, src) {
102
+ const symbols = [];
103
+ const seen = new Set();
104
+ // Line-by-line scan for multi-match patterns
105
+ const lines = src.split('\n');
106
+ for (let i = 0; i < lines.length; i++) {
107
+ const line = lines[i] ?? '';
108
+ for (const { kind, re } of PATTERNS) {
109
+ // Build per-line regex (remove the /m flag)
110
+ const lineRe = new RegExp(re.source);
111
+ const m = lineRe.exec(line);
112
+ if (m) {
113
+ const name = m[1];
114
+ if (name && !seen.has(name)) {
115
+ seen.add(name);
116
+ symbols.push({
117
+ id: nodeId(filePath, name),
118
+ name,
119
+ kind,
120
+ file: filePath,
121
+ line: i + 1,
122
+ dependencies: [],
123
+ dependents: [],
124
+ });
125
+ }
126
+ }
127
+ }
128
+ }
129
+ return symbols;
130
+ }
131
+ // ─── Helpers ──────────────────────────────────────────────────────────────────
132
+ function nodeId(filePath, symbolName) {
133
+ return `${filePath}::${symbolName}`;
134
+ }
135
+ function extractImportPaths(src) {
136
+ const paths = [];
137
+ let m;
138
+ const importRe = new RegExp(IMPORT_RE.source, 'mg');
139
+ while ((m = importRe.exec(src)) !== null) {
140
+ if (m[1])
141
+ paths.push(m[1]);
142
+ }
143
+ const requireRe = new RegExp(REQUIRE_RE.source, 'g');
144
+ while ((m = requireRe.exec(src)) !== null) {
145
+ if (m[1])
146
+ paths.push(m[1]);
147
+ }
148
+ return paths;
149
+ }
150
+ /**
151
+ * Resolve a relative import specifier to an absolute path from the known file list.
152
+ * Returns null if the import is external (node_modules) or unresolvable.
153
+ */
154
+ function resolveImport(fromFile, importSpec, knownFiles) {
155
+ if (!importSpec.startsWith('.'))
156
+ return null;
157
+ const fromDir = fromFile.replace(/\/[^/]+$/, '');
158
+ // Normalize: strip trailing .js (ESM convention)
159
+ const base = importSpec.replace(/\.js$/, '');
160
+ const candidates = [
161
+ `${fromDir}/${base}.ts`,
162
+ `${fromDir}/${base}.tsx`,
163
+ `${fromDir}/${base}/index.ts`,
164
+ `${fromDir}/${base}`,
165
+ ];
166
+ for (const candidate of candidates) {
167
+ // Normalize path separators and double-dots
168
+ const normalized = normalizePath(candidate);
169
+ if (knownFiles.includes(normalized))
170
+ return normalized;
171
+ }
172
+ return null;
173
+ }
174
+ function normalizePath(p) {
175
+ const parts = p.split('/');
176
+ const resolved = [];
177
+ for (const part of parts) {
178
+ if (part === '..') {
179
+ resolved.pop();
180
+ }
181
+ else if (part !== '.') {
182
+ resolved.push(part);
183
+ }
184
+ }
185
+ return resolved.join('/');
186
+ }
187
+ //# sourceMappingURL=symbol-graph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"symbol-graph.js","sourceRoot":"","sources":["../../src/sce/symbol-graph.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAGlC,gFAAgF;AAEhF,MAAM,QAAQ,GAA4C;IACxD,iCAAiC;IACjC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,0CAA0C,EAAE;IACpE,qDAAqD;IACrD,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,gDAAgD,EAAE;IAC1E,mBAAmB;IACnB,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,0CAA0C,EAAE;IACjE,sBAAsB;IACtB,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,8BAA8B,EAAE;IACzD,wBAAwB;IACxB,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,6BAA6B,EAAE;IACnD,iBAAiB;IACjB,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,sCAAsC,EAAE;IAC5D,gDAAgD;IAChD,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,sBAAsB,EAAE;IAChD,wCAAwC;IACxC,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,E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A4C;QAC5C,MAAM,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;QAC5C,IAAI,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC;YAAE,OAAO,UAAU,CAAC;IACzD,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,aAAa,CAAC,CAAS;IAC9B,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3B,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClB,QAAQ,CAAC,GAAG,EAAE,CAAC;QACjB,CAAC;aAAM,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACxB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Team Shared Context Ledger
3
+ *
4
+ * Allows teams to compound learning across developers. Append-only,
5
+ * deterministic merge with dedup by (intentCategory + contextHash).
6
+ */
7
+ export { teamLedgerPath, recordTeamEntry, loadTeamEntries, buildTeamWeightIndex, buildTeamHotspots, teamLedgerStatus, syncFromEcl, TEAM_LEDGER_DIR, } from './ledger.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/team-ledger/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,cAAc,EACd,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,eAAe,GAChB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Team Shared Context Ledger
3
+ *
4
+ * Allows teams to compound learning across developers. Append-only,
5
+ * deterministic merge with dedup by (intentCategory + contextHash).
6
+ */
7
+ export { teamLedgerPath, recordTeamEntry, loadTeamEntries, buildTeamWeightIndex, buildTeamHotspots, teamLedgerStatus, syncFromEcl, TEAM_LEDGER_DIR, } from './ledger.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/team-ledger/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,cAAc,EACd,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,eAAe,GAChB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Team Shared Context Ledger — Implementation
3
+ *
4
+ * Storage: .codeledger/team-ledger/
5
+ * - entries.jsonl (append-only team entries)
6
+ * - weights.json (aggregated weight index)
7
+ * - hotspots.json (failure hotspot index)
8
+ *
9
+ * Merge rules:
10
+ * - Append-only
11
+ * - Deduplicate by (intentCategory + contextHash)
12
+ * - Maintain counts (successWeight, failureWeight)
13
+ *
14
+ * Deterministic: integer weights only, no floats in the index.
15
+ */
16
+ import type { TeamLedgerEntry, TeamWeightEntry, TeamHotspot, TeamLedgerStatus, EclLiteEntry } from '@codeledger/types';
17
+ export declare const TEAM_LEDGER_DIR = "team-ledger";
18
+ export declare function teamLedgerPath(repoRoot: string): string;
19
+ /**
20
+ * Append a new entry to the team ledger.
21
+ * Creates the directory structure if it doesn't exist.
22
+ */
23
+ export declare function recordTeamEntry(repoRoot: string, entry: TeamLedgerEntry): void;
24
+ /**
25
+ * Load all entries from the team ledger.
26
+ * Returns empty array if the ledger doesn't exist.
27
+ */
28
+ export declare function loadTeamEntries(repoRoot: string): TeamLedgerEntry[];
29
+ /**
30
+ * Build and persist the team weight index from entries.
31
+ * Deduplicates by (intentCategory + contextHash), maintaining counts.
32
+ */
33
+ export declare function buildTeamWeightIndex(repoRoot: string): TeamWeightEntry[];
34
+ /**
35
+ * Build and persist team-level failure hotspots.
36
+ * Aggregates across all team entries.
37
+ */
38
+ export declare function buildTeamHotspots(repoRoot: string): TeamHotspot[];
39
+ /**
40
+ * Compute team ledger status summary.
41
+ */
42
+ export declare function teamLedgerStatus(repoRoot: string): TeamLedgerStatus;
43
+ /**
44
+ * Sync local ECL-Lite entries into the team ledger.
45
+ * Deduplicates by (intentCategory + contextHash) — only appends new entries.
46
+ */
47
+ export declare function syncFromEcl(repoRoot: string, eclEntries: EclLiteEntry[], actor?: string): number;
48
+ //# sourceMappingURL=ledger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../../src/team-ledger/ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,YAAY,EAEb,MAAM,mBAAmB,CAAC;AAI3B,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAO7C,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAEvD;AAgBD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,eAAe,GAAG,IAAI,CAI9E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,EAAE,CAcnE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,EAAE,CAyBxE;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW,EAAE,CA4CjE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,CAqBnE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAqChG"}
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Team Shared Context Ledger — Implementation
3
+ *
4
+ * Storage: .codeledger/team-ledger/
5
+ * - entries.jsonl (append-only team entries)
6
+ * - weights.json (aggregated weight index)
7
+ * - hotspots.json (failure hotspot index)
8
+ *
9
+ * Merge rules:
10
+ * - Append-only
11
+ * - Deduplicate by (intentCategory + contextHash)
12
+ * - Maintain counts (successWeight, failureWeight)
13
+ *
14
+ * Deterministic: integer weights only, no floats in the index.
15
+ */
16
+ import { readFileSync, writeFileSync, appendFileSync, existsSync, mkdirSync } from 'fs';
17
+ import { join, dirname } from 'path';
18
+ import { createHash } from 'crypto';
19
+ // ─── Constants ────────────────────────────────────────────────────────────────
20
+ export const TEAM_LEDGER_DIR = 'team-ledger';
21
+ const ENTRIES_FILE = 'entries.jsonl';
22
+ const WEIGHTS_FILE = 'weights.json';
23
+ const HOTSPOTS_FILE = 'hotspots.json';
24
+ // ─── Paths ────────────────────────────────────────────────────────────────────
25
+ export function teamLedgerPath(repoRoot) {
26
+ return join(repoRoot, '.codeledger', TEAM_LEDGER_DIR);
27
+ }
28
+ function entriesPath(repoRoot) {
29
+ return join(teamLedgerPath(repoRoot), ENTRIES_FILE);
30
+ }
31
+ function weightsPath(repoRoot) {
32
+ return join(teamLedgerPath(repoRoot), WEIGHTS_FILE);
33
+ }
34
+ function hotspotsPath(repoRoot) {
35
+ return join(teamLedgerPath(repoRoot), HOTSPOTS_FILE);
36
+ }
37
+ // ─── Public API ───────────────────────────────────────────────────────────────
38
+ /**
39
+ * Append a new entry to the team ledger.
40
+ * Creates the directory structure if it doesn't exist.
41
+ */
42
+ export function recordTeamEntry(repoRoot, entry) {
43
+ const path = entriesPath(repoRoot);
44
+ ensureDir(dirname(path));
45
+ appendFileSync(path, JSON.stringify(entry) + '\n', 'utf-8');
46
+ }
47
+ /**
48
+ * Load all entries from the team ledger.
49
+ * Returns empty array if the ledger doesn't exist.
50
+ */
51
+ export function loadTeamEntries(repoRoot) {
52
+ const path = entriesPath(repoRoot);
53
+ if (!existsSync(path))
54
+ return [];
55
+ const lines = readFileSync(path, 'utf-8').split('\n').filter((l) => l.trim());
56
+ const entries = [];
57
+ for (const line of lines) {
58
+ try {
59
+ entries.push(JSON.parse(line));
60
+ }
61
+ catch {
62
+ // Skip malformed lines
63
+ }
64
+ }
65
+ return entries;
66
+ }
67
+ /**
68
+ * Build and persist the team weight index from entries.
69
+ * Deduplicates by (intentCategory + contextHash), maintaining counts.
70
+ */
71
+ export function buildTeamWeightIndex(repoRoot) {
72
+ const entries = loadTeamEntries(repoRoot);
73
+ const index = new Map();
74
+ for (const entry of entries) {
75
+ const key = `${entry.intentCategory}:${entry.contextHash}`;
76
+ const existing = index.get(key) ?? {
77
+ intentCategory: entry.intentCategory,
78
+ contextHash: entry.contextHash,
79
+ successWeight: 0,
80
+ failureWeight: 0,
81
+ lastUpdated: 0,
82
+ };
83
+ existing.successWeight += entry.successWeight;
84
+ existing.failureWeight += entry.failureWeight;
85
+ existing.lastUpdated = Math.max(existing.lastUpdated, entry.timestamp);
86
+ index.set(key, existing);
87
+ }
88
+ const weights = Array.from(index.values());
89
+ const wp = weightsPath(repoRoot);
90
+ ensureDir(dirname(wp));
91
+ writeFileSync(wp, JSON.stringify(weights, null, 2), 'utf-8');
92
+ return weights;
93
+ }
94
+ /**
95
+ * Build and persist team-level failure hotspots.
96
+ * Aggregates across all team entries.
97
+ */
98
+ export function buildTeamHotspots(repoRoot) {
99
+ const entries = loadTeamEntries(repoRoot);
100
+ const failCounts = new Map();
101
+ const successCounts = new Map();
102
+ const lastFailTs = new Map();
103
+ const actorSets = new Map();
104
+ for (const entry of entries) {
105
+ const actor = entry.actor ?? 'unknown';
106
+ if (entry.outcome === 'failure') {
107
+ for (const f of entry.files) {
108
+ failCounts.set(f, (failCounts.get(f) ?? 0) + 1);
109
+ const prev = lastFailTs.get(f) ?? 0;
110
+ if (entry.timestamp > prev)
111
+ lastFailTs.set(f, entry.timestamp);
112
+ const actors = actorSets.get(f) ?? new Set();
113
+ actors.add(actor);
114
+ actorSets.set(f, actors);
115
+ }
116
+ }
117
+ else {
118
+ for (const f of entry.files) {
119
+ successCounts.set(f, (successCounts.get(f) ?? 0) + 1);
120
+ }
121
+ }
122
+ }
123
+ const hotspots = [];
124
+ for (const [file, failureCount] of failCounts) {
125
+ const successCount = successCounts.get(file) ?? 0;
126
+ const total = failureCount + successCount;
127
+ hotspots.push({
128
+ file,
129
+ failureCount,
130
+ successCount,
131
+ implicationRate: total > 0 ? failureCount / total : 0,
132
+ lastFailureTimestamp: lastFailTs.get(file) ?? 0,
133
+ actorCount: actorSets.get(file)?.size ?? 0,
134
+ });
135
+ }
136
+ const sorted = hotspots.sort((a, b) => b.implicationRate - a.implicationRate);
137
+ const hp = hotspotsPath(repoRoot);
138
+ ensureDir(dirname(hp));
139
+ writeFileSync(hp, JSON.stringify(sorted, null, 2), 'utf-8');
140
+ return sorted;
141
+ }
142
+ /**
143
+ * Compute team ledger status summary.
144
+ */
145
+ export function teamLedgerStatus(repoRoot) {
146
+ const entries = loadTeamEntries(repoRoot);
147
+ const successes = entries.filter((e) => e.outcome === 'success').length;
148
+ const failures = entries.filter((e) => e.outcome === 'failure').length;
149
+ const uniqueCategories = new Set(entries.map((e) => e.intentCategory)).size;
150
+ const uniqueActors = new Set(entries.map((e) => e.actor ?? 'unknown')).size;
151
+ const lastEntry = entries[entries.length - 1];
152
+ return {
153
+ entryCount: entries.length,
154
+ successCount: successes,
155
+ failureCount: failures,
156
+ overallSuccessRate: entries.length > 0 ? successes / entries.length : 0,
157
+ uniqueIntentCategories: uniqueCategories,
158
+ uniqueActors,
159
+ topHotspots: buildTeamHotspots(repoRoot).slice(0, 10),
160
+ lastEntryAt: lastEntry
161
+ ? new Date(lastEntry.timestamp).toISOString()
162
+ : null,
163
+ ledgerPath: teamLedgerPath(repoRoot),
164
+ };
165
+ }
166
+ /**
167
+ * Sync local ECL-Lite entries into the team ledger.
168
+ * Deduplicates by (intentCategory + contextHash) — only appends new entries.
169
+ */
170
+ export function syncFromEcl(repoRoot, eclEntries, actor) {
171
+ const existing = loadTeamEntries(repoRoot);
172
+ const existingKeys = new Set(existing.map((e) => `${e.intentCategory}:${e.contextHash}`));
173
+ let synced = 0;
174
+ for (const ecl of eclEntries) {
175
+ const contextHash = createHash('sha256')
176
+ .update([...ecl.files].sort().join('\n'))
177
+ .digest('hex')
178
+ .slice(0, 16);
179
+ const category = ecl.intentCategory ?? 'general_task';
180
+ const key = `${category}:${contextHash}`;
181
+ if (existingKeys.has(key))
182
+ continue;
183
+ const teamEntry = {
184
+ intentCategory: category,
185
+ contextHash,
186
+ outcome: ecl.outcome,
187
+ confidenceScore: ecl.confidenceScore,
188
+ files: ecl.files,
189
+ symbols: ecl.symbols,
190
+ timestamp: ecl.timestamp,
191
+ actor,
192
+ expansionLevel: ecl.expansionLevel,
193
+ successWeight: ecl.outcome === 'success' ? 1 : 0,
194
+ failureWeight: ecl.outcome === 'failure' ? 1 : 0,
195
+ };
196
+ recordTeamEntry(repoRoot, teamEntry);
197
+ existingKeys.add(key);
198
+ synced++;
199
+ }
200
+ return synced;
201
+ }
202
+ // ─── Helpers ──────────────────────────────────────────────────────────────────
203
+ function ensureDir(dir) {
204
+ if (!existsSync(dir)) {
205
+ mkdirSync(dir, { recursive: true });
206
+ }
207
+ }
208
+ //# sourceMappingURL=ledger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ledger.js","sourceRoot":"","sources":["../../src/team-ledger/ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACxF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;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,GAAG,CAAC,SAAS;YACxB,KAAK;YACL,cAAc,EAAE,GAAG,CAAC,cAAc;YAClC,aAAa,EAAE,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAChD,aAAa,EAAE,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SACjD,CAAC;QAEF,eAAe,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QACrC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACtB,MAAM,EAAE,CAAC;IACX,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,iFAAiF;AAEjF,SAAS,SAAS,CAAC,GAAW;IAC5B,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACtC,CAAC;AACH,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Team Context Quality Score (Team Metrics)
3
+ *
4
+ * Exposes a team-level productivity metric aggregated from sessions.
5
+ * Composite score from: recall, precision, drift, CCS, ISC.
6
+ */
7
+ export { computeTeamMetrics, identifyWeakAreas, TEAM_METRICS_FILE, } from './metrics.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/team-metrics/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Team Context Quality Score (Team Metrics)
3
+ *
4
+ * Exposes a team-level productivity metric aggregated from sessions.
5
+ * Composite score from: recall, precision, drift, CCS, ISC.
6
+ */
7
+ export { computeTeamMetrics, identifyWeakAreas, TEAM_METRICS_FILE, } from './metrics.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/team-metrics/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,cAAc,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Team Context Quality Score — Implementation
3
+ *
4
+ * Aggregates across sessions:
5
+ * - recall, precision, intent drift, CCS, ISC
6
+ *
7
+ * Produces a composite [0,1] score with trend and weak area identification.
8
+ *
9
+ * Storage: .codeledger/team-metrics.json
10
+ *
11
+ * Weights:
12
+ * recall 0.30
13
+ * precision 0.25
14
+ * ccs 0.20
15
+ * isc 0.15
16
+ * drift 0.10 (inverted: lower drift = higher score)
17
+ */
18
+ import type { TeamMetrics, TeamWeakArea } from '@codeledger/types';
19
+ export declare const TEAM_METRICS_FILE = "team-metrics.json";
20
+ interface SessionSnapshot {
21
+ recall: number;
22
+ precision: number;
23
+ drift: number;
24
+ ccs: number;
25
+ isc: number;
26
+ timestamp: number;
27
+ }
28
+ /**
29
+ * Compute team-level quality metrics from session snapshots.
30
+ *
31
+ * Each snapshot is a session's summary metrics. The function computes
32
+ * averages, a composite score, trend vs the previous period, and weak areas.
33
+ *
34
+ * Persists to .codeledger/team-metrics.json.
35
+ */
36
+ export declare function computeTeamMetrics(repoRoot: string, snapshots: SessionSnapshot[]): TeamMetrics;
37
+ /**
38
+ * Identify weak areas where individual factor scores fall below the threshold.
39
+ */
40
+ export declare function identifyWeakAreas(recall: number, precision: number, drift: number, ccs: number, isc: number): TeamWeakArea[];
41
+ export {};
42
+ //# sourceMappingURL=metrics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../../src/team-metrics/metrics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EAEb,MAAM,mBAAmB,CAAC;AAI3B,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAerD,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB;AAID;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,eAAe,EAAE,GAC3B,WAAW,CA6Eb;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACV,YAAY,EAAE,CAwChB"}