soturail 0.8.0 → 0.9.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 (57) hide show
  1. package/README.md +57 -16
  2. package/dist/commands/bench.d.ts +1 -0
  3. package/dist/commands/bench.js +18 -6
  4. package/dist/commands/bench.js.map +1 -1
  5. package/dist/commands/brain.js +14 -7
  6. package/dist/commands/brain.js.map +1 -1
  7. package/dist/commands/native.js +12 -0
  8. package/dist/commands/native.js.map +1 -1
  9. package/dist/commands/rules.js +20 -1
  10. package/dist/commands/rules.js.map +1 -1
  11. package/dist/commands/self.js +19 -0
  12. package/dist/commands/self.js.map +1 -1
  13. package/dist/core/baseline-snapshot.d.ts +27 -0
  14. package/dist/core/baseline-snapshot.js +225 -0
  15. package/dist/core/baseline-snapshot.js.map +1 -0
  16. package/dist/core/benchmark-rail.d.ts +44 -0
  17. package/dist/core/benchmark-rail.js +322 -0
  18. package/dist/core/benchmark-rail.js.map +1 -0
  19. package/dist/core/config.d.ts +5 -0
  20. package/dist/core/config.js +6 -1
  21. package/dist/core/config.js.map +1 -1
  22. package/dist/core/evaluation-suite.js +117 -2
  23. package/dist/core/evaluation-suite.js.map +1 -1
  24. package/dist/core/evidence-pack.js +17 -0
  25. package/dist/core/evidence-pack.js.map +1 -1
  26. package/dist/core/harness-rail.js +2 -0
  27. package/dist/core/harness-rail.js.map +1 -1
  28. package/dist/core/native-candidates.d.ts +44 -0
  29. package/dist/core/native-candidates.js +163 -0
  30. package/dist/core/native-candidates.js.map +1 -0
  31. package/dist/core/project-brain.d.ts +70 -4
  32. package/dist/core/project-brain.js +475 -30
  33. package/dist/core/project-brain.js.map +1 -1
  34. package/dist/core/release-preflight.js +8 -0
  35. package/dist/core/release-preflight.js.map +1 -1
  36. package/dist/core/version.d.ts +1 -1
  37. package/dist/core/version.js +1 -1
  38. package/docs/agents.md +9 -1
  39. package/docs/baseline-snapshots.md +54 -0
  40. package/docs/benchmarking.md +69 -0
  41. package/docs/code-graph.md +33 -0
  42. package/docs/diagram-rail.md +2 -0
  43. package/docs/evaluation-suite.md +23 -0
  44. package/docs/harness-rail.md +10 -0
  45. package/docs/knowledge-to-rules.md +23 -0
  46. package/docs/memory-rail.md +2 -0
  47. package/docs/native-performance-policy.md +62 -0
  48. package/docs/native-runner.md +24 -0
  49. package/docs/project-brain.md +101 -4
  50. package/docs/release-workflow.md +13 -0
  51. package/docs/releases/README.md +2 -0
  52. package/docs/releases/RELEASE_NOTES_v0.8.1.md +42 -0
  53. package/docs/releases/RELEASE_NOTES_v0.9.0.md +35 -0
  54. package/docs/reverse-specification-rail.md +19 -0
  55. package/docs/rules.md +3 -0
  56. package/docs/workflow-rail.md +23 -0
  57. package/package.json +1 -1
