avorelo 0.1.0 → 0.3.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.
- package/LICENSE +23 -16
- package/README.md +90 -51
- package/bin/avorelo.mjs +7 -0
- package/dist/avorelo.mjs +19741 -0
- package/package.json +135 -120
- package/bin/avorelo +0 -9
- package/scripts/README.md +0 -40
- package/scripts/cco-dashboard.js +0 -252
- package/scripts/cco-status.js +0 -430
- package/scripts/lib/activation/account-state.js +0 -37
- package/scripts/lib/activation/activation-runner.js +0 -546
- package/scripts/lib/activation/activation-self-healing.js +0 -480
- package/scripts/lib/activation/activation-state.js +0 -83
- package/scripts/lib/activation/activation-summary.js +0 -191
- package/scripts/lib/activation/adapters/claude-code.js +0 -77
- package/scripts/lib/activation/adapters/codex-cli.js +0 -52
- package/scripts/lib/activation/adapters/cursor.js +0 -37
- package/scripts/lib/activation/adapters/github-agent.js +0 -39
- package/scripts/lib/activation/adapters/terminal.js +0 -42
- package/scripts/lib/activation/adapters/vscode.js +0 -39
- package/scripts/lib/activation/adapters/windsurf.js +0 -37
- package/scripts/lib/activation/ai-surface-detector.js +0 -151
- package/scripts/lib/activation/connect-account.js +0 -145
- package/scripts/lib/activation/detect-environment.js +0 -75
- package/scripts/lib/activation/detect-hosts.js +0 -62
- package/scripts/lib/activation/format-activation-output.js +0 -109
- package/scripts/lib/activation/next-action.js +0 -43
- package/scripts/lib/activation/repair-engine.js +0 -219
- package/scripts/lib/activation-distribution-readiness.js +0 -507
- package/scripts/lib/adapter-conformance.js +0 -176
- package/scripts/lib/adapter-readiness.js +0 -417
- package/scripts/lib/adapter-safety-boundaries.js +0 -335
- package/scripts/lib/adapter-technical-readiness-gate.js +0 -205
- package/scripts/lib/agent-access-governance.js +0 -455
- package/scripts/lib/agent-enforcement.js +0 -765
- package/scripts/lib/agent-policy-profile.js +0 -210
- package/scripts/lib/agent-security/action-evaluator.js +0 -507
- package/scripts/lib/agent-security/adapter-registry.js +0 -98
- package/scripts/lib/agent-security/auto-policy.js +0 -139
- package/scripts/lib/agent-security/bounded-scan.js +0 -93
- package/scripts/lib/agent-security/enforcement-adapter.js +0 -174
- package/scripts/lib/agent-security/enforcement-engine.js +0 -1129
- package/scripts/lib/agent-security/file-write-adapter.js +0 -183
- package/scripts/lib/agent-security/file-write-rules.js +0 -178
- package/scripts/lib/agent-security/index.js +0 -3342
- package/scripts/lib/agent-security/instruction-risk.js +0 -181
- package/scripts/lib/agent-security/mcp-action-adapter.js +0 -185
- package/scripts/lib/agent-security/mcp-action-rules.js +0 -184
- package/scripts/lib/agent-security/package-action-adapter.js +0 -175
- package/scripts/lib/agent-security/package-action-rules.js +0 -233
- package/scripts/lib/agent-security/performance.js +0 -148
- package/scripts/lib/agent-security/permission-minimizer.js +0 -403
- package/scripts/lib/agent-security/scan-cache.js +0 -74
- package/scripts/lib/agent-security/source-trust.js +0 -146
- package/scripts/lib/ai-install-prompt.js +0 -288
- package/scripts/lib/ai-workspace-hygiene.js +0 -1499
- package/scripts/lib/alpha-activation.js +0 -520
- package/scripts/lib/alpha-feedback.js +0 -263
- package/scripts/lib/alpha-readiness-gate.js +0 -332
- package/scripts/lib/anti-gaming.js +0 -169
- package/scripts/lib/artifact-health.js +0 -431
- package/scripts/lib/attribution.js +0 -180
- package/scripts/lib/audit.js +0 -289
- package/scripts/lib/avorelo-skill-registry.js +0 -810
- package/scripts/lib/batch-jobs.js +0 -71
- package/scripts/lib/brain-pack.js +0 -578
- package/scripts/lib/brand-boundary.js +0 -424
- package/scripts/lib/brand.js +0 -74
- package/scripts/lib/browser-capability.js +0 -1048
- package/scripts/lib/browser-proof-preflight.js +0 -321
- package/scripts/lib/cache-readiness.js +0 -187
- package/scripts/lib/canonical-reentry.js +0 -162
- package/scripts/lib/capability-packs.js +0 -314
- package/scripts/lib/capability-recommender.js +0 -512
- package/scripts/lib/capability-registry.js +0 -1059
- package/scripts/lib/carry-forward-surfacing.js +0 -194
- package/scripts/lib/ccusage-adapter.js +0 -188
- package/scripts/lib/company-loop.js +0 -1149
- package/scripts/lib/config.js +0 -637
- package/scripts/lib/context-acquisition-plan.js +0 -287
- package/scripts/lib/context-budget-guard.js +0 -170
- package/scripts/lib/context-budget-scanner.js +0 -257
- package/scripts/lib/context-optimizer.js +0 -715
- package/scripts/lib/context-reduction-plan.js +0 -178
- package/scripts/lib/context-safety.js +0 -88
- package/scripts/lib/context-savings-engine.js +0 -158
- package/scripts/lib/cost-evidence.js +0 -254
- package/scripts/lib/cross-host-install-plan.js +0 -308
- package/scripts/lib/cross-host-install-readiness.js +0 -237
- package/scripts/lib/cross-host-value-flow.js +0 -268
- package/scripts/lib/dashboard.js +0 -900
- package/scripts/lib/design-partner-feedback.js +0 -346
- package/scripts/lib/entitlements.js +0 -100
- package/scripts/lib/execution-packet.js +0 -559
- package/scripts/lib/experimentation-events.js +0 -547
- package/scripts/lib/external-capability-compliance.js +0 -107
- package/scripts/lib/external-user-simulation.js +0 -166
- package/scripts/lib/failure-recovery-readiness.js +0 -81
- package/scripts/lib/failure-recovery.js +0 -419
- package/scripts/lib/feedback-intelligence.js +0 -537
- package/scripts/lib/feedback-signals.js +0 -205
- package/scripts/lib/file-integrity.js +0 -68
- package/scripts/lib/fsx.js +0 -127
- package/scripts/lib/full-readiness-gate.js +0 -451
- package/scripts/lib/guidance-builder.js +0 -174
- package/scripts/lib/hook-apply.js +0 -1019
- package/scripts/lib/hook-baseline.js +0 -310
- package/scripts/lib/hook-config-preview.js +0 -275
- package/scripts/lib/hook-contracts.js +0 -290
- package/scripts/lib/hook-safety-boundary-readiness.js +0 -80
- package/scripts/lib/host-capability-matrix.js +0 -351
- package/scripts/lib/host-support-context.js +0 -254
- package/scripts/lib/http-hook-action.js +0 -538
- package/scripts/lib/install-ai-readiness.js +0 -84
- package/scripts/lib/install-intake-risk.js +0 -1037
- package/scripts/lib/install-journey-intelligence.js +0 -329
- package/scripts/lib/intervention-guidance.js +0 -57
- package/scripts/lib/known-limitations.js +0 -115
- package/scripts/lib/l8-path-truth.js +0 -146
- package/scripts/lib/launch-hardening-gate.js +0 -436
- package/scripts/lib/launch-readiness.js +0 -628
- package/scripts/lib/learning-memory.js +0 -686
- package/scripts/lib/lifecycle-hooks.js +0 -802
- package/scripts/lib/local-package-smoke.js +0 -423
- package/scripts/lib/local-pricing.js +0 -299
- package/scripts/lib/mcp-enforcement.js +0 -311
- package/scripts/lib/mcp-least-privilege-policy.js +0 -303
- package/scripts/lib/mcp-tool-inventory.js +0 -388
- package/scripts/lib/mcp-tool-risk.js +0 -0
- package/scripts/lib/memory.js +0 -335
- package/scripts/lib/metrics.js +0 -699
- package/scripts/lib/micro-proof.js +0 -133
- package/scripts/lib/next-run-context.js +0 -436
- package/scripts/lib/operating-value.js +0 -1648
- package/scripts/lib/optimization-v3.js +0 -122
- package/scripts/lib/orchestration/adapters/_shared.js +0 -49
- package/scripts/lib/orchestration/adapters/aider.js +0 -18
- package/scripts/lib/orchestration/adapters/claude-code.js +0 -35
- package/scripts/lib/orchestration/adapters/codex.js +0 -35
- package/scripts/lib/orchestration/adapters/gemini-cli.js +0 -18
- package/scripts/lib/orchestration/adapters/git.js +0 -25
- package/scripts/lib/orchestration/adapters/index.js +0 -31
- package/scripts/lib/orchestration/adapters/lm-studio.js +0 -18
- package/scripts/lib/orchestration/adapters/ollama.js +0 -18
- package/scripts/lib/orchestration/adapters/opencode.js +0 -18
- package/scripts/lib/orchestration/adapters/openrouter.js +0 -18
- package/scripts/lib/orchestration/adapters/test-runner.js +0 -25
- package/scripts/lib/orchestration/cli.js +0 -438
- package/scripts/lib/orchestration/execution-manager.js +0 -279
- package/scripts/lib/orchestration/handoff.js +0 -314
- package/scripts/lib/orchestration/index.js +0 -456
- package/scripts/lib/orchestration/inventory.js +0 -47
- package/scripts/lib/orchestration/model-discovery.js +0 -498
- package/scripts/lib/orchestration/model-profiler.js +0 -170
- package/scripts/lib/orchestration/model-profiles.js +0 -252
- package/scripts/lib/orchestration/model-refresh-policy.js +0 -72
- package/scripts/lib/orchestration/proof-writer.js +0 -349
- package/scripts/lib/orchestration/provider-discovery/aider.js +0 -49
- package/scripts/lib/orchestration/provider-discovery/claude-code.js +0 -56
- package/scripts/lib/orchestration/provider-discovery/codex.js +0 -49
- package/scripts/lib/orchestration/provider-discovery/common.js +0 -186
- package/scripts/lib/orchestration/provider-discovery/gemini.js +0 -106
- package/scripts/lib/orchestration/provider-discovery/lm-studio.js +0 -118
- package/scripts/lib/orchestration/provider-discovery/models-dev.js +0 -12
- package/scripts/lib/orchestration/provider-discovery/ollama.js +0 -100
- package/scripts/lib/orchestration/provider-discovery/opencode.js +0 -47
- package/scripts/lib/orchestration/provider-discovery/openrouter.js +0 -44
- package/scripts/lib/orchestration/risk-classifier.js +0 -130
- package/scripts/lib/orchestration/routing-policy.js +0 -486
- package/scripts/lib/orchestration/settings.js +0 -112
- package/scripts/lib/orchestration/state.js +0 -165
- package/scripts/lib/orchestration/verification-manager.js +0 -138
- package/scripts/lib/output-profiles.js +0 -146
- package/scripts/lib/package-content-audit.js +0 -368
- package/scripts/lib/package-runtime.js +0 -278
- package/scripts/lib/plan-surface.js +0 -53
- package/scripts/lib/plans.js +0 -2318
- package/scripts/lib/policy-provider.js +0 -27
- package/scripts/lib/prelaunch-activation-readiness.js +0 -409
- package/scripts/lib/prelaunch-evidence-store.js +0 -816
- package/scripts/lib/prelaunch-intelligence.js +0 -869
- package/scripts/lib/pricing-experiment.js +0 -118
- package/scripts/lib/pro-moment-events.js +0 -77
- package/scripts/lib/pro-moment-state.js +0 -227
- package/scripts/lib/pro-moments.js +0 -1216
- package/scripts/lib/product-learning-events.js +0 -629
- package/scripts/lib/project-profile.js +0 -555
- package/scripts/lib/prompt-compiler.js +0 -280
- package/scripts/lib/prompt-lint.js +0 -32
- package/scripts/lib/prompt-suggestions.js +0 -52
- package/scripts/lib/proof-canonical.js +0 -398
- package/scripts/lib/proof-drilldown.js +0 -383
- package/scripts/lib/proof-events.js +0 -342
- package/scripts/lib/proof-history.js +0 -243
- package/scripts/lib/proof-metrics.js +0 -296
- package/scripts/lib/proof-outcome-evidence.js +0 -134
- package/scripts/lib/proof-receipt.js +0 -335
- package/scripts/lib/proof-record.js +0 -461
- package/scripts/lib/public-activation-distribution-gate.js +0 -258
- package/scripts/lib/public-cli.js +0 -3891
- package/scripts/lib/public-distribution-truth.js +0 -211
- package/scripts/lib/public-install-claim-checker.js +0 -294
- package/scripts/lib/publish-provenance-readiness.js +0 -283
- package/scripts/lib/readiness-delta.js +0 -218
- package/scripts/lib/readiness-evidence-closure.js +0 -196
- package/scripts/lib/reentry-memory-capture.js +0 -241
- package/scripts/lib/reentry-memory-retrieval.js +0 -302
- package/scripts/lib/reentry-memory-status.js +0 -146
- package/scripts/lib/reentry-memory-store.js +0 -178
- package/scripts/lib/reentry-state.js +0 -66
- package/scripts/lib/release-candidate-bundle.js +0 -166
- package/scripts/lib/remediation.js +0 -81
- package/scripts/lib/repo-map.js +0 -391
- package/scripts/lib/run-improvements-lifecycle.js +0 -330
- package/scripts/lib/run-improvements.js +0 -789
- package/scripts/lib/runtime-decision-policy.js +0 -387
- package/scripts/lib/safe-path-engine.js +0 -705
- package/scripts/lib/safe-run-controller.js +0 -887
- package/scripts/lib/score.js +0 -262
- package/scripts/lib/seamless-enforcement.js +0 -329
- package/scripts/lib/seamless-outcome.js +0 -689
- package/scripts/lib/seamless-reality-gate.js +0 -5043
- package/scripts/lib/security-risk-classifier.js +0 -511
- package/scripts/lib/security-scan.js +0 -384
- package/scripts/lib/session-context-optimizer.js +0 -1211
- package/scripts/lib/session-timing.js +0 -315
- package/scripts/lib/skill-hygiene.js +0 -805
- package/scripts/lib/skill-packs.js +0 -161
- package/scripts/lib/skills-operating-layer.js +0 -580
- package/scripts/lib/smart-work-routing.js +0 -768
- package/scripts/lib/source-catalog.js +0 -700
- package/scripts/lib/status-value-summary.js +0 -32
- package/scripts/lib/support-bundle.js +0 -578
- package/scripts/lib/task-continuation.js +0 -440
- package/scripts/lib/test-helpers.js +0 -15
- package/scripts/lib/tier.js +0 -38
- package/scripts/lib/token-context-quality-gate.js +0 -370
- package/scripts/lib/token-cost-capture.js +0 -187
- package/scripts/lib/token-cost-intelligence.js +0 -358
- package/scripts/lib/token-efficiency-evidence.js +0 -213
- package/scripts/lib/token-evidence.js +0 -699
- package/scripts/lib/tokenish.js +0 -17
- package/scripts/lib/tool-output-sandbox.js +0 -304
- package/scripts/lib/trust-audit.js +0 -136
- package/scripts/lib/unified-events.js +0 -396
- package/scripts/lib/upgrade-interruption-recovery.js +0 -407
- package/scripts/lib/usage-ledger.js +0 -201
- package/scripts/lib/value-ledger.js +0 -130
- package/scripts/lib/value-proof-calibration.js +0 -531
- package/scripts/lib/visual-qa.js +0 -231
- package/scripts/lib/voice-alpha.js +0 -29
- package/scripts/lib/work-aware-orchestration.js +0 -976
- package/scripts/lib/work-control-receipts.js +0 -577
- package/scripts/lib/work-ledger.js +0 -1123
- package/scripts/lib/work-panel-preview.js +0 -352
- package/scripts/lib/workflow-discipline.js +0 -280
- package/scripts/lib/workflow-signals.js +0 -419
- package/scripts/lib/workspace-map.js +0 -281
- package/scripts/lib/workspace-registry.js +0 -1367
- package/scripts/lib/workspace-resolver.js +0 -480
|
@@ -1,686 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// Evidence-Backed Learning Memory v1
|
|
4
|
-
// Local-first, deterministic, evidence-backed learning layer.
|
|
5
|
-
// No cloud calls, no LLM, no daemon. Generates learning candidates
|
|
6
|
-
// from existing Avorelo artifacts only.
|
|
7
|
-
//
|
|
8
|
-
// Artifacts:
|
|
9
|
-
// .claude/cco/brain/project-brain.json — avorelo.projectBrain.v1
|
|
10
|
-
// .claude/cco/learning/decision-register.jsonl — avorelo.decisionRegister.v1
|
|
11
|
-
// .claude/cco/learning/risk-register.json — avorelo.riskRegister.v1
|
|
12
|
-
// .claude/cco/learning/capability-map.json — avorelo.capabilityMap.v1
|
|
13
|
-
// .claude/cco/state/learning-summary.json — avorelo.learningSummary.v1
|
|
14
|
-
//
|
|
15
|
-
// Source-of-truth order (highest to lowest trust):
|
|
16
|
-
// 1. explicit current user instruction
|
|
17
|
-
// 2. canonical product contracts/docs
|
|
18
|
-
// 3. proof/receipts
|
|
19
|
-
// 4. merged PR/commit evidence
|
|
20
|
-
// 5. audit events
|
|
21
|
-
// 6. readiness/support bundle evidence
|
|
22
|
-
// 7. run-improvement signals
|
|
23
|
-
// 8. low-confidence inferred signals
|
|
24
|
-
//
|
|
25
|
-
// LLM output alone is never source of truth.
|
|
26
|
-
// Test fixtures cannot become real learning unless marked test_fixture.
|
|
27
|
-
|
|
28
|
-
const fs = require("fs");
|
|
29
|
-
const path = require("path");
|
|
30
|
-
const crypto = require("crypto");
|
|
31
|
-
|
|
32
|
-
const BRAIN_REL = ".claude/cco/brain/project-brain.json";
|
|
33
|
-
const DECISION_REGISTER_REL = ".claude/cco/learning/decision-register.jsonl";
|
|
34
|
-
const RISK_REGISTER_REL = ".claude/cco/learning/risk-register.json";
|
|
35
|
-
const CAPABILITY_MAP_REL = ".claude/cco/learning/capability-map.json";
|
|
36
|
-
const LEARNING_SUMMARY_REL = ".claude/cco/state/learning-summary.json";
|
|
37
|
-
|
|
38
|
-
const BRAIN_SCHEMA = "avorelo.projectBrain.v1";
|
|
39
|
-
const DECISION_SCHEMA = "avorelo.decisionRegister.v1";
|
|
40
|
-
const RISK_SCHEMA = "avorelo.riskRegister.v1";
|
|
41
|
-
const CAPABILITY_SCHEMA = "avorelo.capabilityMap.v1";
|
|
42
|
-
const SUMMARY_SCHEMA = "avorelo.learningSummary.v1";
|
|
43
|
-
|
|
44
|
-
const SOURCE_ORDER = [
|
|
45
|
-
"user_instruction",
|
|
46
|
-
"canonical_contract",
|
|
47
|
-
"proof_receipt",
|
|
48
|
-
"merged_pr_evidence",
|
|
49
|
-
"audit_event",
|
|
50
|
-
"readiness_evidence",
|
|
51
|
-
"run_improvement_signal",
|
|
52
|
-
"inferred",
|
|
53
|
-
];
|
|
54
|
-
|
|
55
|
-
const DECISION_STATUSES = ["active", "superseded", "stale", "uncertain", "expired", "test_fixture"];
|
|
56
|
-
|
|
57
|
-
function nowIso() {
|
|
58
|
-
return new Date().toISOString();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function buildFingerprint(data) {
|
|
62
|
-
return crypto
|
|
63
|
-
.createHash("sha256")
|
|
64
|
-
.update(JSON.stringify(data))
|
|
65
|
-
.digest("hex")
|
|
66
|
-
.slice(0, 16);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// ── Evidence collection ───────────────────────────────────────────────────────
|
|
70
|
-
|
|
71
|
-
function collectLearningEvidence(cwd) {
|
|
72
|
-
const evidence = {
|
|
73
|
-
runImprovements: null,
|
|
74
|
-
lifecycleReceipt: null,
|
|
75
|
-
adapterReadiness: null,
|
|
76
|
-
contextBudget: null,
|
|
77
|
-
reentryState: null,
|
|
78
|
-
carryForward: null,
|
|
79
|
-
outcomeEvents: null,
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
try {
|
|
83
|
-
const { loadRunImprovements } = require("./run-improvements");
|
|
84
|
-
evidence.runImprovements = loadRunImprovements(cwd);
|
|
85
|
-
} catch {}
|
|
86
|
-
|
|
87
|
-
try {
|
|
88
|
-
const { loadLifecycleReceipt } = require("./run-improvements-lifecycle");
|
|
89
|
-
evidence.lifecycleReceipt = loadLifecycleReceipt(cwd);
|
|
90
|
-
} catch {}
|
|
91
|
-
|
|
92
|
-
try {
|
|
93
|
-
const { buildAdapterReadinessSurface } = require("./adapter-readiness");
|
|
94
|
-
evidence.adapterReadiness = buildAdapterReadinessSurface(cwd);
|
|
95
|
-
} catch {}
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
const { loadBudgetState } = require("./context-budget-guard");
|
|
99
|
-
evidence.contextBudget = loadBudgetState(cwd);
|
|
100
|
-
} catch {}
|
|
101
|
-
|
|
102
|
-
try {
|
|
103
|
-
const { loadReentryState } = require("./reentry-state");
|
|
104
|
-
evidence.reentryState = loadReentryState(cwd);
|
|
105
|
-
} catch {}
|
|
106
|
-
|
|
107
|
-
try {
|
|
108
|
-
const { loadCarryForward } = require("./carry-forward-surfacing");
|
|
109
|
-
evidence.carryForward = loadCarryForward(cwd);
|
|
110
|
-
} catch {}
|
|
111
|
-
|
|
112
|
-
try {
|
|
113
|
-
const { readOutcomeEvents, aggregateOutcomeEvents } = require("./unified-events");
|
|
114
|
-
const raw = readOutcomeEvents(cwd);
|
|
115
|
-
const events = raw.filter((e) => e.category !== "run_improvements");
|
|
116
|
-
if (events.length > 0) {
|
|
117
|
-
evidence.outcomeEvents = aggregateOutcomeEvents(events, { days: 7 });
|
|
118
|
-
}
|
|
119
|
-
} catch {}
|
|
120
|
-
|
|
121
|
-
return evidence;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// ── Decision candidates ───────────────────────────────────────────────────────
|
|
125
|
-
|
|
126
|
-
function generateDecisionCandidates(evidence) {
|
|
127
|
-
const now = nowIso();
|
|
128
|
-
const candidates = [];
|
|
129
|
-
|
|
130
|
-
// Applied honesty: do not claim applied without lifecycle receipt
|
|
131
|
-
const hasReceipt = evidence.lifecycleReceipt !== null;
|
|
132
|
-
candidates.push({
|
|
133
|
-
id: "dec_applied_requires_receipt",
|
|
134
|
-
decision: "Do not claim 'applied' or 'improved' unless a lifecycle receipt exists confirming it.",
|
|
135
|
-
rationale: hasReceipt
|
|
136
|
-
? "Lifecycle receipt present — applied claim is honest."
|
|
137
|
-
: "No lifecycle receipt — applied must not be claimed.",
|
|
138
|
-
status: "active",
|
|
139
|
-
createdAt: now,
|
|
140
|
-
updatedAt: now,
|
|
141
|
-
supersededBy: null,
|
|
142
|
-
evidenceRefs: ["run_improvements_artifact", "lifecycle_receipt"],
|
|
143
|
-
source: hasReceipt ? "proof_receipt" : "audit_event",
|
|
144
|
-
confidence: 0.95,
|
|
145
|
-
reasonCodes: ["LIFECYCLE_HONEST_CLAIM"],
|
|
146
|
-
affectedSurfaces: ["run-improvements", "status", "dashboard"],
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
// Prepared is honest and useful even without applied
|
|
150
|
-
if (evidence.runImprovements) {
|
|
151
|
-
const ri = evidence.runImprovements;
|
|
152
|
-
if (ri.status === "prepared" || ri.status === "applied") {
|
|
153
|
-
candidates.push({
|
|
154
|
-
id: "dec_prepared_is_honest",
|
|
155
|
-
decision: "Use 'prepared' status when improvements are ready but not yet applied — this is honest and useful.",
|
|
156
|
-
rationale: `Current artifact status is '${ri.status}'. Prepared communicates readiness without overclaiming.`,
|
|
157
|
-
status: "active",
|
|
158
|
-
createdAt: now,
|
|
159
|
-
updatedAt: now,
|
|
160
|
-
supersededBy: null,
|
|
161
|
-
evidenceRefs: ["run_improvements_artifact"],
|
|
162
|
-
source: "run_improvement_signal",
|
|
163
|
-
confidence: 0.90,
|
|
164
|
-
reasonCodes: ["STATUS_HONEST_PREPARED"],
|
|
165
|
-
affectedSurfaces: ["run-improvements"],
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Host support: always host-specific, never universal
|
|
171
|
-
if (evidence.adapterReadiness) {
|
|
172
|
-
candidates.push({
|
|
173
|
-
id: "dec_host_support_is_host_specific",
|
|
174
|
-
decision: "Host support claims must be host-specific. Do not claim universal support across all AI coding hosts.",
|
|
175
|
-
rationale: "Adapter readiness uses host-specific detection — universal claims would be false.",
|
|
176
|
-
status: "active",
|
|
177
|
-
createdAt: now,
|
|
178
|
-
updatedAt: now,
|
|
179
|
-
supersededBy: null,
|
|
180
|
-
evidenceRefs: ["adapter_readiness"],
|
|
181
|
-
source: "readiness_evidence",
|
|
182
|
-
confidence: 0.92,
|
|
183
|
-
reasonCodes: ["HOST_SUPPORT_HOST_SPECIFIC"],
|
|
184
|
-
affectedSurfaces: ["adapter-readiness", "status"],
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// Browser proof: preflight only, not automation
|
|
189
|
-
candidates.push({
|
|
190
|
-
id: "dec_browser_proof_is_preflight_only",
|
|
191
|
-
decision: "Browser proof is a preflight/readiness check only — it does not perform browser automation.",
|
|
192
|
-
rationale: "Browser capability check boundary from canonical product contract.",
|
|
193
|
-
status: "active",
|
|
194
|
-
createdAt: now,
|
|
195
|
-
updatedAt: now,
|
|
196
|
-
supersededBy: null,
|
|
197
|
-
evidenceRefs: ["canonical_contract"],
|
|
198
|
-
source: "canonical_contract",
|
|
199
|
-
confidence: 0.95,
|
|
200
|
-
reasonCodes: ["BROWSER_PREFLIGHT_ONLY"],
|
|
201
|
-
affectedSurfaces: ["browser-proof", "adapter-readiness"],
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
// Context pressure: prefer carry-forward
|
|
205
|
-
if (
|
|
206
|
-
evidence.contextBudget &&
|
|
207
|
-
(evidence.contextBudget.status === "critical" || evidence.contextBudget.status === "warn")
|
|
208
|
-
) {
|
|
209
|
-
candidates.push({
|
|
210
|
-
id: "dec_context_pressure_use_carryforward",
|
|
211
|
-
decision: "Under context pressure, prefer carry-forward summary over full stale context.",
|
|
212
|
-
rationale: `Context budget at ${evidence.contextBudget.status} — full context risks noise and token waste.`,
|
|
213
|
-
status: "active",
|
|
214
|
-
createdAt: now,
|
|
215
|
-
updatedAt: now,
|
|
216
|
-
supersededBy: null,
|
|
217
|
-
evidenceRefs: ["context_budget"],
|
|
218
|
-
source: "run_improvement_signal",
|
|
219
|
-
confidence: evidence.contextBudget.status === "critical" ? 0.92 : 0.75,
|
|
220
|
-
reasonCodes: [`CTX_PRESSURE_${evidence.contextBudget.status.toUpperCase()}`],
|
|
221
|
-
affectedSurfaces: ["run-improvements", "reentry"],
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return candidates;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// ── Risk candidates ───────────────────────────────────────────────────────────
|
|
229
|
-
|
|
230
|
-
function generateRiskCandidates(evidence) {
|
|
231
|
-
const now = nowIso();
|
|
232
|
-
const candidates = [];
|
|
233
|
-
|
|
234
|
-
candidates.push({
|
|
235
|
-
id: "risk_stale_artifacts",
|
|
236
|
-
category: "artifact_integrity",
|
|
237
|
-
title: "Stale artifacts can produce false readiness state",
|
|
238
|
-
severity: "medium",
|
|
239
|
-
status: "active",
|
|
240
|
-
firstSeen: now,
|
|
241
|
-
lastSeen: now,
|
|
242
|
-
evidenceRefs: ["run_improvements_artifact", "lifecycle_receipt"],
|
|
243
|
-
mitigation: "Check artifact TTL and source fingerprint before trusting state claims.",
|
|
244
|
-
ownerSurface: "run-improvements",
|
|
245
|
-
reasonCodes: ["STALE_ARTIFACT_RISK"],
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
candidates.push({
|
|
249
|
-
id: "risk_fake_applied_claims",
|
|
250
|
-
category: "honesty",
|
|
251
|
-
title: "Claiming 'applied' without lifecycle evidence reduces trust",
|
|
252
|
-
severity: "high",
|
|
253
|
-
status: "active",
|
|
254
|
-
firstSeen: now,
|
|
255
|
-
lastSeen: now,
|
|
256
|
-
evidenceRefs: ["lifecycle_receipt"],
|
|
257
|
-
mitigation: "Only set applied=true when lifecycle receipt confirms it via a supported surface.",
|
|
258
|
-
ownerSurface: "run-improvements",
|
|
259
|
-
reasonCodes: ["LIFECYCLE_HONEST_CLAIM"],
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
if (evidence.reentryState && evidence.reentryState.unresolvedRisk) {
|
|
263
|
-
candidates.push({
|
|
264
|
-
id: "risk_unresolved_reentry",
|
|
265
|
-
category: "run_safety",
|
|
266
|
-
title: "Unresolved risk from previous run increases error probability",
|
|
267
|
-
severity: "high",
|
|
268
|
-
status: "active",
|
|
269
|
-
firstSeen: now,
|
|
270
|
-
lastSeen: now,
|
|
271
|
-
evidenceRefs: ["reentry_state"],
|
|
272
|
-
mitigation: "Resolve unresolved risk before continuing. Ask for confirmation before risky actions.",
|
|
273
|
-
ownerSurface: "reentry",
|
|
274
|
-
reasonCodes: ["UNRESOLVED_RISK"],
|
|
275
|
-
});
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
return candidates;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// ── Capability candidates ─────────────────────────────────────────────────────
|
|
282
|
-
|
|
283
|
-
function generateCapabilityCandidates(evidence) {
|
|
284
|
-
const now = nowIso();
|
|
285
|
-
return [
|
|
286
|
-
{
|
|
287
|
-
id: "cap_adapter_readiness",
|
|
288
|
-
capabilityFamily: "adapter_readiness",
|
|
289
|
-
taskTypes: ["host_support_check", "adapter_detection"],
|
|
290
|
-
riskTier: "low",
|
|
291
|
-
supportedInputs: ["project_cwd"],
|
|
292
|
-
outputs: ["adapter_status", "host_detection_result"],
|
|
293
|
-
whenToUse: "When checking which AI coding hosts are available and what capabilities they support.",
|
|
294
|
-
whenNotToUse: "Do not use to claim universal host support across all hosts — results are host-specific.",
|
|
295
|
-
evidenceRefs: evidence.adapterReadiness ? ["adapter_readiness"] : [],
|
|
296
|
-
lastValidated: now,
|
|
297
|
-
status: "active",
|
|
298
|
-
},
|
|
299
|
-
{
|
|
300
|
-
id: "cap_run_improvements",
|
|
301
|
-
capabilityFamily: "run_improvements",
|
|
302
|
-
taskTypes: ["next_run_preparation", "evidence_collection"],
|
|
303
|
-
riskTier: "low",
|
|
304
|
-
supportedInputs: ["project_cwd", "mode"],
|
|
305
|
-
outputs: ["run_improvements_artifact", "next_run_defaults"],
|
|
306
|
-
whenToUse: "When preparing improvements for the next AI coding run based on evidence from the last.",
|
|
307
|
-
whenNotToUse: "Do not claim 'improved' without a lifecycle receipt. Do not generate without evidence.",
|
|
308
|
-
evidenceRefs: evidence.runImprovements ? ["run_improvements_artifact"] : [],
|
|
309
|
-
lastValidated: now,
|
|
310
|
-
status: "active",
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
id: "cap_proof_receipts",
|
|
314
|
-
capabilityFamily: "proof_receipts",
|
|
315
|
-
taskTypes: ["validation_claims", "completion_verification"],
|
|
316
|
-
riskTier: "low",
|
|
317
|
-
supportedInputs: ["project_cwd"],
|
|
318
|
-
outputs: ["proof_receipt", "completion_status"],
|
|
319
|
-
whenToUse: "When making validation claims or verifying task completion.",
|
|
320
|
-
whenNotToUse: "Do not claim 'done' without a proof receipt. Proof does not guarantee universal correctness.",
|
|
321
|
-
evidenceRefs: ["canonical_contract"],
|
|
322
|
-
lastValidated: now,
|
|
323
|
-
status: "active",
|
|
324
|
-
},
|
|
325
|
-
{
|
|
326
|
-
id: "cap_browser_proof_preflight",
|
|
327
|
-
capabilityFamily: "browser_proof_preflight",
|
|
328
|
-
taskTypes: ["browser_readiness_check"],
|
|
329
|
-
riskTier: "low",
|
|
330
|
-
supportedInputs: ["project_cwd"],
|
|
331
|
-
outputs: ["preflight_result"],
|
|
332
|
-
whenToUse: "PREFLIGHT ONLY — check browser capability readiness before any browser-dependent task.",
|
|
333
|
-
whenNotToUse: "Do not use for browser automation. This is a preflight check, not a browser controller.",
|
|
334
|
-
evidenceRefs: ["canonical_contract"],
|
|
335
|
-
lastValidated: now,
|
|
336
|
-
status: "active",
|
|
337
|
-
},
|
|
338
|
-
];
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
// ── Artifact builders ─────────────────────────────────────────────────────────
|
|
342
|
-
|
|
343
|
-
function buildProjectBrain(cwd, evidence) {
|
|
344
|
-
const now = nowIso();
|
|
345
|
-
const evidenceKeys = Object.keys(evidence).filter((k) => evidence[k] !== null);
|
|
346
|
-
const fp = buildFingerprint({ evidenceKeys });
|
|
347
|
-
|
|
348
|
-
return {
|
|
349
|
-
schemaVersion: BRAIN_SCHEMA,
|
|
350
|
-
generatedAt: now,
|
|
351
|
-
updatedAt: now,
|
|
352
|
-
projectSummary: "Avorelo local-first AI coding optimization runtime.",
|
|
353
|
-
activeConstraints: [
|
|
354
|
-
"No cloud sync",
|
|
355
|
-
"No daemon or background service",
|
|
356
|
-
"No LLM as source of truth",
|
|
357
|
-
"No applied claim without lifecycle receipt",
|
|
358
|
-
"No universal host support claims",
|
|
359
|
-
"No raw transcripts or secrets in artifacts",
|
|
360
|
-
],
|
|
361
|
-
canonicalAssumptions: [
|
|
362
|
-
"Evidence comes from existing local artifacts only.",
|
|
363
|
-
"Deterministic: same signals produce same results.",
|
|
364
|
-
"Fail-open: missing evidence returns null, not error.",
|
|
365
|
-
],
|
|
366
|
-
protectedBoundaries: [
|
|
367
|
-
"Do not touch public website, pricing, or launch copy.",
|
|
368
|
-
"Do not build Teams, billing, GrowthBook, or marketplace.",
|
|
369
|
-
"Do not add cloud sync or daemon.",
|
|
370
|
-
"Do not use LLM output as source of truth.",
|
|
371
|
-
],
|
|
372
|
-
evidenceRefs: evidenceKeys,
|
|
373
|
-
confidence: evidenceKeys.length > 0 ? 0.85 : 0.50,
|
|
374
|
-
limitations: [
|
|
375
|
-
"Project brain is generated from local artifacts at a point in time.",
|
|
376
|
-
"Constraints and boundaries may evolve — always check canonical docs first.",
|
|
377
|
-
],
|
|
378
|
-
sourceFingerprint: fp,
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
function loadDecisionRegister(cwd) {
|
|
383
|
-
try {
|
|
384
|
-
const absPath = path.join(cwd, DECISION_REGISTER_REL);
|
|
385
|
-
if (!fs.existsSync(absPath)) return [];
|
|
386
|
-
return fs
|
|
387
|
-
.readFileSync(absPath, "utf8")
|
|
388
|
-
.split("\n")
|
|
389
|
-
.filter(Boolean)
|
|
390
|
-
.map((ln) => {
|
|
391
|
-
try {
|
|
392
|
-
return JSON.parse(ln);
|
|
393
|
-
} catch {
|
|
394
|
-
return null;
|
|
395
|
-
}
|
|
396
|
-
})
|
|
397
|
-
.filter(Boolean);
|
|
398
|
-
} catch {
|
|
399
|
-
return [];
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
function writeDecisionRegister(cwd, decisions) {
|
|
404
|
-
const absPath = path.join(cwd, DECISION_REGISTER_REL);
|
|
405
|
-
fs.mkdirSync(path.dirname(absPath), { recursive: true });
|
|
406
|
-
const lines = decisions.map((d) => JSON.stringify(d)).join("\n");
|
|
407
|
-
fs.writeFileSync(absPath, lines ? lines + "\n" : "", "utf8");
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
// Merge new candidates into the existing register.
|
|
411
|
-
// Rules: update if status or decision text changed; append if new id.
|
|
412
|
-
// Stale/superseded decisions are preserved but excluded from next-run influence.
|
|
413
|
-
// Conflicting decisions are not silently overwritten — id collision is an update.
|
|
414
|
-
function mergeDecisions(existing, candidates) {
|
|
415
|
-
const byId = new Map(existing.map((d) => [d.id, d]));
|
|
416
|
-
for (const candidate of candidates) {
|
|
417
|
-
if (byId.has(candidate.id)) {
|
|
418
|
-
const prev = byId.get(candidate.id);
|
|
419
|
-
if (prev.status !== candidate.status || prev.decision !== candidate.decision) {
|
|
420
|
-
byId.set(candidate.id, { ...candidate, updatedAt: candidate.updatedAt });
|
|
421
|
-
}
|
|
422
|
-
// If identical, keep existing (preserve history)
|
|
423
|
-
} else {
|
|
424
|
-
byId.set(candidate.id, candidate);
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
return [...byId.values()];
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
function loadRiskRegister(cwd) {
|
|
431
|
-
try {
|
|
432
|
-
const absPath = path.join(cwd, RISK_REGISTER_REL);
|
|
433
|
-
const raw = JSON.parse(fs.readFileSync(absPath, "utf8"));
|
|
434
|
-
if (raw.schemaVersion !== RISK_SCHEMA) return { risks: [] };
|
|
435
|
-
return raw;
|
|
436
|
-
} catch {
|
|
437
|
-
return { risks: [] };
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
function buildRiskRegister(cwd, riskCandidates) {
|
|
442
|
-
const now = nowIso();
|
|
443
|
-
const existing = loadRiskRegister(cwd);
|
|
444
|
-
const byId = new Map((existing.risks || []).map((r) => [r.id, r]));
|
|
445
|
-
for (const candidate of riskCandidates) {
|
|
446
|
-
if (byId.has(candidate.id)) {
|
|
447
|
-
byId.set(candidate.id, { ...byId.get(candidate.id), lastSeen: now });
|
|
448
|
-
} else {
|
|
449
|
-
byId.set(candidate.id, candidate);
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
return {
|
|
453
|
-
schemaVersion: RISK_SCHEMA,
|
|
454
|
-
generatedAt: now,
|
|
455
|
-
updatedAt: now,
|
|
456
|
-
risks: [...byId.values()],
|
|
457
|
-
};
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
function loadCapabilityMap(cwd) {
|
|
461
|
-
try {
|
|
462
|
-
const absPath = path.join(cwd, CAPABILITY_MAP_REL);
|
|
463
|
-
const raw = JSON.parse(fs.readFileSync(absPath, "utf8"));
|
|
464
|
-
if (raw.schemaVersion !== CAPABILITY_SCHEMA) return { capabilities: [] };
|
|
465
|
-
return raw;
|
|
466
|
-
} catch {
|
|
467
|
-
return { capabilities: [] };
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
function buildCapabilityMap(cwd, capabilityCandidates) {
|
|
472
|
-
const now = nowIso();
|
|
473
|
-
return {
|
|
474
|
-
schemaVersion: CAPABILITY_SCHEMA,
|
|
475
|
-
generatedAt: now,
|
|
476
|
-
updatedAt: now,
|
|
477
|
-
capabilities: capabilityCandidates,
|
|
478
|
-
};
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
function loadLearningSummary(cwd) {
|
|
482
|
-
try {
|
|
483
|
-
const absPath = path.join(cwd, LEARNING_SUMMARY_REL);
|
|
484
|
-
const raw = JSON.parse(fs.readFileSync(absPath, "utf8"));
|
|
485
|
-
if (raw.schemaVersion !== SUMMARY_SCHEMA) return null;
|
|
486
|
-
return raw;
|
|
487
|
-
} catch {
|
|
488
|
-
return null;
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
function loadProjectBrain(cwd) {
|
|
493
|
-
try {
|
|
494
|
-
const absPath = path.join(cwd, BRAIN_REL);
|
|
495
|
-
const raw = JSON.parse(fs.readFileSync(absPath, "utf8"));
|
|
496
|
-
if (raw.schemaVersion !== BRAIN_SCHEMA) return null;
|
|
497
|
-
return raw;
|
|
498
|
-
} catch {
|
|
499
|
-
return null;
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
function buildLearningSummary(cwd, decisions, riskRegister, capabilities) {
|
|
504
|
-
const now = nowIso();
|
|
505
|
-
const risks = (riskRegister && riskRegister.risks) ? riskRegister.risks : riskRegister || [];
|
|
506
|
-
const activeDecisions = decisions.filter((d) => d.status === "active");
|
|
507
|
-
const activeRisks = risks.filter((r) => r.status === "active");
|
|
508
|
-
const staleItems = decisions.filter(
|
|
509
|
-
(d) => d.status === "stale" || d.status === "superseded"
|
|
510
|
-
);
|
|
511
|
-
|
|
512
|
-
// Top learning signals — bounded, sorted by confidence
|
|
513
|
-
const topSignals = activeDecisions
|
|
514
|
-
.sort((a, b) => b.confidence - a.confidence)
|
|
515
|
-
.slice(0, 3)
|
|
516
|
-
.map((d) => ({
|
|
517
|
-
type: "decision",
|
|
518
|
-
summary: d.decision.slice(0, 120),
|
|
519
|
-
confidence: d.confidence,
|
|
520
|
-
reasonCodes: d.reasonCodes,
|
|
521
|
-
}));
|
|
522
|
-
|
|
523
|
-
// How learning influences next-run defaults (bounded, reason-coded)
|
|
524
|
-
const nextRunInfluence = [];
|
|
525
|
-
|
|
526
|
-
const proofRequired = activeDecisions.find((d) => d.id === "dec_applied_requires_receipt");
|
|
527
|
-
if (proofRequired) {
|
|
528
|
-
nextRunInfluence.push({
|
|
529
|
-
type: "require_lifecycle_receipt",
|
|
530
|
-
text: "Require lifecycle receipt before claiming applied or improved.",
|
|
531
|
-
reasonCodes: ["LIFECYCLE_HONEST_CLAIM"],
|
|
532
|
-
});
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
const hostSpecific = activeDecisions.find((d) => d.id === "dec_host_support_is_host_specific");
|
|
536
|
-
if (hostSpecific) {
|
|
537
|
-
nextRunInfluence.push({
|
|
538
|
-
type: "host_support_wording",
|
|
539
|
-
text: "Host support wording remains host-specific — no universal claims.",
|
|
540
|
-
reasonCodes: ["HOST_SUPPORT_HOST_SPECIFIC"],
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
const ctxPressure = activeDecisions.find((d) => d.id === "dec_context_pressure_use_carryforward");
|
|
545
|
-
if (ctxPressure) {
|
|
546
|
-
nextRunInfluence.push({
|
|
547
|
-
type: "prefer_carryforward",
|
|
548
|
-
text: "Prefer carry-forward summary under context pressure.",
|
|
549
|
-
reasonCodes: ctxPressure.reasonCodes,
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
const fp = buildFingerprint({
|
|
554
|
-
activeDecisionCount: activeDecisions.length,
|
|
555
|
-
activeRiskCount: activeRisks.length,
|
|
556
|
-
capabilityCount: capabilities.length,
|
|
557
|
-
});
|
|
558
|
-
|
|
559
|
-
return {
|
|
560
|
-
schemaVersion: SUMMARY_SCHEMA,
|
|
561
|
-
generatedAt: now,
|
|
562
|
-
activeDecisionCount: activeDecisions.length,
|
|
563
|
-
activeRiskCount: activeRisks.length,
|
|
564
|
-
capabilityCount: capabilities.length,
|
|
565
|
-
staleItemCount: staleItems.length,
|
|
566
|
-
topLearningSignals: topSignals,
|
|
567
|
-
nextRunInfluence,
|
|
568
|
-
limitations: [
|
|
569
|
-
"Learning is evidence-backed but bounded — does not override user instructions.",
|
|
570
|
-
"Stale or superseded decisions are excluded from next-run influence.",
|
|
571
|
-
"Conflicting decisions are flagged, not silently overwritten.",
|
|
572
|
-
"Test fixtures are excluded from real learning candidates.",
|
|
573
|
-
],
|
|
574
|
-
sourceFingerprint: fp,
|
|
575
|
-
};
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
// ── Main generate function ────────────────────────────────────────────────────
|
|
579
|
-
|
|
580
|
-
function generateLearningArtifacts(cwd, options = {}) {
|
|
581
|
-
const evidence = collectLearningEvidence(cwd);
|
|
582
|
-
|
|
583
|
-
const decisionCandidates = generateDecisionCandidates(evidence);
|
|
584
|
-
const riskCandidates = generateRiskCandidates(evidence);
|
|
585
|
-
const capabilityCandidates = generateCapabilityCandidates(evidence);
|
|
586
|
-
|
|
587
|
-
// Project brain
|
|
588
|
-
const brain = buildProjectBrain(cwd, evidence);
|
|
589
|
-
const brainPath = path.join(cwd, BRAIN_REL);
|
|
590
|
-
fs.mkdirSync(path.dirname(brainPath), { recursive: true });
|
|
591
|
-
fs.writeFileSync(brainPath, JSON.stringify(brain, null, 2), "utf8");
|
|
592
|
-
|
|
593
|
-
// Decision register (merge into existing)
|
|
594
|
-
const existingDecisions = loadDecisionRegister(cwd);
|
|
595
|
-
const mergedDecisions = mergeDecisions(existingDecisions, decisionCandidates);
|
|
596
|
-
writeDecisionRegister(cwd, mergedDecisions);
|
|
597
|
-
|
|
598
|
-
// Risk register (merge into existing)
|
|
599
|
-
const riskRegister = buildRiskRegister(cwd, riskCandidates);
|
|
600
|
-
const riskPath = path.join(cwd, RISK_REGISTER_REL);
|
|
601
|
-
fs.mkdirSync(path.dirname(riskPath), { recursive: true });
|
|
602
|
-
fs.writeFileSync(riskPath, JSON.stringify(riskRegister, null, 2), "utf8");
|
|
603
|
-
|
|
604
|
-
// Capability map
|
|
605
|
-
const capabilityMap = buildCapabilityMap(cwd, capabilityCandidates);
|
|
606
|
-
const capPath = path.join(cwd, CAPABILITY_MAP_REL);
|
|
607
|
-
fs.mkdirSync(path.dirname(capPath), { recursive: true });
|
|
608
|
-
fs.writeFileSync(capPath, JSON.stringify(capabilityMap, null, 2), "utf8");
|
|
609
|
-
|
|
610
|
-
// Learning summary
|
|
611
|
-
const summary = buildLearningSummary(
|
|
612
|
-
cwd,
|
|
613
|
-
mergedDecisions,
|
|
614
|
-
riskRegister,
|
|
615
|
-
capabilityCandidates
|
|
616
|
-
);
|
|
617
|
-
const summaryPath = path.join(cwd, LEARNING_SUMMARY_REL);
|
|
618
|
-
fs.mkdirSync(path.dirname(summaryPath), { recursive: true });
|
|
619
|
-
fs.writeFileSync(summaryPath, JSON.stringify(summary, null, 2), "utf8");
|
|
620
|
-
|
|
621
|
-
return {
|
|
622
|
-
brain,
|
|
623
|
-
decisions: mergedDecisions,
|
|
624
|
-
risks: riskRegister,
|
|
625
|
-
capabilities: capabilityMap,
|
|
626
|
-
summary,
|
|
627
|
-
};
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
function formatLearningSummaryText(cwd) {
|
|
631
|
-
const summary = loadLearningSummary(cwd);
|
|
632
|
-
if (!summary) return null;
|
|
633
|
-
|
|
634
|
-
const lines = [
|
|
635
|
-
`Learning: ${summary.activeDecisionCount} active decision(s), ` +
|
|
636
|
-
`${summary.activeRiskCount} recurring risk(s), ${summary.capabilityCount} capability(ies).`,
|
|
637
|
-
];
|
|
638
|
-
|
|
639
|
-
if (summary.nextRunInfluence.length > 0) {
|
|
640
|
-
lines.push(` Next run influence: ${summary.nextRunInfluence[0].text}`);
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
return lines.join("\n");
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
function formatLearningSummaryStatusLine(cwd) {
|
|
647
|
-
const summary = loadLearningSummary(cwd);
|
|
648
|
-
if (!summary) return null;
|
|
649
|
-
return (
|
|
650
|
-
`Learning: ${summary.activeDecisionCount} decision(s), ` +
|
|
651
|
-
`${summary.activeRiskCount} risk(s), ${summary.capabilityCount} capability(ies)`
|
|
652
|
-
);
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
module.exports = {
|
|
656
|
-
BRAIN_SCHEMA,
|
|
657
|
-
DECISION_SCHEMA,
|
|
658
|
-
RISK_SCHEMA,
|
|
659
|
-
CAPABILITY_SCHEMA,
|
|
660
|
-
SUMMARY_SCHEMA,
|
|
661
|
-
BRAIN_REL,
|
|
662
|
-
DECISION_REGISTER_REL,
|
|
663
|
-
RISK_REGISTER_REL,
|
|
664
|
-
CAPABILITY_MAP_REL,
|
|
665
|
-
LEARNING_SUMMARY_REL,
|
|
666
|
-
SOURCE_ORDER,
|
|
667
|
-
DECISION_STATUSES,
|
|
668
|
-
collectLearningEvidence,
|
|
669
|
-
generateDecisionCandidates,
|
|
670
|
-
generateRiskCandidates,
|
|
671
|
-
generateCapabilityCandidates,
|
|
672
|
-
buildProjectBrain,
|
|
673
|
-
loadDecisionRegister,
|
|
674
|
-
writeDecisionRegister,
|
|
675
|
-
mergeDecisions,
|
|
676
|
-
buildRiskRegister,
|
|
677
|
-
loadRiskRegister,
|
|
678
|
-
buildCapabilityMap,
|
|
679
|
-
loadCapabilityMap,
|
|
680
|
-
buildLearningSummary,
|
|
681
|
-
loadLearningSummary,
|
|
682
|
-
loadProjectBrain,
|
|
683
|
-
generateLearningArtifacts,
|
|
684
|
-
formatLearningSummaryText,
|
|
685
|
-
formatLearningSummaryStatusLine,
|
|
686
|
-
};
|