avorelo 0.1.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 (258) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +56 -0
  3. package/bin/avorelo +9 -0
  4. package/package.json +135 -0
  5. package/scripts/README.md +40 -0
  6. package/scripts/cco-dashboard.js +252 -0
  7. package/scripts/cco-status.js +430 -0
  8. package/scripts/lib/activation/account-state.js +37 -0
  9. package/scripts/lib/activation/activation-runner.js +546 -0
  10. package/scripts/lib/activation/activation-self-healing.js +480 -0
  11. package/scripts/lib/activation/activation-state.js +83 -0
  12. package/scripts/lib/activation/activation-summary.js +191 -0
  13. package/scripts/lib/activation/adapters/claude-code.js +77 -0
  14. package/scripts/lib/activation/adapters/codex-cli.js +52 -0
  15. package/scripts/lib/activation/adapters/cursor.js +37 -0
  16. package/scripts/lib/activation/adapters/github-agent.js +39 -0
  17. package/scripts/lib/activation/adapters/terminal.js +42 -0
  18. package/scripts/lib/activation/adapters/vscode.js +39 -0
  19. package/scripts/lib/activation/adapters/windsurf.js +37 -0
  20. package/scripts/lib/activation/ai-surface-detector.js +151 -0
  21. package/scripts/lib/activation/connect-account.js +145 -0
  22. package/scripts/lib/activation/detect-environment.js +75 -0
  23. package/scripts/lib/activation/detect-hosts.js +62 -0
  24. package/scripts/lib/activation/format-activation-output.js +109 -0
  25. package/scripts/lib/activation/next-action.js +43 -0
  26. package/scripts/lib/activation/repair-engine.js +219 -0
  27. package/scripts/lib/activation-distribution-readiness.js +507 -0
  28. package/scripts/lib/adapter-conformance.js +176 -0
  29. package/scripts/lib/adapter-readiness.js +417 -0
  30. package/scripts/lib/adapter-safety-boundaries.js +335 -0
  31. package/scripts/lib/adapter-technical-readiness-gate.js +205 -0
  32. package/scripts/lib/agent-access-governance.js +455 -0
  33. package/scripts/lib/agent-enforcement.js +765 -0
  34. package/scripts/lib/agent-policy-profile.js +210 -0
  35. package/scripts/lib/agent-security/action-evaluator.js +507 -0
  36. package/scripts/lib/agent-security/adapter-registry.js +98 -0
  37. package/scripts/lib/agent-security/auto-policy.js +139 -0
  38. package/scripts/lib/agent-security/bounded-scan.js +93 -0
  39. package/scripts/lib/agent-security/enforcement-adapter.js +174 -0
  40. package/scripts/lib/agent-security/enforcement-engine.js +1129 -0
  41. package/scripts/lib/agent-security/file-write-adapter.js +183 -0
  42. package/scripts/lib/agent-security/file-write-rules.js +178 -0
  43. package/scripts/lib/agent-security/index.js +3342 -0
  44. package/scripts/lib/agent-security/instruction-risk.js +181 -0
  45. package/scripts/lib/agent-security/mcp-action-adapter.js +185 -0
  46. package/scripts/lib/agent-security/mcp-action-rules.js +184 -0
  47. package/scripts/lib/agent-security/package-action-adapter.js +175 -0
  48. package/scripts/lib/agent-security/package-action-rules.js +233 -0
  49. package/scripts/lib/agent-security/performance.js +148 -0
  50. package/scripts/lib/agent-security/permission-minimizer.js +403 -0
  51. package/scripts/lib/agent-security/scan-cache.js +74 -0
  52. package/scripts/lib/agent-security/source-trust.js +146 -0
  53. package/scripts/lib/ai-install-prompt.js +288 -0
  54. package/scripts/lib/ai-workspace-hygiene.js +1499 -0
  55. package/scripts/lib/alpha-activation.js +520 -0
  56. package/scripts/lib/alpha-feedback.js +263 -0
  57. package/scripts/lib/alpha-readiness-gate.js +332 -0
  58. package/scripts/lib/anti-gaming.js +169 -0
  59. package/scripts/lib/artifact-health.js +431 -0
  60. package/scripts/lib/attribution.js +180 -0
  61. package/scripts/lib/audit.js +289 -0
  62. package/scripts/lib/avorelo-skill-registry.js +810 -0
  63. package/scripts/lib/batch-jobs.js +71 -0
  64. package/scripts/lib/brain-pack.js +578 -0
  65. package/scripts/lib/brand-boundary.js +424 -0
  66. package/scripts/lib/brand.js +74 -0
  67. package/scripts/lib/browser-capability.js +1048 -0
  68. package/scripts/lib/browser-proof-preflight.js +321 -0
  69. package/scripts/lib/cache-readiness.js +187 -0
  70. package/scripts/lib/canonical-reentry.js +162 -0
  71. package/scripts/lib/capability-packs.js +314 -0
  72. package/scripts/lib/capability-recommender.js +512 -0
  73. package/scripts/lib/capability-registry.js +1059 -0
  74. package/scripts/lib/carry-forward-surfacing.js +194 -0
  75. package/scripts/lib/ccusage-adapter.js +188 -0
  76. package/scripts/lib/company-loop.js +1149 -0
  77. package/scripts/lib/config.js +637 -0
  78. package/scripts/lib/context-acquisition-plan.js +287 -0
  79. package/scripts/lib/context-budget-guard.js +170 -0
  80. package/scripts/lib/context-budget-scanner.js +257 -0
  81. package/scripts/lib/context-optimizer.js +715 -0
  82. package/scripts/lib/context-reduction-plan.js +178 -0
  83. package/scripts/lib/context-safety.js +88 -0
  84. package/scripts/lib/context-savings-engine.js +158 -0
  85. package/scripts/lib/cost-evidence.js +254 -0
  86. package/scripts/lib/cross-host-install-plan.js +308 -0
  87. package/scripts/lib/cross-host-install-readiness.js +237 -0
  88. package/scripts/lib/cross-host-value-flow.js +268 -0
  89. package/scripts/lib/dashboard.js +900 -0
  90. package/scripts/lib/design-partner-feedback.js +346 -0
  91. package/scripts/lib/entitlements.js +100 -0
  92. package/scripts/lib/execution-packet.js +559 -0
  93. package/scripts/lib/experimentation-events.js +547 -0
  94. package/scripts/lib/external-capability-compliance.js +107 -0
  95. package/scripts/lib/external-user-simulation.js +166 -0
  96. package/scripts/lib/failure-recovery-readiness.js +81 -0
  97. package/scripts/lib/failure-recovery.js +419 -0
  98. package/scripts/lib/feedback-intelligence.js +537 -0
  99. package/scripts/lib/feedback-signals.js +205 -0
  100. package/scripts/lib/file-integrity.js +68 -0
  101. package/scripts/lib/fsx.js +127 -0
  102. package/scripts/lib/full-readiness-gate.js +451 -0
  103. package/scripts/lib/guidance-builder.js +174 -0
  104. package/scripts/lib/hook-apply.js +1019 -0
  105. package/scripts/lib/hook-baseline.js +310 -0
  106. package/scripts/lib/hook-config-preview.js +275 -0
  107. package/scripts/lib/hook-contracts.js +290 -0
  108. package/scripts/lib/hook-safety-boundary-readiness.js +80 -0
  109. package/scripts/lib/host-capability-matrix.js +351 -0
  110. package/scripts/lib/host-support-context.js +254 -0
  111. package/scripts/lib/http-hook-action.js +538 -0
  112. package/scripts/lib/install-ai-readiness.js +84 -0
  113. package/scripts/lib/install-intake-risk.js +1037 -0
  114. package/scripts/lib/install-journey-intelligence.js +329 -0
  115. package/scripts/lib/intervention-guidance.js +57 -0
  116. package/scripts/lib/known-limitations.js +115 -0
  117. package/scripts/lib/l8-path-truth.js +146 -0
  118. package/scripts/lib/launch-hardening-gate.js +436 -0
  119. package/scripts/lib/launch-readiness.js +628 -0
  120. package/scripts/lib/learning-memory.js +686 -0
  121. package/scripts/lib/lifecycle-hooks.js +802 -0
  122. package/scripts/lib/local-package-smoke.js +423 -0
  123. package/scripts/lib/local-pricing.js +299 -0
  124. package/scripts/lib/mcp-enforcement.js +311 -0
  125. package/scripts/lib/mcp-least-privilege-policy.js +303 -0
  126. package/scripts/lib/mcp-tool-inventory.js +388 -0
  127. package/scripts/lib/mcp-tool-risk.js +0 -0
  128. package/scripts/lib/memory.js +335 -0
  129. package/scripts/lib/metrics.js +699 -0
  130. package/scripts/lib/micro-proof.js +133 -0
  131. package/scripts/lib/next-run-context.js +436 -0
  132. package/scripts/lib/operating-value.js +1648 -0
  133. package/scripts/lib/optimization-v3.js +122 -0
  134. package/scripts/lib/orchestration/adapters/_shared.js +49 -0
  135. package/scripts/lib/orchestration/adapters/aider.js +18 -0
  136. package/scripts/lib/orchestration/adapters/claude-code.js +35 -0
  137. package/scripts/lib/orchestration/adapters/codex.js +35 -0
  138. package/scripts/lib/orchestration/adapters/gemini-cli.js +18 -0
  139. package/scripts/lib/orchestration/adapters/git.js +25 -0
  140. package/scripts/lib/orchestration/adapters/index.js +31 -0
  141. package/scripts/lib/orchestration/adapters/lm-studio.js +18 -0
  142. package/scripts/lib/orchestration/adapters/ollama.js +18 -0
  143. package/scripts/lib/orchestration/adapters/opencode.js +18 -0
  144. package/scripts/lib/orchestration/adapters/openrouter.js +18 -0
  145. package/scripts/lib/orchestration/adapters/test-runner.js +25 -0
  146. package/scripts/lib/orchestration/cli.js +438 -0
  147. package/scripts/lib/orchestration/execution-manager.js +279 -0
  148. package/scripts/lib/orchestration/handoff.js +314 -0
  149. package/scripts/lib/orchestration/index.js +456 -0
  150. package/scripts/lib/orchestration/inventory.js +47 -0
  151. package/scripts/lib/orchestration/model-discovery.js +498 -0
  152. package/scripts/lib/orchestration/model-profiler.js +170 -0
  153. package/scripts/lib/orchestration/model-profiles.js +252 -0
  154. package/scripts/lib/orchestration/model-refresh-policy.js +72 -0
  155. package/scripts/lib/orchestration/proof-writer.js +349 -0
  156. package/scripts/lib/orchestration/provider-discovery/aider.js +49 -0
  157. package/scripts/lib/orchestration/provider-discovery/claude-code.js +56 -0
  158. package/scripts/lib/orchestration/provider-discovery/codex.js +49 -0
  159. package/scripts/lib/orchestration/provider-discovery/common.js +186 -0
  160. package/scripts/lib/orchestration/provider-discovery/gemini.js +106 -0
  161. package/scripts/lib/orchestration/provider-discovery/lm-studio.js +118 -0
  162. package/scripts/lib/orchestration/provider-discovery/models-dev.js +12 -0
  163. package/scripts/lib/orchestration/provider-discovery/ollama.js +100 -0
  164. package/scripts/lib/orchestration/provider-discovery/opencode.js +47 -0
  165. package/scripts/lib/orchestration/provider-discovery/openrouter.js +44 -0
  166. package/scripts/lib/orchestration/risk-classifier.js +130 -0
  167. package/scripts/lib/orchestration/routing-policy.js +486 -0
  168. package/scripts/lib/orchestration/settings.js +112 -0
  169. package/scripts/lib/orchestration/state.js +165 -0
  170. package/scripts/lib/orchestration/verification-manager.js +138 -0
  171. package/scripts/lib/output-profiles.js +146 -0
  172. package/scripts/lib/package-content-audit.js +368 -0
  173. package/scripts/lib/package-runtime.js +278 -0
  174. package/scripts/lib/plan-surface.js +53 -0
  175. package/scripts/lib/plans.js +2318 -0
  176. package/scripts/lib/policy-provider.js +27 -0
  177. package/scripts/lib/prelaunch-activation-readiness.js +409 -0
  178. package/scripts/lib/prelaunch-evidence-store.js +816 -0
  179. package/scripts/lib/prelaunch-intelligence.js +869 -0
  180. package/scripts/lib/pricing-experiment.js +118 -0
  181. package/scripts/lib/pro-moment-events.js +77 -0
  182. package/scripts/lib/pro-moment-state.js +227 -0
  183. package/scripts/lib/pro-moments.js +1216 -0
  184. package/scripts/lib/product-learning-events.js +629 -0
  185. package/scripts/lib/project-profile.js +555 -0
  186. package/scripts/lib/prompt-compiler.js +280 -0
  187. package/scripts/lib/prompt-lint.js +32 -0
  188. package/scripts/lib/prompt-suggestions.js +52 -0
  189. package/scripts/lib/proof-canonical.js +398 -0
  190. package/scripts/lib/proof-drilldown.js +383 -0
  191. package/scripts/lib/proof-events.js +342 -0
  192. package/scripts/lib/proof-history.js +243 -0
  193. package/scripts/lib/proof-metrics.js +296 -0
  194. package/scripts/lib/proof-outcome-evidence.js +134 -0
  195. package/scripts/lib/proof-receipt.js +335 -0
  196. package/scripts/lib/proof-record.js +461 -0
  197. package/scripts/lib/public-activation-distribution-gate.js +258 -0
  198. package/scripts/lib/public-cli.js +3891 -0
  199. package/scripts/lib/public-distribution-truth.js +211 -0
  200. package/scripts/lib/public-install-claim-checker.js +294 -0
  201. package/scripts/lib/publish-provenance-readiness.js +283 -0
  202. package/scripts/lib/readiness-delta.js +218 -0
  203. package/scripts/lib/readiness-evidence-closure.js +196 -0
  204. package/scripts/lib/reentry-memory-capture.js +241 -0
  205. package/scripts/lib/reentry-memory-retrieval.js +302 -0
  206. package/scripts/lib/reentry-memory-status.js +146 -0
  207. package/scripts/lib/reentry-memory-store.js +178 -0
  208. package/scripts/lib/reentry-state.js +66 -0
  209. package/scripts/lib/release-candidate-bundle.js +166 -0
  210. package/scripts/lib/remediation.js +81 -0
  211. package/scripts/lib/repo-map.js +391 -0
  212. package/scripts/lib/run-improvements-lifecycle.js +330 -0
  213. package/scripts/lib/run-improvements.js +789 -0
  214. package/scripts/lib/runtime-decision-policy.js +387 -0
  215. package/scripts/lib/safe-path-engine.js +705 -0
  216. package/scripts/lib/safe-run-controller.js +887 -0
  217. package/scripts/lib/score.js +262 -0
  218. package/scripts/lib/seamless-enforcement.js +329 -0
  219. package/scripts/lib/seamless-outcome.js +689 -0
  220. package/scripts/lib/seamless-reality-gate.js +5043 -0
  221. package/scripts/lib/security-risk-classifier.js +511 -0
  222. package/scripts/lib/security-scan.js +384 -0
  223. package/scripts/lib/session-context-optimizer.js +1211 -0
  224. package/scripts/lib/session-timing.js +315 -0
  225. package/scripts/lib/skill-hygiene.js +805 -0
  226. package/scripts/lib/skill-packs.js +161 -0
  227. package/scripts/lib/skills-operating-layer.js +580 -0
  228. package/scripts/lib/smart-work-routing.js +768 -0
  229. package/scripts/lib/source-catalog.js +700 -0
  230. package/scripts/lib/status-value-summary.js +32 -0
  231. package/scripts/lib/support-bundle.js +578 -0
  232. package/scripts/lib/task-continuation.js +440 -0
  233. package/scripts/lib/test-helpers.js +15 -0
  234. package/scripts/lib/tier.js +38 -0
  235. package/scripts/lib/token-context-quality-gate.js +370 -0
  236. package/scripts/lib/token-cost-capture.js +187 -0
  237. package/scripts/lib/token-cost-intelligence.js +358 -0
  238. package/scripts/lib/token-efficiency-evidence.js +213 -0
  239. package/scripts/lib/token-evidence.js +699 -0
  240. package/scripts/lib/tokenish.js +17 -0
  241. package/scripts/lib/tool-output-sandbox.js +304 -0
  242. package/scripts/lib/trust-audit.js +136 -0
  243. package/scripts/lib/unified-events.js +396 -0
  244. package/scripts/lib/upgrade-interruption-recovery.js +407 -0
  245. package/scripts/lib/usage-ledger.js +201 -0
  246. package/scripts/lib/value-ledger.js +130 -0
  247. package/scripts/lib/value-proof-calibration.js +531 -0
  248. package/scripts/lib/visual-qa.js +231 -0
  249. package/scripts/lib/voice-alpha.js +29 -0
  250. package/scripts/lib/work-aware-orchestration.js +976 -0
  251. package/scripts/lib/work-control-receipts.js +577 -0
  252. package/scripts/lib/work-ledger.js +1123 -0
  253. package/scripts/lib/work-panel-preview.js +352 -0
  254. package/scripts/lib/workflow-discipline.js +280 -0
  255. package/scripts/lib/workflow-signals.js +419 -0
  256. package/scripts/lib/workspace-map.js +281 -0
  257. package/scripts/lib/workspace-registry.js +1367 -0
  258. package/scripts/lib/workspace-resolver.js +480 -0
