segreant 0.0.0-stage → 0.2.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 (349) hide show
  1. package/LICENSE +116 -0
  2. package/LICENSING.md +62 -0
  3. package/README.md +315 -2
  4. package/baselines/lift-baselines.json +22 -0
  5. package/bin/publication-lock.mjs +748 -0
  6. package/bin/runtime-snapshot.mjs +266 -0
  7. package/bin/segreant-statusline.mjs +20 -0
  8. package/bin/segreant.mjs +96 -0
  9. package/dist/alerts/detect.js +245 -0
  10. package/dist/alerts/notify.js +66 -0
  11. package/dist/alloc/apply.js +0 -0
  12. package/dist/alloc/epistemic.js +154 -0
  13. package/dist/alloc/exact.js +714 -0
  14. package/dist/alloc/rules.js +0 -0
  15. package/dist/billing/countermodels.js +123 -0
  16. package/dist/billing/epistemic.js +636 -0
  17. package/dist/billing/importer.js +75 -0
  18. package/dist/billing/mapping.js +239 -0
  19. package/dist/billing/openaiCosts.js +352 -0
  20. package/dist/billing/openaiCostsCoverage.js +108 -0
  21. package/dist/billing/readiness.js +68 -0
  22. package/dist/billing/reconcile.js +414 -0
  23. package/dist/billing/scope.js +68 -0
  24. package/dist/billing/types.js +180 -0
  25. package/dist/budget/allocate.js +100 -0
  26. package/dist/budget/capDecision.js +457 -0
  27. package/dist/budget/controlLock.js +71 -0
  28. package/dist/budget/enforceability.js +39 -0
  29. package/dist/budget/guard.js +313 -0
  30. package/dist/budget/onlineControl.js +404 -0
  31. package/dist/budget/recommend.js +153 -0
  32. package/dist/capital.js +220 -0
  33. package/dist/causal/assignment.js +179 -0
  34. package/dist/causal/design.js +161 -0
  35. package/dist/causal/epistemic.js +428 -0
  36. package/dist/causal/estimand.js +64 -0
  37. package/dist/causal/estimate.js +237 -0
  38. package/dist/causal/family.js +61 -0
  39. package/dist/causal/identity.js +18 -0
  40. package/dist/causal/inference-ledger.js +400 -0
  41. package/dist/causal/ledger.js +201 -0
  42. package/dist/causal/measurement.js +150 -0
  43. package/dist/causal/ope.js +297 -0
  44. package/dist/causal/precision.js +206 -0
  45. package/dist/causal/producer.js +774 -0
  46. package/dist/causal/protocol.js +962 -0
  47. package/dist/causal/qualification.js +260 -0
  48. package/dist/causal/records.js +416 -0
  49. package/dist/causal/registry.js +58 -0
  50. package/dist/causal/sequential.js +679 -0
  51. package/dist/causal/transport.js +138 -0
  52. package/dist/causal/types.js +10 -0
  53. package/dist/cli/allocCmd.js +340 -0
  54. package/dist/cli/askModelPrices.js +59 -0
  55. package/dist/cli/backupCmd.js +100 -0
  56. package/dist/cli/basisLines.js +45 -0
  57. package/dist/cli/billingCmd.js +1007 -0
  58. package/dist/cli/capitalCmd.js +65 -0
  59. package/dist/cli/causalCmd.js +340 -0
  60. package/dist/cli/connectCmd.js +466 -0
  61. package/dist/cli/controlCmd.js +341 -0
  62. package/dist/cli/diagnosticsCmd.js +41 -0
  63. package/dist/cli/economicCmd.js +384 -0
  64. package/dist/cli/egressCmd.js +248 -0
  65. package/dist/cli/evidenceCmd.js +157 -0
  66. package/dist/cli/featuresCmd.js +53 -0
  67. package/dist/cli/flags.js +128 -0
  68. package/dist/cli/homeCmd.js +117 -0
  69. package/dist/cli/importCmd.js +657 -0
  70. package/dist/cli/launchCmd.js +90 -0
  71. package/dist/cli/marketCmd.js +178 -0
  72. package/dist/cli/opsCmd.js +335 -0
  73. package/dist/cli/outcomeCmd.js +120 -0
  74. package/dist/cli/packCmd.js +172 -0
  75. package/dist/cli/planCmd.js +181 -0
  76. package/dist/cli/pluginCmd.js +145 -0
  77. package/dist/cli/pricingDeclareCmd.js +178 -0
  78. package/dist/cli/quotaCmd.js +190 -0
  79. package/dist/cli/retention.js +28 -0
  80. package/dist/cli/runCmd.js +591 -0
  81. package/dist/cli/showCmd.js +500 -0
  82. package/dist/cli/teamCmd.js +760 -0
  83. package/dist/cli/ui.js +128 -0
  84. package/dist/cli/valueCmd.js +1001 -0
  85. package/dist/cli.js +628 -0
  86. package/dist/config.js +677 -0
  87. package/dist/connect/antigravity.js +310 -0
  88. package/dist/connect/claudeCode.js +218 -0
  89. package/dist/connect/codex.js +320 -0
  90. package/dist/connect/connectors.js +285 -0
  91. package/dist/connect/importShared.js +283 -0
  92. package/dist/connect/opencode.js +214 -0
  93. package/dist/connect/protobuf.js +126 -0
  94. package/dist/connect/registry.js +46 -0
  95. package/dist/connect/repoRoot.js +112 -0
  96. package/dist/cost/basis.js +168 -0
  97. package/dist/cost/coverage.js +53 -0
  98. package/dist/cost/declarations.js +37 -0
  99. package/dist/cost/exactPricing.js +132 -0
  100. package/dist/cost/firstSight.js +98 -0
  101. package/dist/cost/overrides.js +230 -0
  102. package/dist/cost/pricing.js +997 -0
  103. package/dist/cost/reprice.js +130 -0
  104. package/dist/dashboard/claim-support.js +271 -0
  105. package/dist/dashboard/contracts.js +211 -0
  106. package/dist/dashboard/routes.js +2004 -0
  107. package/dist/dashboard/server.js +76 -0
  108. package/dist/dashboard/sessions.js +345 -0
  109. package/dist/dashboard/settings.js +109 -0
  110. package/dist/dashboard/shared-types.js +6 -0
  111. package/dist/dashboard/static.js +111 -0
  112. package/dist/dashboard/value-cache.js +105 -0
  113. package/dist/dashboard/web/app/components/claimInspector.js +138 -0
  114. package/dist/dashboard/web/app/components/drawer.js +284 -0
  115. package/dist/dashboard/web/app/components/ruleFields.js +144 -0
  116. package/dist/dashboard/web/app/components/spine.js +163 -0
  117. package/dist/dashboard/web/app/components/workflow.js +82 -0
  118. package/dist/dashboard/web/app/core/actions.js +1021 -0
  119. package/dist/dashboard/web/app/core/api.js +164 -0
  120. package/dist/dashboard/web/app/core/chain.js +40 -0
  121. package/dist/dashboard/web/app/core/claimLayers.js +392 -0
  122. package/dist/dashboard/web/app/core/claimTypes.js +222 -0
  123. package/dist/dashboard/web/app/core/dom.js +138 -0
  124. package/dist/dashboard/web/app/core/fmt.js +159 -0
  125. package/dist/dashboard/web/app/core/focus.js +10 -0
  126. package/dist/dashboard/web/app/core/generated-contract.js +211 -0
  127. package/dist/dashboard/web/app/core/generated-payload-contract.js +4579 -0
  128. package/dist/dashboard/web/app/core/generated-types.js +8 -0
  129. package/dist/dashboard/web/app/core/griffin.js +10 -0
  130. package/dist/dashboard/web/app/core/jobs.js +12 -0
  131. package/dist/dashboard/web/app/core/period.js +35 -0
  132. package/dist/dashboard/web/app/core/periodWords.js +10 -0
  133. package/dist/dashboard/web/app/core/periods.js +32 -0
  134. package/dist/dashboard/web/app/core/pricingActions.js +264 -0
  135. package/dist/dashboard/web/app/core/privacyText.js +78 -0
  136. package/dist/dashboard/web/app/core/reconcileWords.js +63 -0
  137. package/dist/dashboard/web/app/core/registry.js +337 -0
  138. package/dist/dashboard/web/app/core/signal.js +140 -0
  139. package/dist/dashboard/web/app/core/slug.js +9 -0
  140. package/dist/dashboard/web/app/core/theme.js +48 -0
  141. package/dist/dashboard/web/app/core/view.js +69 -0
  142. package/dist/dashboard/web/app/main.js +362 -0
  143. package/dist/dashboard/web/app/views/allocation.js +278 -0
  144. package/dist/dashboard/web/app/views/control.js +249 -0
  145. package/dist/dashboard/web/app/views/data.js +136 -0
  146. package/dist/dashboard/web/app/views/evidence.js +553 -0
  147. package/dist/dashboard/web/app/views/privacy.js +13 -0
  148. package/dist/dashboard/web/app/views/spend.js +143 -0
  149. package/dist/dashboard/web/app/views/statement.js +189 -0
  150. package/dist/dashboard/web/app/views/system.js +80 -0
  151. package/dist/dashboard/web/app/views/value.js +534 -0
  152. package/dist/dashboard/web/app/views/workbench.js +312 -0
  153. package/dist/dashboard/web/classic.html +2151 -0
  154. package/dist/dashboard/web/index.html +51 -0
  155. package/dist/dashboard/web/styles/app.css +1336 -0
  156. package/dist/decision/assurance.js +425 -0
  157. package/dist/decision/control.js +336 -0
  158. package/dist/decision/countermodels.js +118 -0
  159. package/dist/decision/engine.js +382 -0
  160. package/dist/decision/epistemic.js +546 -0
  161. package/dist/demo/seed.js +741 -0
  162. package/dist/diagnostics.js +236 -0
  163. package/dist/economics/attribution.js +201 -0
  164. package/dist/economics/close.js +133 -0
  165. package/dist/economics/corrections.js +120 -0
  166. package/dist/economics/epistemic.js +164 -0
  167. package/dist/economics/events.js +294 -0
  168. package/dist/economics/fx.js +245 -0
  169. package/dist/economics/ledger.js +1516 -0
  170. package/dist/economics/money.js +177 -0
  171. package/dist/economics/rate.js +331 -0
  172. package/dist/economics/request.js +89 -0
  173. package/dist/economics/serialization.js +99 -0
  174. package/dist/egress/policy.js +192 -0
  175. package/dist/egress/proxyHealth.js +36 -0
  176. package/dist/egress/receipts.js +871 -0
  177. package/dist/egress/ruleValidation.js +127 -0
  178. package/dist/egress/transport.js +395 -0
  179. package/dist/epistemic/abstract.js +432 -0
  180. package/dist/epistemic/admissibility.js +213 -0
  181. package/dist/epistemic/assumption.js +134 -0
  182. package/dist/epistemic/claim-uses.js +202 -0
  183. package/dist/epistemic/claim.js +264 -0
  184. package/dist/epistemic/countermodel.js +278 -0
  185. package/dist/epistemic/dag.js +421 -0
  186. package/dist/epistemic/derivation.js +391 -0
  187. package/dist/epistemic/evidence.js +254 -0
  188. package/dist/epistemic/grain.js +82 -0
  189. package/dist/epistemic/issuance-map.js +260 -0
  190. package/dist/epistemic/ledger.js +1489 -0
  191. package/dist/epistemic/obligation.js +149 -0
  192. package/dist/epistemic/preservation.js +178 -0
  193. package/dist/epistemic/profile.js +61 -0
  194. package/dist/epistemic/revocation.js +65 -0
  195. package/dist/epistemic/scope.js +66 -0
  196. package/dist/epistemic/serialization.js +171 -0
  197. package/dist/epistemic/state.js +46 -0
  198. package/dist/epistemic/time.js +37 -0
  199. package/dist/epistemic/ux.js +104 -0
  200. package/dist/epistemic/witness.js +176 -0
  201. package/dist/export/allocationCsv.js +70 -0
  202. package/dist/export/billingCsv.js +36 -0
  203. package/dist/export/csv.js +52 -0
  204. package/dist/export/economic.js +105 -0
  205. package/dist/export/focusBilling.js +66 -0
  206. package/dist/export/statementCsv.js +104 -0
  207. package/dist/git/completeness.js +78 -0
  208. package/dist/git/contribution.js +598 -0
  209. package/dist/git/correlate.js +286 -0
  210. package/dist/git/quality.js +467 -0
  211. package/dist/git/repoScope.js +207 -0
  212. package/dist/git/survivalStore.js +186 -0
  213. package/dist/githubActionsEvidence.js +234 -0
  214. package/dist/guide.js +159 -0
  215. package/dist/judge/call.js +161 -0
  216. package/dist/judge/orchestrate.js +127 -0
  217. package/dist/judge/payload.js +47 -0
  218. package/dist/judge/tier.js +107 -0
  219. package/dist/judge/transcript.js +324 -0
  220. package/dist/market/consensus.js +181 -0
  221. package/dist/market/market.js +323 -0
  222. package/dist/market/refresh.js +119 -0
  223. package/dist/market/sources.js +236 -0
  224. package/dist/market/zip.js +98 -0
  225. package/dist/measurement/completeness.js +125 -0
  226. package/dist/measurement/model.js +113 -0
  227. package/dist/measurement/registry.js +166 -0
  228. package/dist/measurement/surrogate.js +325 -0
  229. package/dist/outcomes/contract.js +107 -0
  230. package/dist/outcomes/registry.js +259 -0
  231. package/dist/outcomes/work-unit.js +42 -0
  232. package/dist/pack/canonical.js +63 -0
  233. package/dist/pack/export.js +120 -0
  234. package/dist/pack/index.js +5 -0
  235. package/dist/pack/manifest.js +77 -0
  236. package/dist/pack/signature.js +69 -0
  237. package/dist/pack/types.js +455 -0
  238. package/dist/pack/verifier.js +275 -0
  239. package/dist/plans/detect.js +147 -0
  240. package/dist/plugins/contract.js +497 -0
  241. package/dist/plugins/host.js +333 -0
  242. package/dist/plugins/index.js +4 -0
  243. package/dist/plugins/intake.js +137 -0
  244. package/dist/plugins/invocation.js +158 -0
  245. package/dist/plugins/isolation.js +203 -0
  246. package/dist/proxy/server.js +891 -0
  247. package/dist/proxy/stream-proposals.js +249 -0
  248. package/dist/proxy/usage.js +213 -0
  249. package/dist/quota/limits.js +138 -0
  250. package/dist/quota/statusline.js +68 -0
  251. package/dist/quota/view.js +122 -0
  252. package/dist/research/complexity/calibration.js +110 -0
  253. package/dist/research/complexity/lab.js +134 -0
  254. package/dist/research/complexity/profile.js +78 -0
  255. package/dist/research/economics/budgetRisk.js +100 -0
  256. package/dist/research/economics/capital.js +101 -0
  257. package/dist/research/economics/decisionLedger.js +103 -0
  258. package/dist/research/economics/decomposition.js +106 -0
  259. package/dist/research/economics/execution.js +42 -0
  260. package/dist/research/economics/frontier.js +113 -0
  261. package/dist/research/economics/metricSafety.js +74 -0
  262. package/dist/research/economics/offPolicy.js +120 -0
  263. package/dist/research/economics/promotion.js +85 -0
  264. package/dist/scan/knownApps.js +113 -0
  265. package/dist/scan/scan.js +220 -0
  266. package/dist/store/allocation.js +543 -0
  267. package/dist/store/backup.js +368 -0
  268. package/dist/store/billing.js +919 -0
  269. package/dist/store/causal.js +2547 -0
  270. package/dist/store/causalLineage.js +912 -0
  271. package/dist/store/causalProducer.js +462 -0
  272. package/dist/store/db.js +2726 -0
  273. package/dist/store/economicReadModel.js +270 -0
  274. package/dist/store/ope.js +67 -0
  275. package/dist/store/realization.js +379 -0
  276. package/dist/store/rows.js +52 -0
  277. package/dist/store/schema.js +2218 -0
  278. package/dist/store/scopeEvidence.js +67 -0
  279. package/dist/team/ledger-evidence.js +82 -0
  280. package/dist/team/rollup.js +496 -0
  281. package/dist/team/standardize.js +115 -0
  282. package/dist/util/json.js +24 -0
  283. package/dist/util/pool.js +19 -0
  284. package/dist/util/quiet.js +18 -0
  285. package/dist/util/resource-limits.js +113 -0
  286. package/dist/util/statements.js +61 -0
  287. package/dist/util/time.js +7 -0
  288. package/dist/util/transaction.js +68 -0
  289. package/dist/value/anytime.js +106 -0
  290. package/dist/value/characterization.js +77 -0
  291. package/dist/value/cohort.js +212 -0
  292. package/dist/value/drift.js +211 -0
  293. package/dist/value/epistemic.js +448 -0
  294. package/dist/value/frontier.js +513 -0
  295. package/dist/value/gates.js +276 -0
  296. package/dist/value/instrumentationSensitivity.js +76 -0
  297. package/dist/value/lenses.js +398 -0
  298. package/dist/value/lift.js +206 -0
  299. package/dist/value/liftBaseline.js +355 -0
  300. package/dist/value/liftEfficiency.js +68 -0
  301. package/dist/value/marginal.js +154 -0
  302. package/dist/value/proposals.js +263 -0
  303. package/dist/value/realization.js +1159 -0
  304. package/dist/value/receipt.js +222 -0
  305. package/dist/value/receiptReconciliation.js +117 -0
  306. package/dist/value/reliability.js +101 -0
  307. package/dist/value/report.js +338 -0
  308. package/dist/value/selfReported.js +224 -0
  309. package/dist/value/sourceDepth.js +25 -0
  310. package/dist/value/taskType.js +46 -0
  311. package/dist/value/timeReclaimed.js +90 -0
  312. package/dist/value/usage.js +281 -0
  313. package/dist/version.js +20 -0
  314. package/docs/ALLOCATION.md +263 -0
  315. package/docs/ARCHITECTURE.md +452 -0
  316. package/docs/BILLING-EVIDENCE-IMPORT.md +274 -0
  317. package/docs/CAPABILITY-EVIDENCE-CONTRACT.md +220 -0
  318. package/docs/CAUSAL-EVIDENCE-PROTOCOL.md +295 -0
  319. package/docs/CAUSAL-PRODUCER-CONTRACT.md +128 -0
  320. package/docs/CLI-JSON-CONTRACT.md +38 -0
  321. package/docs/COMPATIBILITY.md +64 -0
  322. package/docs/DATA-BOUNDARIES.md +300 -0
  323. package/docs/EVIDENCE-PROVENANCE.md +40 -0
  324. package/docs/FAQ.md +275 -0
  325. package/docs/FOCUS-COMPATIBILITY.md +15 -0
  326. package/docs/GETTING-STARTED.md +236 -0
  327. package/docs/GUIDE.md +830 -0
  328. package/docs/INTEGRATIONS.md +233 -0
  329. package/docs/MARKET-SOURCES.md +142 -0
  330. package/docs/METHODOLOGY.md +166 -0
  331. package/docs/NEUTRALITY.md +95 -0
  332. package/docs/PRIVACY.md +51 -0
  333. package/docs/PROVIDER-RECONCILIATION.md +260 -0
  334. package/docs/README.md +52 -0
  335. package/docs/REAL-PROVIDER-RECONCILIATION-RUNBOOK.md +44 -0
  336. package/docs/RELEASE-GATE.md +682 -0
  337. package/docs/RELEASE-PROCESS.md +68 -0
  338. package/docs/RELIABILITY-PERFORMANCE.md +149 -0
  339. package/docs/RETURN-ON-INTELLIGENCE.md +808 -0
  340. package/docs/SUPPORT.md +37 -0
  341. package/docs/THE-STANDARD.md +235 -0
  342. package/docs/THREAT-MODEL.md +114 -0
  343. package/market/consensus-fits.json +1 -0
  344. package/market/snapshot.json +1 -0
  345. package/package.json +79 -4
  346. package/pricing/models.json +1400 -0
  347. package/standalone/segreantpack-verifier.d.mts +61 -0
  348. package/standalone/segreantpack-verifier.mjs +715 -0
  349. package/web/assets/brand/mark-256.png +0 -0