@@ -0,0 +1,163 @@
1
+ import { promises as fs } from "node:fs";
2
+ import path from "node:path";
3
+ import { detectNativeEngine } from "./native-engine.js";
4
+ import { getWorkspacePaths, relativeToRoot, writeJson } from "./config.js";
5
+ export async function nativeStatus(root = process.cwd()) {
6
+ const info = await detectNativeEngine(root);
7
+ return {
8
+ schemaVersion: "soturail.native.status.v1",
9
+ createdAt: new Date().toISOString(),
10
+ native_available: info.available,
11
+ native_engine: info.available ? "rust" : "none",
12
+ native_path: info.path,
13
+ native_version: info.version,
14
+ fallback: "typescript",
15
+ npm_install_requires_native: false,
16
+ safe_to_use: true,
17
+ checked_paths: info.checked_paths
18
+ };
19
+ }
20
+ export async function writeNativeCandidateReport(root = process.cwd()) {
21
+ const status = await nativeStatus(root);
22
+ const report = {
23
+ schemaVersion: "soturail.native.candidates.v1",
24
+ createdAt: new Date().toISOString(),
25
+ engine: {
26
+ nativeAvailable: status.native_available,
27
+ fallback: "typescript",
28
+ normalInstallRequiresNative: false
29
+ },
30
+ candidates: nativeCandidates()
31
+ };
32
+ const dir = path.join(getWorkspacePaths(root).workspace, "native");
33
+ const jsonPath = path.join(dir, "candidates.json");
34
+ const markdownPath = path.join(dir, "candidates.md");
35
+ await fs.mkdir(dir, { recursive: true });
36
+ await writeJson(jsonPath, report);
37
+ await fs.writeFile(markdownPath, renderNativeCandidates(report), "utf8");
38
+ return {
39
+ report,
40
+ markdownPath,
41
+ jsonPath,
42
+ output: [
43
+ "SotuRail native candidates",
44
+ `schemaVersion: ${report.schemaVersion}`,
45
+ `native_available: ${report.engine.nativeAvailable}`,
46
+ `fallback: ${report.engine.fallback}`,
47
+ `normal_install_requires_native: ${report.engine.normalInstallRequiresNative}`,
48
+ `candidates_count: ${report.candidates.length}`,
49
+ `good_candidates: ${report.candidates.filter((item) => item.classification === "good-candidate").length}`,
50
+ `json: ${relativeToRoot(root, jsonPath)}`,
51
+ `markdown: ${relativeToRoot(root, markdownPath)}`
52
+ ].join("\n") + "\n"
53
+ };
54
+ }
55
+ export function renderNativeStatus(report) {
56
+ return [
57
+ "SotuRail native status",
58
+ `schemaVersion: ${report.schemaVersion}`,
59
+ `native_available: ${report.native_available}`,
60
+ `native_engine: ${report.native_engine}`,
61
+ `native_path: ${report.native_path ?? "not found"}`,
62
+ `native_version: ${report.native_version ?? "unknown"}`,
63
+ `fallback: ${report.fallback}`,
64
+ `npm_install_requires_native: ${report.npm_install_requires_native}`,
65
+ `safe_to_use: ${report.safe_to_use}`,
66
+ "checked_paths:",
67
+ ...report.checked_paths.map((item) => `- ${item}`)
68
+ ].join("\n") + "\n";
69
+ }
70
+ export async function nativeDoctor(root = process.cwd()) {
71
+ const status = await nativeStatus(root);
72
+ const paths = getWorkspacePaths(root);
73
+ const candidateJson = path.join(paths.workspace, "native", "candidates.json");
74
+ const benchJson = path.join(paths.workspace, "bench", "latest.json");
75
+ const candidatePresent = await exists(candidateJson);
76
+ const benchPresent = await exists(benchJson);
77
+ return [
78
+ "SotuRail native doctor",
79
+ "typescript_fallback: OK",
80
+ `native_optional: ${status.native_available ? "OK" : "Unavailable"}`,
81
+ `native_available: ${status.native_available}`,
82
+ `native_engine: ${status.native_engine}`,
83
+ "normal_npm_install_requires_rust: NO",
84
+ "normal_npm_install_requires_native: NO",
85
+ `benchmarks_available: ${benchPresent ? "YES" : "NO"}`,
86
+ `candidate_report: ${candidatePresent ? relativeToRoot(root, candidateJson) : "missing"}`,
87
+ "decision_policy: benchmark-before-native",
88
+ "recommended_next_command:",
89
+ candidatePresent ? "- soturail bench run --suite brain" : "- soturail native candidates",
90
+ "- soturail native compare"
91
+ ].join("\n") + "\n";
92
+ }
93
+ export async function nativeCompare(root = process.cwd()) {
94
+ const status = await nativeStatus(root);
95
+ if (!status.native_available) {
96
+ return [
97
+ "SotuRail native compare",
98
+ "native_available: false",
99
+ "result: skipped",
100
+ "typescript_fallback: OK",
101
+ "reason: optional native engine is unavailable; no native speedup is claimed",
102
+ "next: soturail bench run --suite brain"
103
+ ].join("\n") + "\n";
104
+ }
105
+ return [
106
+ "SotuRail native compare",
107
+ "native_available: true",
108
+ "result: ready",
109
+ "typescript_fallback: OK",
110
+ "next: soturail bench compare-engines",
111
+ "note: promote native acceleration only after a local benchmark report shows justified speedup."
112
+ ].join("\n") + "\n";
113
+ }
114
+ function nativeCandidates() {
115
+ return [
116
+ candidate("large log reducers", "good-candidate", "Large terminal logs already have reducer fixtures and can be compared against TypeScript output.", "reducer-large-log", "medium", "high"),
117
+ candidate("rangeHash computation", "good-candidate", "Range hashing repeats over source evidence during stale checks.", "range-hash", "low", "medium"),
118
+ candidate("JSONL scanning", "good-candidate", "Append-only brain records and metrics grow with local usage.", "jsonl-read-write", "low", "medium"),
119
+ candidate("source-range relocation", "maybe-candidate", "Relocation uses simple text windows and should be measured before native work.", "brain-stale", "medium", "medium"),
120
+ candidate("duplicate claim clustering", "maybe-candidate", "Claim consolidation scales with record count and token overlap checks.", "brain-consolidate", "medium", "medium"),
121
+ candidate("recursive file scanning", "maybe-candidate", "Large repositories may spend time walking files, but ignores and file limits must stay identical.", "file-scan", "medium", "medium"),
122
+ candidate("reverse claims", "maybe-candidate", "Heuristic extraction may benefit from parser help later, but TypeScript remains adequate on small repos.", "reverse-claims", "medium", "medium"),
123
+ candidate("diagram validation", "not-worth-it-yet", "Current validation is lightweight string logic, not a measured bottleneck.", "workflow-evidence", "low", "low", "keep-typescript"),
124
+ candidate("workflow evidence generation", "not-worth-it-yet", "Evidence rendering is I/O and Markdown assembly, not a native hot path yet.", "workflow-evidence", "low", "low", "keep-typescript"),
125
+ candidate("agent brief rendering", "not-worth-it-yet", "Brief rendering is bounded and review-oriented; native code would add maintenance risk without evidence.", "brain-scan", "low", "low", "keep-typescript"),
126
+ candidate("release preflight", "blocked", "Release gates are orchestration, npm, audit and pack checks; native acceleration would not simplify them.", "release-preflight", "high", "low", "blocked-until-measured")
127
+ ];
128
+ }
129
+ function candidate(area, classification, reason, benchmarkCategory, risk, estimatedBenefit, recommendation = "benchmark-before-native") {
130
+ return {
131
+ area,
132
+ classification,
133
+ reason,
134
+ currentEngine: "typescript",
135
+ benchmarkCategory,
136
+ risk,
137
+ estimatedBenefit,
138
+ fallback: "typescript",
139
+ recommendation
140
+ };
141
+ }
142
+ function renderNativeCandidates(report) {
143
+ return [
144
+ "# SotuRail Native Candidate Report",
145
+ "",
146
+ "No benchmark, no native rewrite. TypeScript remains the portable baseline.",
147
+ "",
148
+ `schemaVersion: ${report.schemaVersion}`,
149
+ `createdAt: ${report.createdAt}`,
150
+ `nativeAvailable: ${report.engine.nativeAvailable}`,
151
+ `fallback: ${report.engine.fallback}`,
152
+ `normalInstallRequiresNative: ${report.engine.normalInstallRequiresNative}`,
153
+ "",
154
+ "| area | classification | benchmark | risk | benefit | recommendation | reason |",
155
+ "|---|---|---|---|---|---|---|",
156
+ ...report.candidates.map((item) => `| ${item.area} | ${item.classification} | ${item.benchmarkCategory} | ${item.risk} | ${item.estimatedBenefit} | ${item.recommendation} | ${item.reason} |`),
157
+ ""
158
+ ].join("\n");
159
+ }
160
+ async function exists(filePath) {
161
+ return fs.access(filePath).then(() => true).catch(() => false);
162
+ }
163
+ //# sourceMappingURL=native-candidates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-candidates.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sB,CAAC,MAA6B;IAC3D,OAAO;QACL,oCAAoC;QACpC,EAAE;QACF,4EAA4E;QAC5E,EAAE;QACF,kBAAkB,MAAM,CAAC,aAAa,EAAE;QACxC,cAAc,MAAM,CAAC,SAAS,EAAE;QAChC,oBAAoB,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE;QACnD,aAAa,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE;QACrC,gCAAgC,MAAM,CAAC,MAAM,CAAC,2BAA2B,EAAE;QAC3E,EAAE;QACF,kFAAkF;QAClF,+BAA+B;QAC/B,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,cAAc,MAAM,IAAI,CAAC,iBAAiB,MAAM,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,gBAAgB,MAAM,IAAI,CAAC,cAAc,MAAM,IAAI,CAAC,MAAM,IAAI,CAAC;QAC/L,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,KAAK,UAAU,MAAM,CAAC,QAAgB;IACpC,OAAO,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;AACjE,CAAC"}
@@ -74,7 +74,10 @@ export interface BrainStaleEventRecord {
74
74
  reason: string;
75
75
  previousHash: string;
76
76
  currentHash: string;
77
- status: "suspect" | "stale" | "resolved";
77
+ status: "suspect" | "stale" | "resolved" | "relocated";
78
+ previousRange?: SourceRange;
79
+ candidateRange?: SourceRange;
80
+ similarity?: number;
78
81
  createdAt: string;
79
82
  }