@@ -0,0 +1,451 @@
1
+ "use strict";
2
+
3
+ // ── Full Readiness / Release Candidate Gate ───────────────────────────────────
4
+ // Contract: avorelo.fullReadinessGate.v1
5
+ // Consumes all existing signals and makes a formal go/no-go release candidate
6
+ // determination. Local-only. Redacted. No public launch claim.
7
+
8
+ const fs = require("fs");
9
+ const path = require("path");
10
+ const { nowIso } = require("./fsx");
11
+ const { appendProductLearningEvent } = require("./product-learning-events");
12
+
13
+ const CONTRACT = "avorelo.fullReadinessGate.v1";
14
+ const SCHEMA_VERSION = 1;
15
+ const GATE_DIR_REL = ".claude/cco/orchestration/full-readiness";
16
+ const ARTIFACT_REL = GATE_DIR_REL + "/latest-gate.json";
17
+ const SCORE_READY = 85;
18
+ const SCORE_WARN = 70;
19
+
20
+ function safeReadJson(absPath) {
21
+ try {
22
+ if (!fs.existsSync(absPath)) return null;
23
+ return JSON.parse(fs.readFileSync(absPath, "utf8").replace(/^/, ""));
24
+ } catch { return null; }
25
+ }
26
+
27
+ function collectFullReadinessSignals(cwd, options) {
28
+ options = options || {};
29
+ function read(rel) { return safeReadJson(path.join(cwd, rel)); }
30
+ var proofOutcomeEvidence = null;
31
+ var installAiReadiness = null;
32
+ var failureRecoveryReadiness = null;
33
+ var hookSafetyBoundaryReadiness = null;
34
+ try {
35
+ var poe = require("./proof-outcome-evidence");
36
+ proofOutcomeEvidence = poe.buildProofOutcomeEvidence(cwd);
37
+ poe.writeProofOutcomeEvidence(cwd, proofOutcomeEvidence);
38
+ } catch (e) {}
39
+ try { installAiReadiness = require("./install-ai-readiness").buildInstallAiReadiness(cwd); } catch (e) {}
40
+ try { failureRecoveryReadiness = require("./failure-recovery-readiness").buildFailureRecoveryReadiness(cwd); } catch (e) {}
41
+ try { hookSafetyBoundaryReadiness = require("./hook-safety-boundary-readiness").buildHookSafetyBoundaryReadiness(cwd); } catch (e) {}
42
+ return {
43
+ prelaunchIntelligence: read(".claude/cco/orchestration/prelaunch-intelligence/latest-intelligence.json"),
44
+ feedbackIntelligence: read(".claude/cco/orchestration/prelaunch-intelligence/latest-feedback-intelligence.json"),
45
+ tokenCostIntelligence: read(".claude/cco/orchestration/prelaunch-intelligence/latest-token-cost-intelligence.json"),
46
+ installJourneyIntelligence: read(".claude/cco/orchestration/prelaunch-intelligence/latest-install-journey.json"),
47
+ installPrompt: read(".claude/cco/orchestration/ai-install/latest-prompt.json"),
48
+ installAiReadiness: installAiReadiness,
49
+ prelaunchReadiness: read(".claude/cco/orchestration/prelaunch-readiness/latest-activation-readiness.json"),
50
+ activation: read(".claude/cco/orchestration/activation/latest-activation.json"),
51
+ alphaReadiness: read(".claude/cco/orchestration/alpha-readiness/latest-gate.json"),
52
+ launchHardening: read(".claude/cco/orchestration/launch-hardening/latest-gate.json"),
53
+ failureRecovery: read(".claude/cco/orchestration/failure-recovery/latest-recovery.json"),
54
+ failureRecoveryReadiness: failureRecoveryReadiness,
55
+ artifactHealth: read(".claude/cco/orchestration/artifact-health/latest-health.json"),
56
+ tokenEfficiency: read(".claude/cco/orchestration/token-efficiency/latest-evidence.json"),
57
+ tokenQualityGate: read(".claude/cco/orchestration/token-efficiency/latest-quality-gate.json"),
58
+ mcpInventory: read(".claude/cco/orchestration/mcp-tool-governance/latest-inventory.json"),
59
+ mcpRisk: read(".claude/cco/orchestration/mcp-tool-governance/latest-risk.json"),
60
+ mcpPolicy: read(".claude/cco/orchestration/mcp-tool-governance/latest-policy.json"),
61
+ hookDoctor: read(".claude/cco/orchestration/hook-apply/latest-doctor.json"),
62
+ hookSafetyBoundaryReadiness: hookSafetyBoundaryReadiness,
63
+ supportBundle: read(".claude/cco/support/latest-support-bundle.json"),
64
+ valueSummary: read(".claude/cco/orchestration/seamless-outcome/latest-value-summary.json"),
65
+ realityGate: read(".claude/cco/orchestration/seamless-outcome/latest-reality-gate.json"),
66
+ proofOutcomeEvidence: proofOutcomeEvidence,
67
+ companyLoop: read(".claude/cco/orchestration/company-loop/latest-report.json"),
68
+ activationDistribution: (function() { try { var adr = require("./activation-distribution-readiness"); return adr.buildActivationDistributionSurface(cwd, {}); } catch(e) { return null; } })(),
69
+ publicDistributionGate: (function() {
70
+ try { return safeReadJson(path.join(cwd, ".claude/cco/orchestration/public-distribution/latest-gate.json")); } catch(e) { return null; }
71
+ })(),
72
+ adapterTechnicalReadiness: (function() {
73
+ try { return safeReadJson(path.join(cwd, ".claude/cco/orchestration/adapter-readiness/latest-technical-gate.json")); } catch(e) { return null; }
74
+ })(),
75
+ };
76
+ }
77
+
78
+ function checkInstallAi(signals) {
79
+ var readiness = signals.installAiReadiness;
80
+ if (readiness) {
81
+ if (readiness.status === "pass") return { id: "install_ai", status: "pass", message: "AI install path present with explicit approval boundaries" };
82
+ return {
83
+ id: "install_ai",
84
+ status: "warn",
85
+ message: "AI install path exists but still has internal readiness gaps",
86
+ safeNextAction: (readiness.safeNextActions && readiness.safeNextActions[0]) || "Run: node bin/avorelo install-ai --json",
87
+ };
88
+ }
89
+ var s = signals.installPrompt;
90
+ if (!s) return { id: "install_ai", status: "warn", message: "AI install prompt not generated", safeNextAction: "Run: node bin/avorelo install-ai --json" };
91
+ var ok = s.activationAvailable === true && s.prelaunchAvailable === true && Array.isArray(s.approvalBoundaries) && s.approvalBoundaries.length > 0;
92
+ if (!ok) return { id: "install_ai", status: "warn", message: "AI install prompt exists but approval boundaries unclear", safeNextAction: "Run: node bin/avorelo install-ai --json" };
93
+ return { id: "install_ai", status: "pass", message: "AI install prompt present with approval boundaries" };
94
+ }
95
+
96
+ function checkFirstValue(signals) {
97
+ var s = signals.prelaunchReadiness;
98
+ if (!s) return { id: "first_value", status: "warn", message: "First value check not run", safeNextAction: "Run: node bin/avorelo first-value-check --json" };
99
+ var fv = s.firstValuePath || s.firstValue || s.firstValueJourney;
100
+ if (!fv) return { id: "first_value", status: "warn", message: "First value path not confirmed", safeNextAction: "Run: node bin/avorelo first-value-check --json" };
101
+ return { id: "first_value", status: "pass", message: "First value path confirmed" };
102
+ }
103
+
104
+ function checkPrelaunchActivation(signals) {
105
+ var s = signals.prelaunchReadiness;
106
+ if (!s) return { id: "prelaunch_activation", status: "warn", message: "Prelaunch activation readiness not run", safeNextAction: "Run: node bin/avorelo prelaunch-readiness --json" };
107
+ if (s.status !== "ready" && s.status !== "warn" && s.status !== "pass") return { id: "prelaunch_activation", status: "blocked", message: "Prelaunch readiness status: " + (s.status || "unknown"), safeNextAction: "Run: node bin/avorelo prelaunch-readiness --json and resolve blockers" };
108
+ return { id: "prelaunch_activation", status: (s.status === "ready" || s.status === "pass") ? "pass" : "warn", message: "Prelaunch readiness: " + s.status };
109
+ }
110
+
111
+ function checkPrelaunchIntelligence(signals) {
112
+ var s = signals.prelaunchIntelligence;
113
+ if (!s) return { id: "prelaunch_intelligence", status: "warn", message: "Prelaunch intelligence not run", safeNextAction: "Run: node bin/avorelo prelaunch-intelligence --json" };
114
+ var score = s.score || 0;
115
+ if ((s.missingEvidence || []).length > 0) {
116
+ return {
117
+ id: "prelaunch_intelligence",
118
+ status: "warn",
119
+ message: "Prelaunch intelligence has unresolved evidence gaps",
120
+ safeNextAction: (s.safeNextActions && s.safeNextActions[0]) || "Run: node bin/avorelo prelaunch-intelligence --json",
121
+ };
122
+ }
123
+ if (score >= SCORE_READY) return { id: "prelaunch_intelligence", status: "pass", message: "Intelligence score: " + score };
124
+ return { id: "prelaunch_intelligence", status: "warn", message: "Intelligence score: " + score + " (below " + SCORE_READY + " ready threshold)", safeNextAction: "Run dogfood feedback pass then rerun prelaunch-intelligence" };
125
+ }
126
+
127
+ function checkLaunchHardening(signals) {
128
+ var s = signals.launchHardening;
129
+ if (!s) return { id: "launch_hardening", status: "warn", message: "Launch hardening gate not run", safeNextAction: "Run: node bin/avorelo launch-hardening --json" };
130
+ if ((s.summary && s.summary.fail || 0) > 0) return { id: "launch_hardening", status: "blocked", message: "Launch hardening has " + s.summary.fail + " failures", safeNextAction: "Run: node bin/avorelo launch-hardening --json and resolve failures" };
131
+ return { id: "launch_hardening", status: "pass", message: "Launch hardening pass: " + (s.summary && s.summary.pass || 0) + ", warn: " + (s.summary && s.summary.warn || 0) };
132
+ }
133
+
134
+ function checkFailureRecovery(signals) {
135
+ var readiness = signals.failureRecoveryReadiness;
136
+ if (readiness) {
137
+ if (readiness.status === "pass") return { id: "failure_recovery", status: "pass", message: "Failure recovery path and support surfaces are internally ready" };
138
+ return {
139
+ id: "failure_recovery",
140
+ status: "warn",
141
+ message: "Failure recovery path still has internal readiness gaps",
142
+ safeNextAction: (readiness.safeNextActions && readiness.safeNextActions[0]) || "Run: node bin/avorelo launch-hardening --json",
143
+ };
144
+ }
145
+ var s = signals.failureRecovery;
146
+ if (!s) return { id: "failure_recovery", status: "warn", message: "Failure recovery plan not generated", safeNextAction: "Run: node bin/avorelo launch-hardening --json" };
147
+ return { id: "failure_recovery", status: "pass", message: "Failure recovery plan present" };
148
+ }
149
+
150
+ function checkTokenContextQuality(signals) {
151
+ var s = signals.tokenQualityGate;
152
+ var e = signals.tokenEfficiency;
153
+ if (!s && !e) return { id: "token_context_quality", status: "warn", message: "Token/context quality gate not run", safeNextAction: "Run: node bin/avorelo token-efficiency --json" };
154
+ if (s && s.summary && s.summary.fail > 0) return { id: "token_context_quality", status: "blocked", message: "Token quality gate has " + s.summary.fail + " failures", safeNextAction: "Run: node bin/avorelo token-efficiency --json and resolve failures" };
155
+ return { id: "token_context_quality", status: "pass", message: "Token/context quality checks passing" };
156
+ }
157
+
158
+ function checkTokenCostDiscipline(signals) {
159
+ var s = signals.tokenCostIntelligence;
160
+ if (!s) return { id: "token_cost_discipline", status: "warn", message: "Token/cost intelligence not available", safeNextAction: "Run: node bin/avorelo token-cost --json" };
161
+ if (s.noExactSavingsClaim === false) return { id: "token_cost_discipline", status: "blocked", message: "Exact savings claimed without verified source", safeNextAction: "Remove exact savings claims" };
162
+ if ((s.realUsageSamplesCount || 0) === 0) {
163
+ return {
164
+ id: "token_cost_discipline",
165
+ status: "warn",
166
+ message: "Token/cost evidence is " + (s.evidenceMode || s.evidenceLevel || "missing") + " and still lacks measured real usage samples",
167
+ safeNextAction: (s.safeNextActions && s.safeNextActions[0]) || "Run: node bin/avorelo token-cost import --file <redacted-json-or-jsonl> --json",
168
+ evidenceLevel: s.evidenceLevel || "not_available",
169
+ };
170
+ }
171
+ if (s.status === "not_available" || s.evidenceLevel === "not_available") return { id: "token_cost_discipline", status: "warn", message: "Token/cost evidence not_available — acceptable if caveated", evidenceLevel: "not_available" };
172
+ return { id: "token_cost_discipline", status: "pass", message: "Token/cost evidence: " + (s.evidenceLevel || s.status) };
173
+ }
174
+
175
+ function checkMcpToolGovernance(signals) {
176
+ var inv = signals.mcpInventory;
177
+ var risk = signals.mcpRisk;
178
+ var policy = signals.mcpPolicy;
179
+ if (!inv && !risk && !policy) return { id: "mcp_tool_governance", status: "warn", message: "MCP governance not run", safeNextAction: "Run: node bin/avorelo mcp doctor --json" };
180
+ if (risk && (risk.highCritical || 0) > 0) return { id: "mcp_tool_governance", status: "blocked", message: "MCP has " + risk.highCritical + " high/critical risk tools", safeNextAction: "Run: node bin/avorelo mcp doctor --json and resolve high/critical risks" };
181
+ return { id: "mcp_tool_governance", status: "pass", message: "MCP governance active. Risk: " + (risk && risk.status || "pass") };
182
+ }
183
+
184
+ function checkHookSafetyBoundaries(signals) {
185
+ var readiness = signals.hookSafetyBoundaryReadiness;
186
+ if (readiness) {
187
+ if (readiness.status === "pass") return { id: "hook_safety_boundaries", status: "pass", message: "Hook safety boundaries are enforced and explicit" };
188
+ return {
189
+ id: "hook_safety_boundaries",
190
+ status: "warn",
191
+ message: "Hook safety boundaries still need internal verification",
192
+ safeNextAction: (readiness.safeNextActions && readiness.safeNextActions[0]) || "Run: node bin/avorelo hooks doctor --json",
193
+ };
194
+ }
195
+ var s = signals.hookDoctor;
196
+ if (!s) return { id: "hook_safety_boundaries", status: "warn", message: "Hook doctor not run — hooks require explicit approval", safeNextAction: "Run: node bin/avorelo hooks doctor --json" };
197
+ if (s.summary && s.summary.fail > 0) return { id: "hook_safety_boundaries", status: "blocked", message: "Hook safety boundary check failed", safeNextAction: "Run: node bin/avorelo hooks doctor --json and resolve failures" };
198
+ return { id: "hook_safety_boundaries", status: "pass", message: "Hook safety boundaries enforced — hooks require explicit approval" };
199
+ }
200
+
201
+ function checkSupportBundleRedaction(signals) {
202
+ var s = signals.supportBundle;
203
+ if (!s) return { id: "support_bundle_redaction", status: "warn", message: "Support bundle not generated", safeNextAction: "Run: node bin/avorelo support-bundle --json" };
204
+ if (s.redacted !== true) return { id: "support_bundle_redaction", status: "blocked", message: "Support bundle is not marked redacted", safeNextAction: "Run: node bin/avorelo support-bundle --json" };
205
+ return { id: "support_bundle_redaction", status: "pass", message: "Support bundle present and redacted" };
206
+ }
207
+
208
+ function checkProofOutcomeEvidence(signals) {
209
+ var s = signals.proofOutcomeEvidence;
210
+ if (!s || s.latestProofAvailable !== true) {
211
+ return {
212
+ id: "proof_outcome_evidence",
213
+ status: "warn",
214
+ message: "No proof/value summary generated from a completed real task",
215
+ safeNextAction: (s && s.safeNextActions && s.safeNextActions[0]) || "Run: node bin/avorelo proof after completing a real task",
216
+ redacted: true,
217
+ };
218
+ }
219
+ if (s.status !== "pass") {
220
+ return {
221
+ id: "proof_outcome_evidence",
222
+ status: "warn",
223
+ message: "Proof/value summary exists but readiness evidence is still incomplete",
224
+ safeNextAction: (s.safeNextActions && s.safeNextActions[0]) || "Run: node bin/avorelo outcome --gate --json",
225
+ redacted: true,
226
+ };
227
+ }
228
+ return {
229
+ id: "proof_outcome_evidence",
230
+ status: "pass",
231
+ message: "Proof/value summary present and evidence-backed",
232
+ redacted: true,
233
+ };
234
+ }
235
+
236
+ function checkFeedbackIntelligence(signals) {
237
+ var s = signals.feedbackIntelligence;
238
+ if (!s) return { id: "feedback_intelligence", status: "warn", message: "Feedback intelligence not run", safeNextAction: "Run: node bin/avorelo feedback intake-pack --json" };
239
+ if ((s.qualifiedFeedbackItemsCount || 0) === 0 || s.status === "insufficient_data") {
240
+ return {
241
+ id: "feedback_intelligence",
242
+ status: "warn",
243
+ message: "Feedback insufficient — no qualified redacted feedback evidence exists",
244
+ safeNextAction: (s.safeNextActions && s.safeNextActions[0]) || "Run: node bin/avorelo feedback intake-pack --json",
245
+ evidenceLevel: "insufficient_data",
246
+ };
247
+ }
248
+ if (s.hasBlockerSeverity === true) return { id: "feedback_intelligence", status: "warn", message: "Feedback has blocker-severity friction", safeNextAction: "Address feedback blockers then rerun" };
249
+ return { id: "feedback_intelligence", status: "pass", message: "Feedback clusters: " + (s.clustersFound || 0) };
250
+ }
251
+
252
+ function checkCompanyLoopRecommendation(signals) {
253
+ var s = signals.companyLoop;
254
+ if (!s) return { id: "company_loop_recommendation", status: "warn", message: "Company loop not run", safeNextAction: "Run: node bin/avorelo company-loop --json" };
255
+ var rec = (s.nextPrRecommendation && s.nextPrRecommendation.recommendedNextPr) || s.recommendedNextPr;
256
+ return { id: "company_loop_recommendation", status: "pass", message: "Company loop recommendation: " + (rec || "present"), recommendation: rec || null };
257
+ }
258
+
259
+ function checkKnownLimitations(signals, options) {
260
+ options = options || {};
261
+ var limitations = options.knownLimitations || null;
262
+ if (!limitations) return { id: "known_limitations", status: "warn", message: "Known limitations register not yet built", safeNextAction: "Run: node bin/avorelo known-limitations --json" };
263
+ var blockerLimits = (limitations.limitations || []).filter(function(l) { return l.severity === "blocker" && l.status !== "accepted"; });
264
+ if (blockerLimits.length > 0) return { id: "known_limitations", status: "blocked", message: blockerLimits.length + " unmitigated blocker limitations", safeNextAction: "Resolve blocker limitations before release candidate", blockerCount: blockerLimits.length };
265
+ return { id: "known_limitations", status: "pass", message: "Known limitations documented: " + (limitations.limitations || []).length, count: (limitations.limitations || []).length };
266
+ }
267
+
268
+ function checkNoFalseClaims(signals) {
269
+ var tci = signals.tokenCostIntelligence;
270
+ var intel = signals.prelaunchIntelligence;
271
+ var pi = signals.prelaunchReadiness;
272
+ if ((tci && tci.noExactSavingsClaim === false) || (intel && intel.noExactSavingsClaim === false) || (pi && pi.noExactSavingsClaim === false)) {
273
+ return { id: "no_false_claims", status: "blocked", message: "Exact savings claimed without verified billing source", safeNextAction: "Remove exact savings claims" };
274
+ }
275
+ if ((intel && intel.noPublicLaunchClaim === false) || (pi && pi.noPublicLaunchClaim === false)) {
276
+ return { id: "no_false_claims", status: "blocked", message: "Public launch ready claimed before gate passes", safeNextAction: "Remove public launch claim" };
277
+ }
278
+ return { id: "no_false_claims", status: "pass", message: "No false claims detected" };
279
+ }
280
+
281
+
282
+ function checkAdapterTechnicalReadiness(signals) {
283
+ var id = "adapter_technical_readiness";
284
+ var s = signals.adapterTechnicalReadiness;
285
+ if (!s) return { id: id, status: "warn", message: "Adapter technical readiness gate not yet run.", safeNextAction: "Run: node bin/avorelo adapter-readiness-technical --json" };
286
+ if (s.status === "blocked") return { id: id, status: "blocked", message: "Adapter technical readiness blocked (" + (s.blockerCount || s.totalBlockers || 0) + " blockers).", safeNextAction: s.safeNextAction || "Run: node bin/avorelo adapter-readiness-technical --json and fix blockers." };
287
+ if (s.verdict === "adapter_ready") return { id: id, status: "pass", message: "Adapter technical readiness: ready (score " + s.score + "/100).", safeNextAction: null };
288
+ return { id: id, status: "warn", message: "Adapter technical readiness: " + s.status + " (score " + (s.score || "?") + "/100).", safeNextAction: s.safeNextAction || "Run: node bin/avorelo adapter-readiness-technical --json" };
289
+ }
290
+
291
+ function checkActivationDistributionReadiness(signals) {
292
+ var id = "activation_distribution_readiness";
293
+ var s = signals.activationDistribution;
294
+ if (!s) return { id: id, status: "warn", message: "Activation distribution readiness not yet run.", safeNextAction: "Run: node bin/avorelo activation-distribution --json" };
295
+ if (s.status === "blocked") return { id: id, status: "blocked", message: "Activation distribution readiness is blocked (" + (s.blockerCount || 0) + " blockers).", safeNextAction: s.safeNextActions && s.safeNextActions[0] || "Run: node bin/avorelo activation-distribution --json and fix blockers." };
296
+ if (s.status === "ready") return { id: id, status: "pass", message: "Activation distribution readiness: ready (score " + s.score + ").", safeNextAction: null };
297
+ return { id: id, status: "warn", message: "Activation distribution readiness: " + s.status + " (score " + (s.score || "?") + ").", safeNextAction: s.safeNextActions && s.safeNextActions[0] || "Run: node bin/avorelo activation-distribution --json" };
298
+ }
299
+
300
+ function checkPublicDistributionGate(signals) {
301
+ var id = "public_distribution_gate";
302
+ var s = signals.publicDistributionGate;
303
+ if (!s) return { id: id, status: "warn", message: "Public distribution truth gate not yet run.", safeNextAction: "Run: node bin/avorelo public-distribution --json" };
304
+ // Only block full readiness if distribution gate is truly blocked (false install claims, forbidden files, broken bin)
305
+ if (s.status === "blocked") return { id: id, status: "blocked", message: "Public distribution gate blocked (" + (s.blockers || []).length + " blockers).", safeNextAction: s.safeNextAction || "Run: node bin/avorelo public-distribution --json and fix blockers." };
306
+ // local_only, warn, or pending are all acceptable — package is not yet public
307
+ if (s.status === "local_only" || s.status === "pending") return { id: id, status: "pass", message: "Public distribution: " + s.status + " (private package, local install verified).", safeNextAction: null };
308
+ if (s.status === "ready") return { id: id, status: "pass", message: "Public distribution gate: ready (score " + s.score + ").", safeNextAction: null };
309
+ return { id: id, status: "warn", message: "Public distribution: " + s.status + " (score " + (s.score || "?") + ").", safeNextAction: s.safeNextAction || "Run: node bin/avorelo public-distribution --json" };
310
+ }
311
+
312
+ var CHECK_WEIGHTS = { install_ai: 10, first_value: 8, prelaunch_activation: 10, prelaunch_intelligence: 12, launch_hardening: 10, failure_recovery: 5, token_context_quality: 8, token_cost_discipline: 5, mcp_tool_governance: 8, hook_safety_boundaries: 8, support_bundle_redaction: 5, proof_outcome_evidence: 5, feedback_intelligence: 3, company_loop_recommendation: 2, known_limitations: 5, no_false_claims: 10, activation_distribution_readiness: 8, public_distribution_gate: 5, adapter_technical_readiness: 5 };
313
+ var TOTAL_WEIGHT = Object.values(CHECK_WEIGHTS).reduce(function(a, b) { return a + b; }, 0);
314
+
315
+ function scoreFullReadiness(checks) {
316
+ var earned = 0;
317
+ for (var i = 0; i < checks.length; i++) {
318
+ var w = CHECK_WEIGHTS[checks[i].id] || 0;
319
+ if (checks[i].status === "pass") earned += w;
320
+ else if (checks[i].status === "warn") earned += w * 0.6;
321
+ }
322
+ return Math.round((earned / TOTAL_WEIGHT) * 100);
323
+ }
324
+
325
+ function runFullReadinessGate(cwd, options) {
326
+ options = options || {};
327
+ var signals = collectFullReadinessSignals(cwd, options);
328
+ var knownLimitations = options.knownLimitations || null;
329
+ var checks = [
330
+ checkInstallAi(signals), checkFirstValue(signals), checkPrelaunchActivation(signals),
331
+ checkPrelaunchIntelligence(signals), checkLaunchHardening(signals), checkFailureRecovery(signals),
332
+ checkTokenContextQuality(signals), checkTokenCostDiscipline(signals), checkMcpToolGovernance(signals),
333
+ checkHookSafetyBoundaries(signals), checkSupportBundleRedaction(signals), checkProofOutcomeEvidence(signals),
334
+ checkFeedbackIntelligence(signals), checkCompanyLoopRecommendation(signals),
335
+ checkKnownLimitations(signals, { knownLimitations: knownLimitations }), checkNoFalseClaims(signals),
336
+ checkActivationDistributionReadiness(signals), checkPublicDistributionGate(signals),
337
+ checkAdapterTechnicalReadiness(signals),
338
+ ].map(function(check) { return Object.assign({ redacted: true }, check); });
339
+ var score = scoreFullReadiness(checks);
340
+ var blockers = checks.filter(function(c) { return c.status === "blocked"; });
341
+ var warnings = checks.filter(function(c) { return c.status === "warn"; });
342
+ var passes = checks.filter(function(c) { return c.status === "pass"; });
343
+ var evidenceRefs = [
344
+ ".claude/cco/orchestration/prelaunch-intelligence/latest-intelligence.json",
345
+ ".claude/cco/orchestration/prelaunch-readiness/latest-activation-readiness.json",
346
+ ".claude/cco/orchestration/launch-hardening/latest-gate.json",
347
+ ".claude/cco/orchestration/mcp-tool-governance/latest-policy.json",
348
+ ".claude/cco/orchestration/token-efficiency/latest-evidence.json",
349
+ ".claude/cco/support/latest-support-bundle.json",
350
+ ".claude/cco/orchestration/seamless-outcome/latest-value-summary.json",
351
+ ".claude/cco/orchestration/company-loop/latest-report.json",
352
+ ].filter(function(r) { return fs.existsSync(path.join(cwd, r)); });
353
+
354
+ var status, releaseCandidateStatus;
355
+ if (blockers.length > 0) { status = "blocked"; releaseCandidateStatus = "candidate_blocked"; }
356
+ else if (score >= SCORE_READY) {
357
+ var hasSparse = signals.feedbackIntelligence && signals.feedbackIntelligence.status === "insufficient_data" &&
358
+ (signals.tokenCostIntelligence && (signals.tokenCostIntelligence.status === "not_available" || signals.tokenCostIntelligence.evidenceLevel === "not_available"));
359
+ if (hasSparse) { status = "warn"; releaseCandidateStatus = "candidate_warn"; }
360
+ else { status = "ready"; releaseCandidateStatus = "candidate_ready"; }
361
+ } else if (score >= SCORE_WARN) { status = "warn"; releaseCandidateStatus = "candidate_warn"; }
362
+ else { status = "insufficient_data"; releaseCandidateStatus = "insufficient_data"; }
363
+
364
+ var decision;
365
+ if (status === "ready") decision = "Release candidate criteria met. Evidence supports proceeding to distribution readiness.";
366
+ else if (status === "warn") decision = "Not release-candidate ready yet. Incomplete evidence but no hard blockers.";
367
+ else if (status === "blocked") decision = "Blocked by " + blockers.length + " hard blocker(s). Resolve before proceeding.";
368
+ else decision = "Insufficient evidence to make a release candidate determination.";
369
+
370
+ var recommendedNextPr;
371
+ var evidenceOnlyWarnings = ["feedback_intelligence", "token_cost_discipline", "proof_outcome_evidence", "prelaunch_intelligence"];
372
+ var nonEvidenceWarnings = warnings.filter(function(w) { return evidenceOnlyWarnings.indexOf(w.id) === -1; });
373
+ if (status !== "blocked" && blockers.length === 0 && warnings.length > 0 && nonEvidenceWarnings.length === 0) recommendedNextPr = "GrowthBook Provider + Exposure Events";
374
+ else if (warnings.some(function(w) { return w.id === "feedback_intelligence"; })) recommendedNextPr = "Operational: Import real design-partner feedback";
375
+ else if (warnings.some(function(w) { return w.id === "token_cost_discipline"; })) recommendedNextPr = "Operational: Capture/import real token-cost evidence";
376
+ else if (warnings.some(function(w) { return w.id === "proof_outcome_evidence"; })) recommendedNextPr = "Operational: Run proof after a real bounded task";
377
+ else if (status === "ready" || (status === "warn" && blockers.length === 0)) recommendedNextPr = "Activation Distribution Readiness v1";
378
+ else if (blockers.some(function(b) { return b.id === "mcp_tool_governance" || b.id === "hook_safety_boundaries"; })) recommendedNextPr = "Repair: MCP/Hook safety";
379
+ else recommendedNextPr = "Dogfood / Feedback Collection pass";
380
+
381
+ var firstBlocker = blockers[0];
382
+ var firstWarning = warnings[0];
383
+ var safeNextAction = (firstBlocker && firstBlocker.safeNextAction) || (firstWarning && firstWarning.safeNextAction) || "Run: node bin/avorelo release-candidate-bundle --json for full summary";
384
+
385
+ var gate = {
386
+ contract: CONTRACT, schemaVersion: SCHEMA_VERSION, createdAt: nowIso(),
387
+ status: status, releaseCandidateStatus: releaseCandidateStatus, score: score, decision: decision,
388
+ checks: checks, blockers: blockers, warnings: warnings, passes: passes.map(function(p) { return p.id; }),
389
+ evidenceRefs: evidenceRefs,
390
+ knownLimitationsRef: ".claude/cco/orchestration/full-readiness/latest-known-limitations.json",
391
+ recommendedNextPr: recommendedNextPr, safeNextAction: safeNextAction,
392
+ knownLimitationsCount: knownLimitations ? (knownLimitations.limitations || []).length : 0,
393
+ noPublicLaunchClaim: true, noReleaseReadyClaimUnlessPassed: true, redacted: true,
394
+ };
395
+
396
+ try { appendProductLearningEvent(cwd, { eventName: "full_readiness_gate_run", category: "full_readiness", status: status, score: score, blockerCount: blockers.length, warningCount: warnings.length }); } catch (e) {}
397
+ return gate;
398
+ }
399
+
400
+ function writeFullReadinessGate(cwd, gate) {
401
+ var dir = path.join(cwd, GATE_DIR_REL);
402
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
403
+ fs.writeFileSync(path.join(cwd, ARTIFACT_REL), JSON.stringify(gate, null, 2));
404
+ return gate;
405
+ }
406
+
407
+ function buildFullReadinessSurface(cwd, options) {
408
+ options = options || {};
409
+ var gate = safeReadJson(path.join(cwd, ARTIFACT_REL));
410
+ if (!gate) return { status: "not_available", score: null, releaseCandidateStatus: "insufficient_data", blockerCount: 0, warningCount: 0, knownLimitationsCount: 0, recommendedNextPr: null };
411
+ return { status: gate.status, score: gate.score, releaseCandidateStatus: gate.releaseCandidateStatus, blockerCount: (gate.blockers || []).length, warningCount: (gate.warnings || []).length, knownLimitationsCount: gate.knownLimitationsCount || 0, recommendedNextPr: gate.recommendedNextPr, blockers: gate.blockers, noPublicLaunchClaim: true };
412
+ }
413
+
414
+ function formatFullReadinessText(gate, options) {
415
+ options = options || {};
416
+ var debug = options.debug === true;
417
+ var lines = [];
418
+ lines.push("Full readiness: " + gate.status);
419
+ lines.push("Score: " + gate.score);
420
+ lines.push("");
421
+ lines.push("Decision:");
422
+ lines.push(" " + gate.decision);
423
+ if (gate.blockers.length > 0) {
424
+ lines.push(""); lines.push("Blockers:");
425
+ gate.blockers.forEach(function(b) { lines.push(" - " + b.message); if (b.safeNextAction) lines.push(" Next: " + b.safeNextAction); });
426
+ } else { lines.push(""); lines.push("Blockers:"); lines.push(" none"); }
427
+ if (gate.warnings.length > 0) {
428
+ lines.push(""); lines.push("Warnings:");
429
+ gate.warnings.forEach(function(w) { lines.push(" - " + w.message); });
430
+ }
431
+ if (debug) {
432
+ lines.push(""); lines.push("Checks:");
433
+ gate.checks.forEach(function(c) { lines.push(" " + c.status.padEnd(8) + " " + c.id + ": " + c.message); });
434
+ lines.push(""); lines.push("Evidence refs: " + gate.evidenceRefs.length);
435
+ lines.push("Release candidate status: " + gate.releaseCandidateStatus);
436
+ }
437
+ lines.push(""); lines.push("Next:"); lines.push(" " + gate.safeNextAction); lines.push(""); lines.push("No public launch claim.");
438
+ return lines.join("\n");
439
+ }
440
+
441
+ module.exports = {
442
+ CONTRACT, SCHEMA_VERSION, ARTIFACT_REL, GATE_DIR_REL, SCORE_READY, SCORE_WARN,
443
+ runFullReadinessGate, collectFullReadinessSignals, scoreFullReadiness,
444
+ writeFullReadinessGate, buildFullReadinessSurface, formatFullReadinessText,
445
+ checkInstallAi, checkFirstValue, checkPrelaunchActivation, checkPrelaunchIntelligence,
446
+ checkLaunchHardening, checkFailureRecovery, checkTokenContextQuality, checkTokenCostDiscipline,
447
+ checkMcpToolGovernance, checkHookSafetyBoundaries, checkSupportBundleRedaction,
448
+ checkProofOutcomeEvidence, checkFeedbackIntelligence, checkCompanyLoopRecommendation,
449
+ checkKnownLimitations, checkNoFalseClaims, checkActivationDistributionReadiness,
450
+ checkAdapterTechnicalReadiness, checkPublicDistributionGate,
451
+ };
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+
3
+ const { formatNextBoundedAction } = require("./proof-canonical");
4
+
5
+ function extractContinueField(text, label) {
6
+ const pattern = new RegExp(`^${label}:\\s*(.+)$`, "mi");
7
+ const match = String(text || "").match(pattern);
8
+ return match ? String(match[1]).trim() : "";
9
+ }
10
+
11
+ function parseContinueNote(text) {
12
+ if (!String(text || "").trim()) return null;
13
+
14
+ const whatHappened = extractContinueField(text, "What happened");
15
+ const nextAction = extractContinueField(text, "Next");
16
+ const preservedState = extractContinueField(text, "Preserved");
17
+ const artifactPath = extractContinueField(text, "Artifact");
18
+
19
+ if (!whatHappened && !nextAction && !preservedState && !artifactPath) {
20
+ return null;
21
+ }
22
+
23
+ return {
24
+ whatHappened,
25
+ nextAction,
26
+ preservedState,
27
+ artifactPath: artifactPath || null,
28
+ };
29
+ }
30
+
31
+ function buildFreshStartGuidance(onboardingReady) {
32
+ const lines = ["## Avorelo Session Guidance", ""];
33
+
34
+ if (onboardingReady) {
35
+ lines.push("Fresh start.");
36
+ lines.push("");
37
+ lines.push("Run /avorelo-init, then avorelo status.");
38
+ lines.push("Avorelo should stay quiet unless it needs to intervene or guide recovery.");
39
+ return { text: lines.join("\n"), hasResume: false };
40
+ }
41
+
42
+ lines.push("Fresh start.");
43
+ lines.push("");
44
+ lines.push("Continue working normally.");
45
+ lines.push("Use avorelo status if you want a quick check before the next step.");
46
+ lines.push("Avorelo should stay quiet unless it needs to intervene or guide recovery.");
47
+ return { text: lines.join("\n"), hasResume: false };
48
+ }
49
+
50
+ function buildCanonicalReentryGuidance(input = {}, parsedContinueNote = null) {
51
+ const canonicalReentry =
52
+ input.canonicalReentry && input.canonicalReentry.is_canonical_truth_available
53
+ ? input.canonicalReentry
54
+ : null;
55
+ if (!canonicalReentry) return null;
56
+
57
+ const carryForward = input.carryForward || null;
58
+ const reentryState = input.reentryState || null;
59
+ const lines = ["## Avorelo Session Guidance", "", "**Current bounded state**"];
60
+ const nextAction =
61
+ canonicalReentry.next_bounded_action_text ||
62
+ formatNextBoundedAction(canonicalReentry.next_bounded_action) ||
63
+ parsedContinueNote?.nextAction ||
64
+ reentryState?.nextAction ||
65
+ "Run avorelo status to inspect the current bounded state.";
66
+ const preservedState =
67
+ parsedContinueNote?.preservedState ||
68
+ (carryForward?.toolHistory?.toolNames?.length
69
+ ? `Recent tool context was preserved: ${carryForward.toolHistory.toolNames.join(", ")}.`
70
+ : null);
71
+ const artifactPath =
72
+ canonicalReentry.state_source ||
73
+ parsedContinueNote?.artifactPath ||
74
+ reentryState?.primaryArtifactPath ||
75
+ null;
76
+
77
+ if (canonicalReentry.where_am_i_now) {
78
+ lines.push(`- Where am I now: ${canonicalReentry.where_am_i_now}`);
79
+ }
80
+ if (canonicalReentry.what_can_i_honestly_claim) {
81
+ lines.push(`- Honest claim: ${canonicalReentry.what_can_i_honestly_claim}`);
82
+ }
83
+ if (canonicalReentry.reentry_status) {
84
+ lines.push(`- Re-entry: ${canonicalReentry.reentry_status}`);
85
+ }
86
+ lines.push(`- Next: ${nextAction}`);
87
+ if (canonicalReentry.latest_trustworthy_run_id) {
88
+ lines.push(`- Trustworthy run: ${canonicalReentry.latest_trustworthy_run_id}`);
89
+ }
90
+ if (canonicalReentry.readiness_state) {
91
+ lines.push(`- Readiness: ${canonicalReentry.readiness_state}`);
92
+ }
93
+ if (canonicalReentry.rollback_available === true) {
94
+ const rollbackSuffix = canonicalReentry.rollback_trigger ? ` (${canonicalReentry.rollback_trigger})` : "";
95
+ lines.push(`- Rollback: available${rollbackSuffix}.`);
96
+ }
97
+ if (preservedState) {
98
+ lines.push(`- Preserved: ${preservedState}`);
99
+ }
100
+ if (artifactPath) {
101
+ lines.push(`- Artifact: ${artifactPath}`);
102
+ }
103
+ if (reentryState?.unresolvedRisk) {
104
+ lines.push("- Risk: unresolved review still needs attention before the next unsafe step.");
105
+ }
106
+ lines.push("");
107
+ lines.push("Avorelo is active. Continue with the next bounded step.");
108
+
109
+ return {
110
+ text: lines.join("\n"),
111
+ hasResume: true,
112
+ usedCanonicalTruth: true,
113
+ };
114
+ }
115
+
116
+ function buildStartGuidance(input = {}) {
117
+ const carryForward = input.carryForward || null;
118
+ const reentryState = input.reentryState || null;
119
+ const continueNote = parseContinueNote(input.continueNoteText || "");
120
+ const onboardingReady = input.onboardingReady === true;
121
+ const canonicalGuidance = buildCanonicalReentryGuidance(input, continueNote);
122
+ if (canonicalGuidance) {
123
+ return canonicalGuidance;
124
+ }
125
+
126
+ const lines = ["## Avorelo Session Guidance", ""];
127
+
128
+ const hasResume = Boolean(continueNote || reentryState || carryForward);
129
+ if (!hasResume) {
130
+ return buildFreshStartGuidance(onboardingReady);
131
+ }
132
+
133
+ const whatHappened =
134
+ continueNote?.whatHappened ||
135
+ (reentryState?.lastInterventionType && reentryState.lastInterventionType !== "none"
136
+ ? `The last session ended after ${reentryState.lastInterventionType.replace(/_/g, " ")}.`
137
+ : "The last session left a bounded continuation cue.");
138
+ const nextAction =
139
+ continueNote?.nextAction ||
140
+ reentryState?.nextAction ||
141
+ "Run avorelo status to continue.";
142
+ const preservedState =
143
+ continueNote?.preservedState ||
144
+ (carryForward?.toolHistory?.toolNames?.length
145
+ ? `Recent tool context was preserved: ${carryForward.toolHistory.toolNames.join(", ")}.`
146
+ : "Bounded local evidence from the last session was preserved.");
147
+ const artifactPath =
148
+ continueNote?.artifactPath ||
149
+ reentryState?.primaryArtifactPath ||
150
+ null;
151
+
152
+ lines.push("**Resume cue**");
153
+ lines.push(`- What happened: ${whatHappened}`);
154
+ lines.push(`- Next: ${nextAction}`);
155
+ lines.push(`- Preserved: ${preservedState}`);
156
+ if (artifactPath) {
157
+ lines.push(`- Artifact: ${artifactPath}`);
158
+ }
159
+ if (reentryState?.unresolvedRisk) {
160
+ lines.push("- Risk: unresolved risk still needs review before the next unsafe step.");
161
+ }
162
+ lines.push("");
163
+ lines.push("Avorelo is active. Continue with the next bounded step.");
164
+
165
+ return {
166
+ text: lines.join("\n"),
167
+ hasResume: true,
168
+ };
169
+ }
170
+
171
+ module.exports = {
172
+ buildStartGuidance,
173
+ parseContinueNote,
174
+ };