package/dist/cli/ui.js ADDED
@@ -0,0 +1,128 @@
1
+ /**
2
+ * Shared CLI presentation helpers — ANSI palette, money/number/percent
3
+ * formatting, and the small disclosure lines every command reuses. Extracted
4
+ * verbatim from cli.ts in the per-command-module split; the dispatcher and
5
+ * every command module import from here so the CLI speaks with one voice.
6
+ */
7
+ import { stringifyJson } from '../util/json.js';
8
+ // Night Vault brand colors on terminals that declare 24-bit support (molten
9
+ // gold for value, sage for pass, signal red for alerts); the plain ANSI-16
10
+ // equivalents everywhere else so older terminals never see garbage escapes.
11
+ const truecolor = process.env.COLORTERM === 'truecolor' || process.env.COLORTERM === '24bit' || Boolean(process.env.WT_SESSION);
12
+ export const C = {
13
+ reset: '\x1b[0m',
14
+ dim: '\x1b[2m',
15
+ bold: '\x1b[1m',
16
+ cyan: '\x1b[36m',
17
+ green: truecolor ? '\x1b[38;2;99;197;147m' : '\x1b[32m',
18
+ yellow: truecolor ? '\x1b[38;2;232;179;60m' : '\x1b[33m',
19
+ red: truecolor ? '\x1b[38;2;226;93;74m' : '\x1b[31m',
20
+ gray: '\x1b[90m',
21
+ };
22
+ export function color(on, code, s) {
23
+ return on ? `${code}${s}${C.reset}` : s;
24
+ }
25
+ export function usd(n) {
26
+ // Sign outside the symbol, and the same precision either side of zero: a
27
+ // credit of 5 dollars used to fall through every branch to "$-5.000000".
28
+ const sign = n < 0 ? '-' : '';
29
+ const a = Math.abs(n);
30
+ if (a === 0)
31
+ return '$0.00';
32
+ if (a >= 1)
33
+ return `${sign}$${a.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
34
+ if (a >= 0.01)
35
+ return `${sign}$${a.toFixed(4)}`;
36
+ return `${sign}$${a.toFixed(6)}`;
37
+ }
38
+ export function num(n) {
39
+ return n.toLocaleString('en-US');
40
+ }
41
+ export function pct(n) {
42
+ return `${(n * 100).toFixed(0)}%`;
43
+ }
44
+ /** CLI response version, separate from database and exported artifact schemas. */
45
+ export const CLI_JSON_SCHEMA_VERSION = 1;
46
+ export function cliJsonResponse(value) {
47
+ if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
48
+ // A document that already names its own schema version keeps it: that
49
+ // number describes the document, and the CLI must not relabel it.
50
+ if (Object.hasOwn(value, 'schemaVersion'))
51
+ return value;
52
+ return { ...value, schemaVersion: CLI_JSON_SCHEMA_VERSION };
53
+ }
54
+ return { schemaVersion: CLI_JSON_SCHEMA_VERSION, data: value };
55
+ }
56
+ /** Emit one versioned response with stable six-decimal USD fields. */
57
+ export function printJson(value, space = 2) {
58
+ process.stdout.write(stringifyJson(cliJsonResponse(value), space) + '\n');
59
+ }
60
+ /** Actionable not-a-git-repo message: tell the user what to do, not just what's wrong. */
61
+ export function printNotAGitRepo(repo) {
62
+ console.error(` Not a git repository: ${repo}`);
63
+ console.error(' Run this from inside your repo, or pass --repo <path>. Session-scored usage needs no git: segreant usage');
64
+ }
65
+ /**
66
+ * One-line honesty notes about where the realized-value figures came from: a
67
+ * stored snapshot vs a live repo, and — for a live repo — whether the dollars were
68
+ * scoped to THIS project's own spend (the ledger is characterized by project:
69
+ * native imports or tagged traffic) or fell back to the project-blind window sum
70
+ * (untagged proxy). Discloses the basis so the number is never silently mixed.
71
+ */
72
+ export function noteSource(tty, source, projectScoped, costStaleUnits = 0,
73
+ /** Mature units whose spend window lost rows to retention (D-176). */
74
+ spendWindowTruncatedUnits = 0,
75
+ /** Mature units persisted before that coverage was recorded: unknown, not intact. */
76
+ spendWindowUnknownUnits = 0) {
77
+ if (spendWindowTruncatedUnits > 0) {
78
+ // The cost totals below are DENOMINATORS. A commit whose attribution
79
+ // window retention emptied contributes $0.00 and still counts as a
80
+ // unit, so every ratio built on them is inflated by an unknown amount.
81
+ // Reported rather than corrected: nothing surviving records what was
82
+ // deleted, so a repaired total would be invented.
83
+ console.log(color(tty, C.yellow, ` ● ${spendWindowTruncatedUnits} unit(s) had spend deleted by retention inside their attribution window — their cost reads lower than it was, so ratios below are flattering by an unknown amount.`));
84
+ }
85
+ if (spendWindowUnknownUnits > 0) {
86
+ // Distinct from zero truncated units on purpose: a snapshot written
87
+ // before the coverage was recorded cannot say, and reading that as
88
+ // intact is the inference this line exists to refuse.
89
+ console.log(color(tty, C.gray, ` ● ${spendWindowUnknownUnits} unit(s) predate the retention-coverage record, so whether their spend window lost rows is unknown. Recompute with: segreant realize`));
90
+ }
91
+ if (costStaleUnits > 0) {
92
+ // A reprice re-costed the request ledger. These units predate the recorded
93
+ // cost basis, so they could not be re-attributed without guessing which basis
94
+ // produced them — they still carry the old dollars, and this view and
95
+ // `segreant spend` will not agree until they are recomputed.
96
+ console.log(color(tty, C.yellow, ` ● ${costStaleUnits} unit(s) carry pre-reprice costs — excluded from model comparison. Recompute with: segreant realize`));
97
+ }
98
+ if (source === 'store') {
99
+ console.log(color(tty, C.gray, ' ● stored realization snapshot — no live repo attached; figures are as of the last realize run.'));
100
+ return;
101
+ }
102
+ if (projectScoped === true) {
103
+ console.log(color(tty, C.gray, " ● scoped to this project's own spend — ledger characterized by project (imports / tagged traffic)."));
104
+ }
105
+ else if (projectScoped === false) {
106
+ console.log(color(tty, C.gray, ' ● project-blind window attribution — no project-tagged spend here. Import or tag sources to scope value per project.'));
107
+ }
108
+ }
109
+ export function glyph(tty, v) {
110
+ if (v === 'pass')
111
+ return color(tty, C.green, '✓');
112
+ if (v === 'fail')
113
+ return color(tty, C.red, '✗');
114
+ return color(tty, C.gray, '·');
115
+ }
116
+ /**
117
+ * A gate's glyph from its four-valued polarity (AII-003, WP-B03).
118
+ *
119
+ * A conflicted gate projects to `fail`, so rendering the verdict alone showed
120
+ * an operator a red ✗ — "the tests failed" — when what actually happened is
121
+ * that two runs disagreed and neither has been adjudicated. Those call for
122
+ * different actions, so they get different glyphs.
123
+ */
124
+ export function gateGlyph(tty, result) {
125
+ if (result.polarity === 'conflicted')
126
+ return color(tty, C.yellow, '!');
127
+ return glyph(tty, result.verdict);
128
+ }