80
83
  export interface BrainProjectProfile {
@@ -165,10 +168,64 @@ export interface BrainDoctorReport {
165
168
  validJsonl?: boolean;
166
169
  }>;
167
170
  counts: BrainCounts;
171
+ duplicateClaimGroups?: number;
172
+ integrationStatus?: Record<string, string>;
173
+ repairPlanPath?: string;
168
174
  findings: string[];
169
175
  nextCommands: string[];
170
176
  }
171
177
  export type BrainAgentTarget = Extract<AgentId, "claude" | "codex" | "gemini" | "cursor" | "generic">;
178
+ export interface BrainStaleOptions {
179
+ repairPlan?: boolean;
180
+ }
181
+ export interface BrainRepairSuggestion {
182
+ recordId: string;
183
+ type: "claim" | "decision" | "rule";
184
+ text: string;
185
+ reason: string;
186
+ sourcePath: string;
187
+ affectedRange?: SourceRange;
188
+ candidateRange?: SourceRange;
189
+ similarity?: number;
190
+ recommendedCommand: string;
191
+ recommendedHumanAction: string;
192
+ relatedValidation: string[];
193
+ }
194
+ export interface BrainRepairPlan {
195
+ schemaVersion: "soturail.brain.repair-plan.v1";
196
+ createdAt: string;
197
+ suggestions: BrainRepairSuggestion[];
198
+ }
199
+ export interface BrainConsolidationGroup {
200
+ canonicalId: string;
201
+ duplicateIds: string[];
202
+ reason: string;
203
+ score: number;
204
+ claims: Array<{
205
+ id: string;
206
+ status: BrainClaimStatus;
207
+ confidence: BrainConfidence;
208
+ sourcePath: string;
209
+ claim: string;
210
+ }>;
211
+ }
212
+ export interface BrainConsolidationReport {
213
+ schemaVersion: "soturail.brain.consolidation.v1";
214
+ createdAt: string;
215
+ dryRun: boolean;
216
+ claimsRead: number;
217
+ duplicateGroups: number;
218
+ mergedClaims: number;
219
+ canonicalClaims: number;
220
+ groups: BrainConsolidationGroup[];
221
+ }
222
+ export interface BrainExportOptions {
223
+ limit?: number;
224
+ includeSuspect?: boolean;
225
+ }
226
+ export interface BrainDoctorOptions {
227
+ repairPlan?: boolean;
228
+ }
172
229
  export declare function initBrain(root?: string): Promise<{
173
230
  paths: string[];
174
231
  output: string;
@@ -180,15 +237,23 @@ export declare function scanBrain(root?: string): Promise<{
180
237
  }>;
181
238
  export declare function brainProfile(root?: string): Promise<string>;
182
239
  export declare function recallBrain(query: string, root?: string, limit?: number): Promise<string>;
183
- export declare function staleBrain(root?: string): Promise<{
240
+ export declare function staleBrain(root?: string, options?: BrainStaleOptions): Promise<{
184
241
  freshness: BrainFreshnessView;
242
+ repairPlan?: BrainRepairPlan;
243
+ output: string;
244
+ }>;
245
+ export declare function consolidateBrain(root?: string, options?: {
246
+ dryRun?: boolean;
247
+ }): Promise<{
248
+ report: BrainConsolidationReport;
185
249
  output: string;
186
250
  }>;
187
- export declare function brainDoctor(root?: string): Promise<{
251
+ export declare function brainDoctor(root?: string, options?: BrainDoctorOptions): Promise<{
188
252
  report: BrainDoctorReport;
253
+ repairPlan?: BrainRepairPlan;
189
254
  output: string;
190
255
  }>;
191
- export declare function exportBrain(agent: BrainAgentTarget, root?: string): Promise<{
256
+ export declare function exportBrain(agent: BrainAgentTarget, root?: string, options?: BrainExportOptions): Promise<{
192
257
  path: string;
193
258
  content: string;
194
259
  output: string;
@@ -196,6 +261,7 @@ export declare function exportBrain(agent: BrainAgentTarget, root?: string): Pro
196
261
  export declare function rulesFromBrain(root?: string): Promise<{
197
262
  rules: BrainRuleRecord[];
198
263
  markdownPath: string;
264
+ jsonPath: string;
199
265
  output: string;
200
266
  }>;
201
267
  export declare function readBrainCounts(root?: string): Promise<BrainCounts>;