avorelo 0.1.0 → 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.
- package/LICENSE +23 -16
- package/README.md +91 -51
- package/bin/avorelo.mjs +7 -0
- package/dist/avorelo.mjs +14337 -0
- package/package.json +106 -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,1216 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const { getCurrentPlan } = require("./entitlements");
|
|
4
|
-
const { nowIso } = require("./fsx");
|
|
5
|
-
const { appendProMomentEvent } = require("./pro-moment-events");
|
|
6
|
-
const {
|
|
7
|
-
buildDefaultProMomentState,
|
|
8
|
-
getMomentStateEntry,
|
|
9
|
-
getSuppressionState,
|
|
10
|
-
readProMomentState,
|
|
11
|
-
updateProMomentState,
|
|
12
|
-
} = require("./pro-moment-state");
|
|
13
|
-
const { ValueLedger } = require("./value-ledger");
|
|
14
|
-
|
|
15
|
-
const TRUST_CRITICAL_BASELINES = Object.freeze([
|
|
16
|
-
"setup_quality",
|
|
17
|
-
"readiness_truth",
|
|
18
|
-
"safe_local_repair_basics",
|
|
19
|
-
"unsafe_action_blocks",
|
|
20
|
-
"basic_risky_instruction_handling",
|
|
21
|
-
"basic_skill_instruction_safety_checks",
|
|
22
|
-
"latest_proof",
|
|
23
|
-
"latest_status_value_summary",
|
|
24
|
-
"one_clear_next_action",
|
|
25
|
-
"basic_recovery_path",
|
|
26
|
-
"basic_local_usability",
|
|
27
|
-
]);
|
|
28
|
-
|
|
29
|
-
const ALLOWED_PRO_DEPTH_AREAS = new Set([
|
|
30
|
-
"deeper_continuity",
|
|
31
|
-
"richer_history",
|
|
32
|
-
"export",
|
|
33
|
-
"longer_retention",
|
|
34
|
-
"more_visual_qa",
|
|
35
|
-
"deeper_safe_path",
|
|
36
|
-
"approval_posture",
|
|
37
|
-
"source_trust_depth",
|
|
38
|
-
"risk_based_automatic_routing",
|
|
39
|
-
"deeper_worker_handoff",
|
|
40
|
-
"deeper_context_token_insight_history",
|
|
41
|
-
"multi_repo_depth",
|
|
42
|
-
"team_shared_policies",
|
|
43
|
-
]);
|
|
44
|
-
|
|
45
|
-
const PRO_MOMENT_MATURITY_LEVELS = Object.freeze({
|
|
46
|
-
idea_only: 0,
|
|
47
|
-
defined_but_disabled: 1,
|
|
48
|
-
eligibility_implemented: 2,
|
|
49
|
-
surface_integrated: 3,
|
|
50
|
-
user_controls_implemented: 4,
|
|
51
|
-
telemetry_hardened: 5,
|
|
52
|
-
trust_privacy_copy_regressions: 6,
|
|
53
|
-
docs_and_decision_record: 7,
|
|
54
|
-
production_active: 8,
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const PRO_MOMENT_COPY_GUARD_PROFILES = Object.freeze({
|
|
58
|
-
calm_depth: Object.freeze({
|
|
59
|
-
bannedPhrases: Object.freeze([
|
|
60
|
-
"Upgrade now",
|
|
61
|
-
"Stay protected with Pro",
|
|
62
|
-
"You are unsafe",
|
|
63
|
-
"You are missing out",
|
|
64
|
-
"Pay to see proof",
|
|
65
|
-
"Unlock truth",
|
|
66
|
-
"limited time",
|
|
67
|
-
"countdown",
|
|
68
|
-
"setup is better in Pro",
|
|
69
|
-
"unlock protection",
|
|
70
|
-
]),
|
|
71
|
-
valueBacked: true,
|
|
72
|
-
fearBased: false,
|
|
73
|
-
modalPressure: false,
|
|
74
|
-
}),
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
const PRO_MOMENT_PRIVACY_PROFILES = Object.freeze({
|
|
78
|
-
no_raw_content: Object.freeze({
|
|
79
|
-
redactPaths: true,
|
|
80
|
-
redactPrompts: true,
|
|
81
|
-
redactCode: true,
|
|
82
|
-
redactSecrets: true,
|
|
83
|
-
redactSensitiveRepoContent: true,
|
|
84
|
-
}),
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
const PRO_MOMENT_TELEMETRY_PROFILES = Object.freeze({
|
|
88
|
-
human_visible_text_only: Object.freeze({
|
|
89
|
-
jsonCountsAsShown: false,
|
|
90
|
-
humanVisibleTextCountsAsShown: true,
|
|
91
|
-
jsonStartsSuppression: false,
|
|
92
|
-
recentShownSuppressionHours: 12,
|
|
93
|
-
redactionRequired: true,
|
|
94
|
-
}),
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
const PRO_MOMENT_REQUIRED_USER_CONTROLS = Object.freeze([
|
|
98
|
-
"inspect",
|
|
99
|
-
"dismiss",
|
|
100
|
-
"suppress",
|
|
101
|
-
]);
|
|
102
|
-
|
|
103
|
-
const PRO_MOMENT_HELPER_SCRIPT = "node scripts/cco-pro-moments.js";
|
|
104
|
-
const CONTINUITY_DETAILS_MESSAGE =
|
|
105
|
-
"Free preserves your latest next step. Pro can keep deeper continuity across sessions so Avorelo carries more context, proof, and handoff depth over time.";
|
|
106
|
-
const EVIDENCE_HISTORY_DETAILS_MESSAGE =
|
|
107
|
-
"Free keeps your latest proof. Pro adds richer proof history and export for repeated work, review, and handoff.";
|
|
108
|
-
|
|
109
|
-
const PRO_MOMENT_DEFINITIONS = Object.freeze({
|
|
110
|
-
continuity_depth: {
|
|
111
|
-
id: "continuity_depth",
|
|
112
|
-
label: "Continuity depth",
|
|
113
|
-
description: "Offer deeper repeated-work continuity only after Avorelo already preserved useful local context.",
|
|
114
|
-
status: "active",
|
|
115
|
-
maturityLevel: PRO_MOMENT_MATURITY_LEVELS.production_active,
|
|
116
|
-
category: "continuity",
|
|
117
|
-
planRequirement: "free",
|
|
118
|
-
freeBoundary: {
|
|
119
|
-
summary: "Free preserves the latest next step and current continuity truth.",
|
|
120
|
-
guarantees: [
|
|
121
|
-
"latest_status_value_summary",
|
|
122
|
-
"one_clear_next_action",
|
|
123
|
-
"basic_local_usability",
|
|
124
|
-
],
|
|
125
|
-
},
|
|
126
|
-
proDepth: {
|
|
127
|
-
summary: "Pro keeps deeper continuity, proof, and handoff depth across repeated work.",
|
|
128
|
-
capabilities: ["deeper_continuity", "richer_history"],
|
|
129
|
-
},
|
|
130
|
-
allowedSurfaces: ["status", "dashboard", "reentry"],
|
|
131
|
-
allowedDisplayLevels: ["passive", "contextual_inline"],
|
|
132
|
-
requiredSignals: ["activation_completed", "value_seen", "repeat_usage"],
|
|
133
|
-
hardBlockers: ["first_session", "risk_state", "error_state", "cooldown_active"],
|
|
134
|
-
cooldownDays: 14,
|
|
135
|
-
globalCooldownDays: 7,
|
|
136
|
-
cooldownProfile: {
|
|
137
|
-
momentCooldownDays: 14,
|
|
138
|
-
globalCooldownDays: 7,
|
|
139
|
-
repeatedDismissalSuppressionDays: 30,
|
|
140
|
-
dontShowAgainSuppressionDays: 60,
|
|
141
|
-
recentShownSuppressionHours: 12,
|
|
142
|
-
},
|
|
143
|
-
depthAreas: ["deeper_continuity", "richer_history"],
|
|
144
|
-
copyGuardProfile: "calm_depth",
|
|
145
|
-
privacyProfile: "no_raw_content",
|
|
146
|
-
telemetryProfile: "human_visible_text_only",
|
|
147
|
-
requiredUserControls: PRO_MOMENT_REQUIRED_USER_CONTROLS,
|
|
148
|
-
requiredTests: [
|
|
149
|
-
"eligibility",
|
|
150
|
-
"surface_rendering",
|
|
151
|
-
"text_vs_json_telemetry",
|
|
152
|
-
"cooldown_and_suppression",
|
|
153
|
-
"copy_guard",
|
|
154
|
-
"privacy_redaction",
|
|
155
|
-
"trust_boundaries",
|
|
156
|
-
],
|
|
157
|
-
docs: {
|
|
158
|
-
engine: "docs/Pro-Moment-Engine.md",
|
|
159
|
-
decisionRecord: "docs/Pro-Moment-Decision-Records/continuity-depth.md",
|
|
160
|
-
closureReport: "docs/Pro-Moment-Closure-Report.md",
|
|
161
|
-
dogfoodChecklist: "docs/Pro-Moment-Dogfood-Checklist.md",
|
|
162
|
-
},
|
|
163
|
-
copyVariants: {
|
|
164
|
-
title: "Keep more continuity across sessions",
|
|
165
|
-
body:
|
|
166
|
-
"Avorelo preserved your latest next step. Pro can keep deeper continuity across sessions, so you spend less time rebuilding context.",
|
|
167
|
-
alternateBody:
|
|
168
|
-
"Free keeps the latest next step. Pro helps Avorelo carry more context, proof, and handoff depth across repeated work.",
|
|
169
|
-
primaryAction: "See Pro continuity",
|
|
170
|
-
secondaryAction: "Not now",
|
|
171
|
-
tertiaryAction: "Do not show this again for continuity",
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
evidence_history_export: {
|
|
175
|
-
id: "evidence_history_export",
|
|
176
|
-
label: "Evidence history and export",
|
|
177
|
-
description: "Offer deeper retained proof history and local export only after the user explicitly reaches for proof depth.",
|
|
178
|
-
status: "active",
|
|
179
|
-
maturityLevel: PRO_MOMENT_MATURITY_LEVELS.production_active,
|
|
180
|
-
category: "evidence",
|
|
181
|
-
planRequirement: "free",
|
|
182
|
-
freeBoundary: {
|
|
183
|
-
summary: "Free keeps the latest proof, current-state truth, and one clear next action visible.",
|
|
184
|
-
guarantees: [
|
|
185
|
-
"latest_proof",
|
|
186
|
-
"latest_status_value_summary",
|
|
187
|
-
"one_clear_next_action",
|
|
188
|
-
],
|
|
189
|
-
},
|
|
190
|
-
proDepth: {
|
|
191
|
-
summary: "Pro keeps the trail with richer history, local export, and longer retained review depth.",
|
|
192
|
-
capabilities: ["richer_history", "export", "longer_retention"],
|
|
193
|
-
},
|
|
194
|
-
allowedSurfaces: ["proof_history", "proof_export", "proof_depth"],
|
|
195
|
-
allowedDisplayLevels: ["passive", "contextual_inline", "strong"],
|
|
196
|
-
requiredSignals: ["proof_generated"],
|
|
197
|
-
hardBlockers: ["first_session", "activation_incomplete", "risk_state", "error_state", "recovery_state", "cooldown_active", "state_invalid"],
|
|
198
|
-
cooldownDays: 14,
|
|
199
|
-
globalCooldownDays: 7,
|
|
200
|
-
cooldownProfile: {
|
|
201
|
-
momentCooldownDays: 14,
|
|
202
|
-
globalCooldownDays: 7,
|
|
203
|
-
repeatedDismissalSuppressionDays: 30,
|
|
204
|
-
dontShowAgainSuppressionDays: 60,
|
|
205
|
-
recentShownSuppressionHours: 12,
|
|
206
|
-
},
|
|
207
|
-
depthAreas: ["richer_history", "export", "longer_retention"],
|
|
208
|
-
copyGuardProfile: "calm_depth",
|
|
209
|
-
privacyProfile: "no_raw_content",
|
|
210
|
-
telemetryProfile: "human_visible_text_only",
|
|
211
|
-
requiredUserControls: PRO_MOMENT_REQUIRED_USER_CONTROLS,
|
|
212
|
-
requiredTests: [
|
|
213
|
-
"explicit_intent_only",
|
|
214
|
-
"plain_proof_stays_free",
|
|
215
|
-
"history_and_export_entitlements",
|
|
216
|
-
"text_vs_json_telemetry",
|
|
217
|
-
"cooldown_and_suppression",
|
|
218
|
-
"copy_guard",
|
|
219
|
-
"privacy_redaction",
|
|
220
|
-
"trust_boundaries",
|
|
221
|
-
],
|
|
222
|
-
docs: {
|
|
223
|
-
engine: "docs/Pro-Moment-Engine.md",
|
|
224
|
-
decisionRecord: "docs/Pro-Moment-Decision-Records/evidence-history-export.md",
|
|
225
|
-
closureReport: "docs/Pro-Moment-Closure-Report.md",
|
|
226
|
-
dogfoodChecklist: "docs/Pro-Moment-Dogfood-Checklist.md",
|
|
227
|
-
},
|
|
228
|
-
copyVariants: {
|
|
229
|
-
title: "Free keeps the latest proof. Pro keeps the trail.",
|
|
230
|
-
body:
|
|
231
|
-
"Free keeps your latest proof. Pro adds proof history so repeated work is easier to review and continue.",
|
|
232
|
-
alternateBody:
|
|
233
|
-
"Free keeps your latest proof. Pro adds local proof export for review, handoff, and repeated work.",
|
|
234
|
-
primaryAction: "See Pro proof history",
|
|
235
|
-
secondaryAction: "Not now",
|
|
236
|
-
tertiaryAction: "Do not show this again for proof history",
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
advanced_security_safe_path: {
|
|
240
|
-
id: "advanced_security_safe_path",
|
|
241
|
-
label: "Advanced Safe Path depth",
|
|
242
|
-
description: "Future depth moment for deeper Safe Path and approval posture.",
|
|
243
|
-
status: "future",
|
|
244
|
-
maturityLevel: PRO_MOMENT_MATURITY_LEVELS.defined_but_disabled,
|
|
245
|
-
category: "security",
|
|
246
|
-
planRequirement: "free",
|
|
247
|
-
freeBoundary: {
|
|
248
|
-
summary: "Basic unsafe-action protection and Safe Path truth remain free.",
|
|
249
|
-
guarantees: [
|
|
250
|
-
"unsafe_action_blocks",
|
|
251
|
-
"basic_risky_instruction_handling",
|
|
252
|
-
"basic_skill_instruction_safety_checks",
|
|
253
|
-
],
|
|
254
|
-
},
|
|
255
|
-
proDepth: {
|
|
256
|
-
summary: "Any future Pro depth would be deeper Safe Path posture only, never basic safety.",
|
|
257
|
-
capabilities: ["deeper_safe_path", "approval_posture", "source_trust_depth"],
|
|
258
|
-
},
|
|
259
|
-
allowedSurfaces: ["status", "dashboard", "security"],
|
|
260
|
-
allowedDisplayLevels: ["passive", "contextual_inline", "strong"],
|
|
261
|
-
requiredSignals: ["safe_path_suggested"],
|
|
262
|
-
hardBlockers: ["first_session", "risk_state", "error_state", "cooldown_active"],
|
|
263
|
-
cooldownDays: 14,
|
|
264
|
-
globalCooldownDays: 7,
|
|
265
|
-
cooldownProfile: {
|
|
266
|
-
momentCooldownDays: 14,
|
|
267
|
-
globalCooldownDays: 7,
|
|
268
|
-
repeatedDismissalSuppressionDays: 30,
|
|
269
|
-
dontShowAgainSuppressionDays: 60,
|
|
270
|
-
recentShownSuppressionHours: 12,
|
|
271
|
-
},
|
|
272
|
-
depthAreas: ["deeper_safe_path", "approval_posture", "source_trust_depth"],
|
|
273
|
-
copyGuardProfile: "calm_depth",
|
|
274
|
-
privacyProfile: "no_raw_content",
|
|
275
|
-
telemetryProfile: "human_visible_text_only",
|
|
276
|
-
requiredUserControls: PRO_MOMENT_REQUIRED_USER_CONTROLS,
|
|
277
|
-
requiredTests: ["not_active_yet"],
|
|
278
|
-
docs: {
|
|
279
|
-
engine: "docs/Pro-Moment-Engine.md",
|
|
280
|
-
},
|
|
281
|
-
},
|
|
282
|
-
automatic_risk_based_routing: {
|
|
283
|
-
id: "automatic_risk_based_routing",
|
|
284
|
-
label: "Automatic risk-based routing",
|
|
285
|
-
description: "Future depth moment for automatic routing once the repo has stronger routing truth.",
|
|
286
|
-
status: "future",
|
|
287
|
-
maturityLevel: PRO_MOMENT_MATURITY_LEVELS.defined_but_disabled,
|
|
288
|
-
category: "routing",
|
|
289
|
-
planRequirement: "free",
|
|
290
|
-
freeBoundary: {
|
|
291
|
-
summary: "Basic routing truth and recommendations remain free.",
|
|
292
|
-
guarantees: [
|
|
293
|
-
"latest_status_value_summary",
|
|
294
|
-
"one_clear_next_action",
|
|
295
|
-
],
|
|
296
|
-
},
|
|
297
|
-
proDepth: {
|
|
298
|
-
summary: "Any future Pro depth would be deeper risk-based automation only.",
|
|
299
|
-
capabilities: ["risk_based_automatic_routing"],
|
|
300
|
-
},
|
|
301
|
-
allowedSurfaces: ["status", "dashboard", "routing"],
|
|
302
|
-
allowedDisplayLevels: ["passive", "contextual_inline", "strong"],
|
|
303
|
-
requiredSignals: ["route_recommendation_shown"],
|
|
304
|
-
hardBlockers: ["first_session", "risk_state", "error_state", "cooldown_active"],
|
|
305
|
-
cooldownDays: 14,
|
|
306
|
-
globalCooldownDays: 7,
|
|
307
|
-
cooldownProfile: {
|
|
308
|
-
momentCooldownDays: 14,
|
|
309
|
-
globalCooldownDays: 7,
|
|
310
|
-
repeatedDismissalSuppressionDays: 30,
|
|
311
|
-
dontShowAgainSuppressionDays: 60,
|
|
312
|
-
recentShownSuppressionHours: 12,
|
|
313
|
-
},
|
|
314
|
-
depthAreas: ["risk_based_automatic_routing"],
|
|
315
|
-
copyGuardProfile: "calm_depth",
|
|
316
|
-
privacyProfile: "no_raw_content",
|
|
317
|
-
telemetryProfile: "human_visible_text_only",
|
|
318
|
-
requiredUserControls: PRO_MOMENT_REQUIRED_USER_CONTROLS,
|
|
319
|
-
requiredTests: ["not_active_yet"],
|
|
320
|
-
docs: {
|
|
321
|
-
engine: "docs/Pro-Moment-Engine.md",
|
|
322
|
-
},
|
|
323
|
-
},
|
|
324
|
-
visual_qa_quota: {
|
|
325
|
-
id: "visual_qa_quota",
|
|
326
|
-
label: "Visual QA depth",
|
|
327
|
-
description: "Future depth moment for expanded Visual QA quota and richer retained reports.",
|
|
328
|
-
status: "disabled",
|
|
329
|
-
maturityLevel: PRO_MOMENT_MATURITY_LEVELS.defined_but_disabled,
|
|
330
|
-
category: "visual_qa",
|
|
331
|
-
planRequirement: "free",
|
|
332
|
-
freeBoundary: {
|
|
333
|
-
summary: "Basic local Visual QA value is not paywalled.",
|
|
334
|
-
guarantees: [
|
|
335
|
-
"latest_status_value_summary",
|
|
336
|
-
"basic_local_usability",
|
|
337
|
-
],
|
|
338
|
-
},
|
|
339
|
-
proDepth: {
|
|
340
|
-
summary: "Any future Pro depth would be higher-volume QA and richer retained reports.",
|
|
341
|
-
capabilities: ["more_visual_qa", "richer_history"],
|
|
342
|
-
},
|
|
343
|
-
allowedSurfaces: ["dashboard", "visual_qa"],
|
|
344
|
-
allowedDisplayLevels: ["passive", "contextual_inline", "strong"],
|
|
345
|
-
requiredSignals: ["visual_qa_completed"],
|
|
346
|
-
hardBlockers: ["first_session", "risk_state", "error_state", "cooldown_active"],
|
|
347
|
-
cooldownDays: 14,
|
|
348
|
-
globalCooldownDays: 7,
|
|
349
|
-
cooldownProfile: {
|
|
350
|
-
momentCooldownDays: 14,
|
|
351
|
-
globalCooldownDays: 7,
|
|
352
|
-
repeatedDismissalSuppressionDays: 30,
|
|
353
|
-
dontShowAgainSuppressionDays: 60,
|
|
354
|
-
recentShownSuppressionHours: 12,
|
|
355
|
-
},
|
|
356
|
-
depthAreas: ["more_visual_qa", "richer_history"],
|
|
357
|
-
copyGuardProfile: "calm_depth",
|
|
358
|
-
privacyProfile: "no_raw_content",
|
|
359
|
-
telemetryProfile: "human_visible_text_only",
|
|
360
|
-
requiredUserControls: PRO_MOMENT_REQUIRED_USER_CONTROLS,
|
|
361
|
-
requiredTests: ["not_active_yet"],
|
|
362
|
-
docs: {
|
|
363
|
-
engine: "docs/Pro-Moment-Engine.md",
|
|
364
|
-
},
|
|
365
|
-
},
|
|
366
|
-
context_token_insight_depth: {
|
|
367
|
-
id: "context_token_insight_depth",
|
|
368
|
-
label: "Context insight depth",
|
|
369
|
-
description: "Future depth moment for longer context and token insight history.",
|
|
370
|
-
status: "future",
|
|
371
|
-
maturityLevel: PRO_MOMENT_MATURITY_LEVELS.defined_but_disabled,
|
|
372
|
-
category: "context",
|
|
373
|
-
planRequirement: "free",
|
|
374
|
-
freeBoundary: {
|
|
375
|
-
summary: "Basic context discipline and latest next action remain free.",
|
|
376
|
-
guarantees: [
|
|
377
|
-
"one_clear_next_action",
|
|
378
|
-
"basic_local_usability",
|
|
379
|
-
],
|
|
380
|
-
},
|
|
381
|
-
proDepth: {
|
|
382
|
-
summary: "Any future Pro depth would be deeper retained context/token history only.",
|
|
383
|
-
capabilities: ["deeper_context_token_insight_history"],
|
|
384
|
-
},
|
|
385
|
-
allowedSurfaces: ["status", "dashboard", "context"],
|
|
386
|
-
allowedDisplayLevels: ["passive", "contextual_inline"],
|
|
387
|
-
requiredSignals: ["context_discipline_applied"],
|
|
388
|
-
hardBlockers: ["first_session", "risk_state", "error_state", "cooldown_active"],
|
|
389
|
-
cooldownDays: 14,
|
|
390
|
-
globalCooldownDays: 7,
|
|
391
|
-
cooldownProfile: {
|
|
392
|
-
momentCooldownDays: 14,
|
|
393
|
-
globalCooldownDays: 7,
|
|
394
|
-
repeatedDismissalSuppressionDays: 30,
|
|
395
|
-
dontShowAgainSuppressionDays: 60,
|
|
396
|
-
recentShownSuppressionHours: 12,
|
|
397
|
-
},
|
|
398
|
-
depthAreas: ["deeper_context_token_insight_history"],
|
|
399
|
-
copyGuardProfile: "calm_depth",
|
|
400
|
-
privacyProfile: "no_raw_content",
|
|
401
|
-
telemetryProfile: "human_visible_text_only",
|
|
402
|
-
requiredUserControls: PRO_MOMENT_REQUIRED_USER_CONTROLS,
|
|
403
|
-
requiredTests: ["not_active_yet"],
|
|
404
|
-
docs: {
|
|
405
|
-
engine: "docs/Pro-Moment-Engine.md",
|
|
406
|
-
},
|
|
407
|
-
},
|
|
408
|
-
multi_repo_depth: {
|
|
409
|
-
id: "multi_repo_depth",
|
|
410
|
-
label: "Multi-repo depth",
|
|
411
|
-
description: "Future depth moment for cross-repo continuity later.",
|
|
412
|
-
status: "future",
|
|
413
|
-
maturityLevel: PRO_MOMENT_MATURITY_LEVELS.defined_but_disabled,
|
|
414
|
-
category: "continuity",
|
|
415
|
-
planRequirement: "free",
|
|
416
|
-
freeBoundary: {
|
|
417
|
-
summary: "Single-repo continuity truth remains free.",
|
|
418
|
-
guarantees: [
|
|
419
|
-
"latest_status_value_summary",
|
|
420
|
-
"one_clear_next_action",
|
|
421
|
-
],
|
|
422
|
-
},
|
|
423
|
-
proDepth: {
|
|
424
|
-
summary: "Any future Pro depth would be multi-repo continuity only.",
|
|
425
|
-
capabilities: ["multi_repo_depth"],
|
|
426
|
-
},
|
|
427
|
-
allowedSurfaces: ["dashboard"],
|
|
428
|
-
allowedDisplayLevels: ["passive", "contextual_inline"],
|
|
429
|
-
requiredSignals: ["repeat_usage"],
|
|
430
|
-
hardBlockers: ["first_session", "risk_state", "error_state", "cooldown_active"],
|
|
431
|
-
cooldownDays: 14,
|
|
432
|
-
globalCooldownDays: 7,
|
|
433
|
-
cooldownProfile: {
|
|
434
|
-
momentCooldownDays: 14,
|
|
435
|
-
globalCooldownDays: 7,
|
|
436
|
-
repeatedDismissalSuppressionDays: 30,
|
|
437
|
-
dontShowAgainSuppressionDays: 60,
|
|
438
|
-
recentShownSuppressionHours: 12,
|
|
439
|
-
},
|
|
440
|
-
depthAreas: ["multi_repo_depth"],
|
|
441
|
-
copyGuardProfile: "calm_depth",
|
|
442
|
-
privacyProfile: "no_raw_content",
|
|
443
|
-
telemetryProfile: "human_visible_text_only",
|
|
444
|
-
requiredUserControls: PRO_MOMENT_REQUIRED_USER_CONTROLS,
|
|
445
|
-
requiredTests: ["not_active_yet"],
|
|
446
|
-
docs: {
|
|
447
|
-
engine: "docs/Pro-Moment-Engine.md",
|
|
448
|
-
},
|
|
449
|
-
},
|
|
450
|
-
team_shared_policy_later: {
|
|
451
|
-
id: "team_shared_policy_later",
|
|
452
|
-
label: "Shared policy depth",
|
|
453
|
-
description: "Future depth moment for team/shared policy surfaces later.",
|
|
454
|
-
status: "future",
|
|
455
|
-
maturityLevel: PRO_MOMENT_MATURITY_LEVELS.defined_but_disabled,
|
|
456
|
-
category: "team",
|
|
457
|
-
planRequirement: "free",
|
|
458
|
-
freeBoundary: {
|
|
459
|
-
summary: "Local single-user truth remains free.",
|
|
460
|
-
guarantees: [
|
|
461
|
-
"latest_status_value_summary",
|
|
462
|
-
"one_clear_next_action",
|
|
463
|
-
"basic_local_usability",
|
|
464
|
-
],
|
|
465
|
-
},
|
|
466
|
-
proDepth: {
|
|
467
|
-
summary: "Any future Pro depth would be shared policy and team carry-forward only.",
|
|
468
|
-
capabilities: ["team_shared_policies"],
|
|
469
|
-
},
|
|
470
|
-
allowedSurfaces: ["dashboard"],
|
|
471
|
-
allowedDisplayLevels: ["passive", "contextual_inline", "strong"],
|
|
472
|
-
requiredSignals: ["repeat_usage"],
|
|
473
|
-
hardBlockers: ["first_session", "risk_state", "error_state", "cooldown_active"],
|
|
474
|
-
cooldownDays: 14,
|
|
475
|
-
globalCooldownDays: 7,
|
|
476
|
-
cooldownProfile: {
|
|
477
|
-
momentCooldownDays: 14,
|
|
478
|
-
globalCooldownDays: 7,
|
|
479
|
-
repeatedDismissalSuppressionDays: 30,
|
|
480
|
-
dontShowAgainSuppressionDays: 60,
|
|
481
|
-
recentShownSuppressionHours: 12,
|
|
482
|
-
},
|
|
483
|
-
depthAreas: ["team_shared_policies"],
|
|
484
|
-
copyGuardProfile: "calm_depth",
|
|
485
|
-
privacyProfile: "no_raw_content",
|
|
486
|
-
telemetryProfile: "human_visible_text_only",
|
|
487
|
-
requiredUserControls: PRO_MOMENT_REQUIRED_USER_CONTROLS,
|
|
488
|
-
requiredTests: ["not_active_yet"],
|
|
489
|
-
docs: {
|
|
490
|
-
engine: "docs/Pro-Moment-Engine.md",
|
|
491
|
-
},
|
|
492
|
-
},
|
|
493
|
-
});
|
|
494
|
-
|
|
495
|
-
function getProMomentDefinition(momentId) {
|
|
496
|
-
return PRO_MOMENT_DEFINITIONS[String(momentId || "").trim()] || null;
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
function listProMomentDefinitions() {
|
|
500
|
-
return Object.values(PRO_MOMENT_DEFINITIONS);
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
function isActiveProMomentDefinition(definition) {
|
|
504
|
-
return Boolean(definition) && definition.status === "active";
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
function validateProMomentDefinitions() {
|
|
508
|
-
return listProMomentDefinitions().every((definition) => {
|
|
509
|
-
const copyProfile = PRO_MOMENT_COPY_GUARD_PROFILES[definition.copyGuardProfile];
|
|
510
|
-
const privacyProfile = PRO_MOMENT_PRIVACY_PROFILES[definition.privacyProfile];
|
|
511
|
-
const telemetryProfile = PRO_MOMENT_TELEMETRY_PROFILES[definition.telemetryProfile];
|
|
512
|
-
return Array.isArray(definition.depthAreas)
|
|
513
|
-
&& definition.depthAreas.every((area) => ALLOWED_PRO_DEPTH_AREAS.has(area))
|
|
514
|
-
&& Number.isInteger(definition.maturityLevel)
|
|
515
|
-
&& definition.maturityLevel >= PRO_MOMENT_MATURITY_LEVELS.idea_only
|
|
516
|
-
&& definition.maturityLevel <= PRO_MOMENT_MATURITY_LEVELS.production_active
|
|
517
|
-
&& definition.freeBoundary
|
|
518
|
-
&& Array.isArray(definition.freeBoundary.guarantees)
|
|
519
|
-
&& definition.proDepth
|
|
520
|
-
&& Array.isArray(definition.proDepth.capabilities)
|
|
521
|
-
&& definition.proDepth.capabilities.every((area) => ALLOWED_PRO_DEPTH_AREAS.has(area))
|
|
522
|
-
&& Array.isArray(definition.requiredUserControls)
|
|
523
|
-
&& definition.requiredUserControls.every((control) => PRO_MOMENT_REQUIRED_USER_CONTROLS.includes(control))
|
|
524
|
-
&& copyProfile
|
|
525
|
-
&& privacyProfile
|
|
526
|
-
&& telemetryProfile
|
|
527
|
-
&& definition.docs
|
|
528
|
-
&& typeof definition.docs.engine === "string";
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
function isTrustCriticalBaseline(key) {
|
|
533
|
-
return TRUST_CRITICAL_BASELINES.includes(String(key || "").trim());
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
function countValueEvents(cwd, status) {
|
|
537
|
-
let total = 0;
|
|
538
|
-
|
|
539
|
-
try {
|
|
540
|
-
const ledger = new ValueLedger(cwd);
|
|
541
|
-
const events = ledger.loadAll();
|
|
542
|
-
total += Math.min(events.length, 5);
|
|
543
|
-
if ((events || []).some((event) => event?.bucket === "reentry_reused")) {
|
|
544
|
-
total += 1;
|
|
545
|
-
}
|
|
546
|
-
} catch {}
|
|
547
|
-
|
|
548
|
-
if (status?.activation?.firstValue?.available) total += 1;
|
|
549
|
-
if (status?.currentState?.reentryStatus) total += 1;
|
|
550
|
-
if (Number(status?.reentryMemory?.candidatesCount || 0) > 0) total += 1;
|
|
551
|
-
if (status?.currentState?.nextBoundedAction) total += 1;
|
|
552
|
-
|
|
553
|
-
return total;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
function deriveRiskState(status) {
|
|
557
|
-
const explicitRisk = status?.workflowDiscipline?.signals?.riskLevel;
|
|
558
|
-
if (explicitRisk === "high" || explicitRisk === "medium") return explicitRisk;
|
|
559
|
-
if (status?.currentState?.reentryStatus === "repair_then_retry") return "recovery";
|
|
560
|
-
if (status?.currentState?.reentryStatus === "rollback_now") return "recovery";
|
|
561
|
-
return "safe";
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
function deriveErrorState(status) {
|
|
565
|
-
const activationStatus = String(status?.activation?.status || "").toLowerCase();
|
|
566
|
-
if (activationStatus.includes("fail") || activationStatus.includes("error") || activationStatus.includes("blocked")) {
|
|
567
|
-
return true;
|
|
568
|
-
}
|
|
569
|
-
const readiness = String(status?.currentState?.readinessState || "").toLowerCase();
|
|
570
|
-
return readiness === "fail" || readiness === "blocked";
|
|
571
|
-
}
|
|
572
|
-
|
|
573
|
-
function deriveRecoveryState(status) {
|
|
574
|
-
const reentryStatus = String(status?.currentState?.reentryStatus || "").toLowerCase();
|
|
575
|
-
return reentryStatus === "repair_then_retry" || reentryStatus === "rollback_now";
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
function deriveUserAction(surface, status) {
|
|
579
|
-
if (status?.currentState?.reentryStatus || Number(status?.reentryMemory?.candidatesCount || 0) > 0) {
|
|
580
|
-
return "viewed_reentry_summary";
|
|
581
|
-
}
|
|
582
|
-
return `viewed_${surface}`;
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
function deriveEligibilityInput(cwd, options = {}) {
|
|
586
|
-
const surface = String(options.surface || "status");
|
|
587
|
-
const status = options.status || {};
|
|
588
|
-
const sessionCount = Math.max(
|
|
589
|
-
Number(status?.weeklySummary?.sessions || 0),
|
|
590
|
-
Array.isArray(status?.sessions) ? status.sessions.length : 0,
|
|
591
|
-
);
|
|
592
|
-
const activationStatus = String(status?.activation?.status || "");
|
|
593
|
-
const activationCompleted =
|
|
594
|
-
status?.activation?.present === true
|
|
595
|
-
&& ["first_value_ready", "active", "completed", "ready"].includes(activationStatus);
|
|
596
|
-
const firstValueShown = status?.activation?.firstValue?.available === true;
|
|
597
|
-
const valueEventsCount = countValueEvents(cwd, status);
|
|
598
|
-
const currentRiskState = deriveRiskState(status);
|
|
599
|
-
const currentErrorState = deriveErrorState(status);
|
|
600
|
-
const currentRecoveryState = deriveRecoveryState(status);
|
|
601
|
-
const repeatedFreeCapabilityUsage =
|
|
602
|
-
sessionCount >= 2
|
|
603
|
-
|| Number(status?.reentryMemory?.candidatesCount || 0) > 0
|
|
604
|
-
|| Boolean(status?.currentState?.reentryStatus);
|
|
605
|
-
|
|
606
|
-
return {
|
|
607
|
-
plan: String(options.plan || getCurrentPlan({ cwd })),
|
|
608
|
-
surface,
|
|
609
|
-
currentSurface: surface,
|
|
610
|
-
momentCandidate: String(options.momentId || "continuity_depth"),
|
|
611
|
-
sessionCount,
|
|
612
|
-
activationCompleted,
|
|
613
|
-
activationFailed:
|
|
614
|
-
String(status?.activation?.status || "").toLowerCase().includes("fail")
|
|
615
|
-
|| String(status?.activation?.status || "").toLowerCase().includes("error"),
|
|
616
|
-
firstValueShown,
|
|
617
|
-
valueEventsCount,
|
|
618
|
-
currentRiskState,
|
|
619
|
-
currentErrorState,
|
|
620
|
-
currentRecoveryState,
|
|
621
|
-
userAction: options.userAction || deriveUserAction(surface, status),
|
|
622
|
-
featureRequested: options.featureRequested || null,
|
|
623
|
-
quotaReached: options.quotaReached === true,
|
|
624
|
-
naturalBoundary:
|
|
625
|
-
["status", "dashboard", "reentry", "proof_history", "proof_export", "proof_depth"].includes(surface),
|
|
626
|
-
repeatedFreeCapabilityUsage,
|
|
627
|
-
reentryUsed: Boolean(status?.currentState?.reentryStatus),
|
|
628
|
-
proofGenerated: Boolean(status?.latestReport || status?.currentState?.latestTrustworthyRunId),
|
|
629
|
-
handoffCreated: Boolean(status?.workControl?.latestReceiptPath),
|
|
630
|
-
contextDisciplineApplied:
|
|
631
|
-
Boolean(status?.workflowDiscipline?.signals)
|
|
632
|
-
|| Boolean(status?.contextBudgetGuard?.reductionPlan),
|
|
633
|
-
riskBlockedWarnedScoped:
|
|
634
|
-
currentRiskState !== "safe"
|
|
635
|
-
|| Number(status?.safePath?.approvalsRequired || 0) > 0
|
|
636
|
-
|| Number(status?.safePath?.blocksPreserved || 0) > 0,
|
|
637
|
-
safePathSuggested: Number(status?.safePath?.reductionsRecommended || 0) > 0,
|
|
638
|
-
visualQaCompleted: Number(status?.planSummary?.visualQa?.quota?.used || 0) > 0,
|
|
639
|
-
routeRecommendationShown: Boolean(status?.orchestration?.statusLine),
|
|
640
|
-
};
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
function normalizeMomentInput(input = {}) {
|
|
644
|
-
return {
|
|
645
|
-
plan: String(input.plan || "free"),
|
|
646
|
-
surface: String(input.surface || input.currentSurface || "status"),
|
|
647
|
-
currentSurface: String(input.currentSurface || input.surface || "status"),
|
|
648
|
-
momentCandidate: String(input.momentCandidate || "continuity_depth"),
|
|
649
|
-
sessionCount: Number.isFinite(Number(input.sessionCount)) ? Number(input.sessionCount) : 0,
|
|
650
|
-
activationCompleted: input.activationCompleted === true,
|
|
651
|
-
activationFailed: input.activationFailed === true,
|
|
652
|
-
firstValueShown: input.firstValueShown === true,
|
|
653
|
-
valueEventsCount: Number.isFinite(Number(input.valueEventsCount)) ? Number(input.valueEventsCount) : 0,
|
|
654
|
-
currentRiskState: String(input.currentRiskState || "safe"),
|
|
655
|
-
currentErrorState: input.currentErrorState === true,
|
|
656
|
-
currentRecoveryState: input.currentRecoveryState === true,
|
|
657
|
-
userAction: input.userAction ? String(input.userAction) : null,
|
|
658
|
-
featureRequested: input.featureRequested ? String(input.featureRequested) : null,
|
|
659
|
-
quotaReached: input.quotaReached === true,
|
|
660
|
-
naturalBoundary: input.naturalBoundary !== false,
|
|
661
|
-
repeatedFreeCapabilityUsage: input.repeatedFreeCapabilityUsage === true,
|
|
662
|
-
reentryUsed: input.reentryUsed === true,
|
|
663
|
-
proofGenerated: input.proofGenerated === true,
|
|
664
|
-
handoffCreated: input.handoffCreated === true,
|
|
665
|
-
contextDisciplineApplied: input.contextDisciplineApplied === true,
|
|
666
|
-
riskBlockedWarnedScoped: input.riskBlockedWarnedScoped === true,
|
|
667
|
-
safePathSuggested: input.safePathSuggested === true,
|
|
668
|
-
visualQaCompleted: input.visualQaCompleted === true,
|
|
669
|
-
routeRecommendationShown: input.routeRecommendationShown === true,
|
|
670
|
-
stateIntegrity: String(input.stateIntegrity || "valid"),
|
|
671
|
-
suppressionState: input.suppressionState || null,
|
|
672
|
-
};
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
function hasAnyValueSignal(input) {
|
|
676
|
-
return Boolean(
|
|
677
|
-
input.activationCompleted
|
|
678
|
-
|| input.firstValueShown
|
|
679
|
-
|| input.proofGenerated
|
|
680
|
-
|| input.handoffCreated
|
|
681
|
-
|| input.reentryUsed
|
|
682
|
-
|| input.contextDisciplineApplied
|
|
683
|
-
|| input.riskBlockedWarnedScoped
|
|
684
|
-
|| input.safePathSuggested
|
|
685
|
-
|| input.visualQaCompleted
|
|
686
|
-
|| input.routeRecommendationShown
|
|
687
|
-
|| input.valueEventsCount > 0,
|
|
688
|
-
);
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
function relatedSurfaceOpen(input) {
|
|
692
|
-
return input.userAction === "viewed_reentry_summary"
|
|
693
|
-
|| input.currentSurface === "reentry"
|
|
694
|
-
|| input.currentSurface === "proof_history"
|
|
695
|
-
|| input.currentSurface === "proof_export"
|
|
696
|
-
|| input.currentSurface === "proof_depth";
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
function activeNextEligibleAt(suppressionState) {
|
|
700
|
-
const values = [
|
|
701
|
-
suppressionState?.globalSuppressedUntil,
|
|
702
|
-
suppressionState?.momentSuppressedUntil,
|
|
703
|
-
suppressionState?.recentlyShownUntil,
|
|
704
|
-
]
|
|
705
|
-
.map((value) => Date.parse(value || ""))
|
|
706
|
-
.filter((value) => Number.isFinite(value));
|
|
707
|
-
if (!values.length) return null;
|
|
708
|
-
return new Date(Math.max(...values)).toISOString();
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
function buildBlockedReasonCodes(input, definition, suppressionState) {
|
|
712
|
-
const blocked = [];
|
|
713
|
-
|
|
714
|
-
if (!definition) return ["moment_unknown"];
|
|
715
|
-
if (!isActiveProMomentDefinition(definition)) blocked.push("moment_disabled");
|
|
716
|
-
if (input.plan !== definition.planRequirement) blocked.push("not_free_plan");
|
|
717
|
-
if (!definition.allowedSurfaces.includes(input.surface)) blocked.push("surface_not_allowed");
|
|
718
|
-
if (input.stateIntegrity === "invalid" && !input.featureRequested) blocked.push("state_invalid");
|
|
719
|
-
if (input.sessionCount <= 1) blocked.push("first_session");
|
|
720
|
-
if (input.activationFailed) blocked.push("activation_failed");
|
|
721
|
-
if (!input.activationCompleted) blocked.push("activation_incomplete");
|
|
722
|
-
if (!hasAnyValueSignal(input)) blocked.push("no_value_signal");
|
|
723
|
-
if (input.currentRiskState !== "safe") blocked.push("risk_state");
|
|
724
|
-
if (input.currentErrorState) blocked.push("error_state");
|
|
725
|
-
if (input.currentRecoveryState) blocked.push("recovery_state");
|
|
726
|
-
if (suppressionState?.globalCooldownActive) blocked.push("cooldown_active");
|
|
727
|
-
if (suppressionState?.momentCooldownActive) blocked.push("moment_cooldown_active");
|
|
728
|
-
if (suppressionState?.recentlyShownActive) blocked.push("recently_shown");
|
|
729
|
-
if (
|
|
730
|
-
!input.featureRequested
|
|
731
|
-
&& suppressionState?.momentState?.dismissCount >= 2
|
|
732
|
-
&& suppressionState?.momentCooldownActive
|
|
733
|
-
) {
|
|
734
|
-
blocked.push("multiple_dismissals_suppressed");
|
|
735
|
-
}
|
|
736
|
-
if (
|
|
737
|
-
!input.featureRequested
|
|
738
|
-
&& Number(suppressionState?.momentState?.dismissCount || 0) >= 1
|
|
739
|
-
&& suppressionState?.momentCooldownActive
|
|
740
|
-
) {
|
|
741
|
-
blocked.push("dismissed_recently");
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
return [...new Set(blocked)];
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
function computeScore(input, suppressionState) {
|
|
748
|
-
let score = 0;
|
|
749
|
-
const reasonCodes = [];
|
|
750
|
-
|
|
751
|
-
if (input.activationCompleted) {
|
|
752
|
-
score += 2;
|
|
753
|
-
reasonCodes.push("activation_completed");
|
|
754
|
-
}
|
|
755
|
-
if (input.firstValueShown || input.valueEventsCount > 0) {
|
|
756
|
-
score += 2;
|
|
757
|
-
reasonCodes.push("value_seen");
|
|
758
|
-
}
|
|
759
|
-
if (input.sessionCount >= 2) {
|
|
760
|
-
score += 2;
|
|
761
|
-
reasonCodes.push("repeat_usage");
|
|
762
|
-
}
|
|
763
|
-
if (input.valueEventsCount >= 3) {
|
|
764
|
-
score += 2;
|
|
765
|
-
reasonCodes.push("value_events_depth");
|
|
766
|
-
}
|
|
767
|
-
if (relatedSurfaceOpen(input)) {
|
|
768
|
-
score += 3;
|
|
769
|
-
reasonCodes.push("related_surface_opened");
|
|
770
|
-
}
|
|
771
|
-
if (input.featureRequested) {
|
|
772
|
-
score += 4;
|
|
773
|
-
reasonCodes.push("feature_requested");
|
|
774
|
-
}
|
|
775
|
-
if (input.quotaReached) {
|
|
776
|
-
score += 4;
|
|
777
|
-
reasonCodes.push("quota_reached");
|
|
778
|
-
}
|
|
779
|
-
if (input.naturalBoundary) {
|
|
780
|
-
score += 2;
|
|
781
|
-
reasonCodes.push("natural_boundary");
|
|
782
|
-
}
|
|
783
|
-
if (input.repeatedFreeCapabilityUsage) {
|
|
784
|
-
score += 2;
|
|
785
|
-
reasonCodes.push("repeated_free_capability_usage");
|
|
786
|
-
}
|
|
787
|
-
|
|
788
|
-
if (input.sessionCount <= 1) score -= 10;
|
|
789
|
-
if (input.currentRiskState !== "safe" || input.currentErrorState || input.currentRecoveryState) score -= 8;
|
|
790
|
-
if (input.activationFailed) score -= 8;
|
|
791
|
-
if (suppressionState?.globalCooldownActive) score -= 8;
|
|
792
|
-
if (suppressionState?.momentCooldownActive) score -= 8;
|
|
793
|
-
if (Number(suppressionState?.momentState?.dismissCount || 0) >= 1) score -= 5;
|
|
794
|
-
if (Number(suppressionState?.momentState?.dismissCount || 0) >= 2) {
|
|
795
|
-
score -= 8;
|
|
796
|
-
}
|
|
797
|
-
if (
|
|
798
|
-
Number(suppressionState?.momentState?.strongModalCount || 0) > 0
|
|
799
|
-
|| Number(suppressionState?.global?.strongModalCount || 0) > 0
|
|
800
|
-
) {
|
|
801
|
-
score -= 8;
|
|
802
|
-
}
|
|
803
|
-
if (suppressionState?.recentlyShownActive) score -= 8;
|
|
804
|
-
|
|
805
|
-
return {
|
|
806
|
-
score,
|
|
807
|
-
reasonCodes,
|
|
808
|
-
};
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
function buildProMomentMessage(momentId, context = {}) {
|
|
812
|
-
const definition = getProMomentDefinition(momentId);
|
|
813
|
-
if (!definition || !definition.copyVariants) return null;
|
|
814
|
-
const useAlternate =
|
|
815
|
-
context.surface === "dashboard"
|
|
816
|
-
|| context.surface === "proof_export"
|
|
817
|
-
|| context.userAction === "viewed_dashboard"
|
|
818
|
-
|| context.valueEventsCount >= 4;
|
|
819
|
-
return {
|
|
820
|
-
title: definition.copyVariants.title,
|
|
821
|
-
body: useAlternate ? definition.copyVariants.alternateBody : definition.copyVariants.body,
|
|
822
|
-
primaryAction: definition.copyVariants.primaryAction,
|
|
823
|
-
secondaryAction: definition.copyVariants.secondaryAction,
|
|
824
|
-
tertiaryAction: definition.copyVariants.tertiaryAction || null,
|
|
825
|
-
};
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
function buildProMomentDetailMessage(momentId) {
|
|
829
|
-
if (momentId === "continuity_depth") {
|
|
830
|
-
return CONTINUITY_DETAILS_MESSAGE;
|
|
831
|
-
}
|
|
832
|
-
if (momentId === "evidence_history_export") {
|
|
833
|
-
return EVIDENCE_HISTORY_DETAILS_MESSAGE;
|
|
834
|
-
}
|
|
835
|
-
return null;
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
function buildProMomentActionCommands(momentId, surface = "status") {
|
|
839
|
-
const safeMomentId = String(momentId || "continuity_depth");
|
|
840
|
-
const safeSurface = String(surface || "status");
|
|
841
|
-
if (safeMomentId === "evidence_history_export") {
|
|
842
|
-
return {
|
|
843
|
-
inspect: {
|
|
844
|
-
label: "See Pro proof history",
|
|
845
|
-
command: `${PRO_MOMENT_HELPER_SCRIPT} inspect ${safeMomentId} --surface ${safeSurface}`,
|
|
846
|
-
},
|
|
847
|
-
dismiss: {
|
|
848
|
-
label: "Not now",
|
|
849
|
-
command: `${PRO_MOMENT_HELPER_SCRIPT} dismiss ${safeMomentId} --surface ${safeSurface}`,
|
|
850
|
-
},
|
|
851
|
-
suppress: {
|
|
852
|
-
label: "Hide proof history",
|
|
853
|
-
command: `${PRO_MOMENT_HELPER_SCRIPT} suppress ${safeMomentId} --surface ${safeSurface}`,
|
|
854
|
-
},
|
|
855
|
-
};
|
|
856
|
-
}
|
|
857
|
-
return {
|
|
858
|
-
inspect: {
|
|
859
|
-
label: "See Pro continuity",
|
|
860
|
-
command: `${PRO_MOMENT_HELPER_SCRIPT} inspect ${safeMomentId} --surface ${safeSurface}`,
|
|
861
|
-
},
|
|
862
|
-
dismiss: {
|
|
863
|
-
label: "Not now",
|
|
864
|
-
command: `${PRO_MOMENT_HELPER_SCRIPT} dismiss ${safeMomentId} --surface ${safeSurface}`,
|
|
865
|
-
},
|
|
866
|
-
suppress: {
|
|
867
|
-
label: "Hide continuity",
|
|
868
|
-
command: `${PRO_MOMENT_HELPER_SCRIPT} suppress ${safeMomentId} --surface ${safeSurface}`,
|
|
869
|
-
},
|
|
870
|
-
};
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
function resolveDisplayLevel(definition, input, score) {
|
|
874
|
-
if (!definition) return "none";
|
|
875
|
-
if (
|
|
876
|
-
score >= 10
|
|
877
|
-
&& (input.featureRequested || input.quotaReached)
|
|
878
|
-
&& definition.allowedDisplayLevels.includes("strong")
|
|
879
|
-
) {
|
|
880
|
-
return "strong";
|
|
881
|
-
}
|
|
882
|
-
if (
|
|
883
|
-
score >= 6
|
|
884
|
-
&& definition.allowedDisplayLevels.includes("contextual_inline")
|
|
885
|
-
&& relatedSurfaceOpen(input)
|
|
886
|
-
) {
|
|
887
|
-
return "contextual_inline";
|
|
888
|
-
}
|
|
889
|
-
if (score >= 6 && definition.allowedDisplayLevels.includes("passive")) {
|
|
890
|
-
return "passive";
|
|
891
|
-
}
|
|
892
|
-
return "none";
|
|
893
|
-
}
|
|
894
|
-
|
|
895
|
-
function evaluateProMomentEligibility(input) {
|
|
896
|
-
const normalized = normalizeMomentInput(input);
|
|
897
|
-
const definition = input?.definitionOverride || getProMomentDefinition(normalized.momentCandidate);
|
|
898
|
-
const suppressionState =
|
|
899
|
-
normalized.suppressionState
|
|
900
|
-
|| getSuppressionState(buildDefaultProMomentState(), normalized.momentCandidate);
|
|
901
|
-
const blockedReasonCodes = buildBlockedReasonCodes(normalized, definition, suppressionState);
|
|
902
|
-
const { score, reasonCodes } = computeScore(normalized, suppressionState);
|
|
903
|
-
const hardBlocked = blockedReasonCodes.length > 0;
|
|
904
|
-
const displayLevel = hardBlocked ? "none" : resolveDisplayLevel(definition, normalized, score);
|
|
905
|
-
const eligible = !hardBlocked && score >= 6 && displayLevel !== "none";
|
|
906
|
-
|
|
907
|
-
return {
|
|
908
|
-
eligible,
|
|
909
|
-
momentId: normalized.momentCandidate,
|
|
910
|
-
displayLevel,
|
|
911
|
-
score,
|
|
912
|
-
reasonCodes,
|
|
913
|
-
blockedReasonCodes,
|
|
914
|
-
nextEligibleAt: eligible ? null : activeNextEligibleAt(suppressionState),
|
|
915
|
-
message: eligible
|
|
916
|
-
? buildProMomentMessage(normalized.momentCandidate, {
|
|
917
|
-
surface: normalized.surface,
|
|
918
|
-
userAction: normalized.userAction,
|
|
919
|
-
valueEventsCount: normalized.valueEventsCount,
|
|
920
|
-
})
|
|
921
|
-
: null,
|
|
922
|
-
};
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
function buildProMomentSurface(cwd, options = {}) {
|
|
926
|
-
const momentId = String(options.momentId || "continuity_depth");
|
|
927
|
-
const stateRead = readProMomentState(cwd);
|
|
928
|
-
const suppressionState = getSuppressionState(stateRead.state, momentId, {
|
|
929
|
-
proactive: options.proactive !== undefined ? options.proactive : !options.featureRequested,
|
|
930
|
-
respectRecentShown:
|
|
931
|
-
options.respectRecentShown !== undefined ? options.respectRecentShown : !options.featureRequested,
|
|
932
|
-
});
|
|
933
|
-
const input = {
|
|
934
|
-
...deriveEligibilityInput(cwd, {
|
|
935
|
-
surface: options.surface || "status",
|
|
936
|
-
status: options.status || {},
|
|
937
|
-
momentId,
|
|
938
|
-
featureRequested: options.featureRequested,
|
|
939
|
-
quotaReached: options.quotaReached,
|
|
940
|
-
plan: options.plan,
|
|
941
|
-
userAction: options.userAction,
|
|
942
|
-
}),
|
|
943
|
-
stateIntegrity: stateRead.integrity,
|
|
944
|
-
suppressionState,
|
|
945
|
-
};
|
|
946
|
-
const decision = evaluateProMomentEligibility(input);
|
|
947
|
-
|
|
948
|
-
return {
|
|
949
|
-
...decision,
|
|
950
|
-
surface: input.surface,
|
|
951
|
-
plan: input.plan,
|
|
952
|
-
sessionCount: input.sessionCount,
|
|
953
|
-
valueEventsCount: input.valueEventsCount,
|
|
954
|
-
dismissCount: suppressionState.momentState.dismissCount,
|
|
955
|
-
cooldownActive:
|
|
956
|
-
suppressionState.globalCooldownActive
|
|
957
|
-
|| suppressionState.momentCooldownActive
|
|
958
|
-
|| suppressionState.recentlyShownActive,
|
|
959
|
-
detailMessage: buildProMomentDetailMessage(momentId),
|
|
960
|
-
actions: buildProMomentActionCommands(momentId, input.surface),
|
|
961
|
-
statePath: stateRead.path,
|
|
962
|
-
stateIntegrity: stateRead.integrity,
|
|
963
|
-
warning: stateRead.warning,
|
|
964
|
-
};
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
function buildCompactProMomentLines(surface) {
|
|
968
|
-
if (!surface?.eligible || !surface.message) return [];
|
|
969
|
-
return [
|
|
970
|
-
`Pro depth available: ${surface.message.body}`,
|
|
971
|
-
`${surface.actions.inspect.label}: ${surface.actions.inspect.command}`,
|
|
972
|
-
`${surface.actions.dismiss.label}: ${surface.actions.dismiss.command}`,
|
|
973
|
-
`${surface.actions.suppress.label}: ${surface.actions.suppress.command}`,
|
|
974
|
-
];
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
function buildEventPayload(surface) {
|
|
978
|
-
return {
|
|
979
|
-
momentId: surface.momentId,
|
|
980
|
-
surface: surface.surface,
|
|
981
|
-
displayLevel: surface.displayLevel,
|
|
982
|
-
reasonCodes: surface.reasonCodes,
|
|
983
|
-
blockedReasonCodes: surface.blockedReasonCodes,
|
|
984
|
-
plan: surface.plan,
|
|
985
|
-
sessionCount: surface.sessionCount,
|
|
986
|
-
valueEventsCount: surface.valueEventsCount,
|
|
987
|
-
dismissCount: surface.dismissCount,
|
|
988
|
-
cooldownActive: surface.cooldownActive,
|
|
989
|
-
nextEligibleAt: surface.nextEligibleAt,
|
|
990
|
-
timestamp: nowIso(),
|
|
991
|
-
};
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
function recordProMomentShown(cwd, params = {}) {
|
|
995
|
-
const momentId = String(params.momentId || "continuity_depth");
|
|
996
|
-
const now = params.timestamp || nowIso();
|
|
997
|
-
|
|
998
|
-
const writeResult = updateProMomentState(cwd, (current) => {
|
|
999
|
-
const source = current || buildDefaultProMomentState();
|
|
1000
|
-
const currentMoment = getMomentStateEntry(source, momentId);
|
|
1001
|
-
return {
|
|
1002
|
-
...source,
|
|
1003
|
-
global: {
|
|
1004
|
-
...source.global,
|
|
1005
|
-
lastShownAt: now,
|
|
1006
|
-
strongModalCount:
|
|
1007
|
-
source.global.strongModalCount + (params.displayLevel === "strong" ? 1 : 0),
|
|
1008
|
-
},
|
|
1009
|
-
moments: {
|
|
1010
|
-
...source.moments,
|
|
1011
|
-
[momentId]: {
|
|
1012
|
-
...currentMoment,
|
|
1013
|
-
lastShownAt: now,
|
|
1014
|
-
shownCount: currentMoment.shownCount + 1,
|
|
1015
|
-
},
|
|
1016
|
-
},
|
|
1017
|
-
};
|
|
1018
|
-
});
|
|
1019
|
-
|
|
1020
|
-
const event = appendProMomentEvent(cwd, "pro_nudge_shown", {
|
|
1021
|
-
...params,
|
|
1022
|
-
momentId,
|
|
1023
|
-
timestamp: now,
|
|
1024
|
-
});
|
|
1025
|
-
|
|
1026
|
-
return {
|
|
1027
|
-
ok: writeResult.ok && event.ok,
|
|
1028
|
-
statePath: writeResult.path,
|
|
1029
|
-
event,
|
|
1030
|
-
};
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
function recordProMomentClicked(cwd, params = {}) {
|
|
1034
|
-
const momentId = String(params.momentId || "continuity_depth");
|
|
1035
|
-
const now = params.timestamp || nowIso();
|
|
1036
|
-
|
|
1037
|
-
updateProMomentState(cwd, (current) => {
|
|
1038
|
-
const source = current || buildDefaultProMomentState();
|
|
1039
|
-
const currentMoment = getMomentStateEntry(source, momentId);
|
|
1040
|
-
return {
|
|
1041
|
-
...source,
|
|
1042
|
-
moments: {
|
|
1043
|
-
...source.moments,
|
|
1044
|
-
[momentId]: {
|
|
1045
|
-
...currentMoment,
|
|
1046
|
-
clickedCount: currentMoment.clickedCount + 1,
|
|
1047
|
-
lastClickedAt: now,
|
|
1048
|
-
},
|
|
1049
|
-
},
|
|
1050
|
-
};
|
|
1051
|
-
});
|
|
1052
|
-
|
|
1053
|
-
return appendProMomentEvent(cwd, "pro_nudge_clicked", {
|
|
1054
|
-
...params,
|
|
1055
|
-
momentId,
|
|
1056
|
-
timestamp: now,
|
|
1057
|
-
});
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
function recordProMomentDismissed(cwd, params = {}) {
|
|
1061
|
-
const momentId = String(params.momentId || "continuity_depth");
|
|
1062
|
-
const now = params.timestamp || nowIso();
|
|
1063
|
-
const kind = params.kind === "dont_show_again" ? "dont_show_again" : "not_now";
|
|
1064
|
-
|
|
1065
|
-
const updated = updateProMomentState(cwd, (current) => {
|
|
1066
|
-
const source = current || buildDefaultProMomentState();
|
|
1067
|
-
const currentMoment = getMomentStateEntry(source, momentId);
|
|
1068
|
-
const nextMomentDismissCount = currentMoment.dismissCount + 1;
|
|
1069
|
-
const nextGlobalDismissCount = Number(source.global.dismissCount || 0) + 1;
|
|
1070
|
-
const momentSuppressedDays =
|
|
1071
|
-
kind === "dont_show_again"
|
|
1072
|
-
? 60
|
|
1073
|
-
: nextMomentDismissCount >= 2
|
|
1074
|
-
? 30
|
|
1075
|
-
: 14;
|
|
1076
|
-
const globalSuppressedDays = nextGlobalDismissCount >= 3 ? 30 : 7;
|
|
1077
|
-
|
|
1078
|
-
return {
|
|
1079
|
-
...source,
|
|
1080
|
-
global: {
|
|
1081
|
-
...source.global,
|
|
1082
|
-
dismissCount: nextGlobalDismissCount,
|
|
1083
|
-
suppressedUntil: new Date(
|
|
1084
|
-
Date.parse(now) + globalSuppressedDays * 24 * 60 * 60 * 1000,
|
|
1085
|
-
).toISOString(),
|
|
1086
|
-
},
|
|
1087
|
-
moments: {
|
|
1088
|
-
...source.moments,
|
|
1089
|
-
[momentId]: {
|
|
1090
|
-
...currentMoment,
|
|
1091
|
-
dismissCount: nextMomentDismissCount,
|
|
1092
|
-
lastDismissedAt: now,
|
|
1093
|
-
suppressedUntil: new Date(
|
|
1094
|
-
Date.parse(now) + momentSuppressedDays * 24 * 60 * 60 * 1000,
|
|
1095
|
-
).toISOString(),
|
|
1096
|
-
},
|
|
1097
|
-
},
|
|
1098
|
-
};
|
|
1099
|
-
});
|
|
1100
|
-
|
|
1101
|
-
const nextState = readProMomentState(cwd).state;
|
|
1102
|
-
const nextMoment = getMomentStateEntry(nextState, momentId);
|
|
1103
|
-
appendProMomentEvent(cwd, "pro_nudge_dismissed", {
|
|
1104
|
-
...params,
|
|
1105
|
-
momentId,
|
|
1106
|
-
dismissCount: nextMoment.dismissCount,
|
|
1107
|
-
timestamp: now,
|
|
1108
|
-
});
|
|
1109
|
-
appendProMomentEvent(cwd, "pro_nudge_cooldown_started", {
|
|
1110
|
-
...params,
|
|
1111
|
-
momentId,
|
|
1112
|
-
dismissCount: nextMoment.dismissCount,
|
|
1113
|
-
cooldownActive: true,
|
|
1114
|
-
nextEligibleAt: nextMoment.suppressedUntil,
|
|
1115
|
-
timestamp: now,
|
|
1116
|
-
});
|
|
1117
|
-
if (kind === "not_now") {
|
|
1118
|
-
appendProMomentEvent(cwd, "pro_nudge_not_now_clicked", {
|
|
1119
|
-
...params,
|
|
1120
|
-
momentId,
|
|
1121
|
-
dismissCount: nextMoment.dismissCount,
|
|
1122
|
-
timestamp: now,
|
|
1123
|
-
});
|
|
1124
|
-
}
|
|
1125
|
-
if (kind === "dont_show_again") {
|
|
1126
|
-
appendProMomentEvent(cwd, "pro_nudge_dont_show_again_clicked", {
|
|
1127
|
-
...params,
|
|
1128
|
-
momentId,
|
|
1129
|
-
dismissCount: nextMoment.dismissCount,
|
|
1130
|
-
cooldownActive: true,
|
|
1131
|
-
nextEligibleAt: nextMoment.suppressedUntil,
|
|
1132
|
-
timestamp: now,
|
|
1133
|
-
});
|
|
1134
|
-
}
|
|
1135
|
-
if (nextMoment.dismissCount >= 2) {
|
|
1136
|
-
appendProMomentEvent(cwd, "pro_nudge_multiple_dismissals", {
|
|
1137
|
-
...params,
|
|
1138
|
-
momentId,
|
|
1139
|
-
dismissCount: nextMoment.dismissCount,
|
|
1140
|
-
cooldownActive: true,
|
|
1141
|
-
nextEligibleAt: nextMoment.suppressedUntil,
|
|
1142
|
-
timestamp: now,
|
|
1143
|
-
});
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
return {
|
|
1147
|
-
ok: updated.ok,
|
|
1148
|
-
statePath: updated.path,
|
|
1149
|
-
state: nextState,
|
|
1150
|
-
};
|
|
1151
|
-
}
|
|
1152
|
-
|
|
1153
|
-
function recordProMomentEvaluation(cwd, surface, options = {}) {
|
|
1154
|
-
if (!surface || !surface.momentId) return { ok: false, reason: "missing_surface" };
|
|
1155
|
-
if (options.humanVisible === false) {
|
|
1156
|
-
return { ok: true, skipped: true, reason: "not_human_visible" };
|
|
1157
|
-
}
|
|
1158
|
-
const payload = buildEventPayload(surface);
|
|
1159
|
-
const shouldLogSuppression =
|
|
1160
|
-
surface.eligible
|
|
1161
|
-
|| surface.blockedReasonCodes?.includes("cooldown_active")
|
|
1162
|
-
|| surface.blockedReasonCodes?.includes("moment_cooldown_active")
|
|
1163
|
-
|| surface.blockedReasonCodes?.includes("recently_shown")
|
|
1164
|
-
|| surface.blockedReasonCodes?.includes("multiple_dismissals_suppressed")
|
|
1165
|
-
|| surface.blockedReasonCodes?.includes("state_invalid");
|
|
1166
|
-
if (!shouldLogSuppression) {
|
|
1167
|
-
return { ok: true, skipped: true };
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
appendProMomentEvent(cwd, "pro_moment_candidate_detected", payload);
|
|
1171
|
-
|
|
1172
|
-
if (surface.eligible) {
|
|
1173
|
-
appendProMomentEvent(cwd, "pro_moment_eligible", payload);
|
|
1174
|
-
return recordProMomentShown(cwd, payload);
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
if (surface.blockedReasonCodes?.length) {
|
|
1178
|
-
appendProMomentEvent(cwd, "pro_moment_suppressed", payload);
|
|
1179
|
-
if (
|
|
1180
|
-
surface.blockedReasonCodes.includes("cooldown_active")
|
|
1181
|
-
|| surface.blockedReasonCodes.includes("moment_cooldown_active")
|
|
1182
|
-
|| surface.blockedReasonCodes.includes("recently_shown")
|
|
1183
|
-
) {
|
|
1184
|
-
appendProMomentEvent(cwd, "pro_nudge_hidden_due_to_cooldown", payload);
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
|
|
1188
|
-
return { ok: true, suppressed: true };
|
|
1189
|
-
}
|
|
1190
|
-
|
|
1191
|
-
module.exports = {
|
|
1192
|
-
ALLOWED_PRO_DEPTH_AREAS,
|
|
1193
|
-
PRO_MOMENT_COPY_GUARD_PROFILES,
|
|
1194
|
-
PRO_MOMENT_DEFINITIONS,
|
|
1195
|
-
PRO_MOMENT_MATURITY_LEVELS,
|
|
1196
|
-
PRO_MOMENT_PRIVACY_PROFILES,
|
|
1197
|
-
PRO_MOMENT_REQUIRED_USER_CONTROLS,
|
|
1198
|
-
PRO_MOMENT_TELEMETRY_PROFILES,
|
|
1199
|
-
TRUST_CRITICAL_BASELINES,
|
|
1200
|
-
buildCompactProMomentLines,
|
|
1201
|
-
buildProMomentActionCommands,
|
|
1202
|
-
buildProMomentDetailMessage,
|
|
1203
|
-
buildProMomentMessage,
|
|
1204
|
-
buildProMomentSurface,
|
|
1205
|
-
deriveEligibilityInput,
|
|
1206
|
-
evaluateProMomentEligibility,
|
|
1207
|
-
getProMomentDefinition,
|
|
1208
|
-
isActiveProMomentDefinition,
|
|
1209
|
-
isTrustCriticalBaseline,
|
|
1210
|
-
listProMomentDefinitions,
|
|
1211
|
-
recordProMomentClicked,
|
|
1212
|
-
recordProMomentDismissed,
|
|
1213
|
-
recordProMomentEvaluation,
|
|
1214
|
-
recordProMomentShown,
|
|
1215
|
-
validateProMomentDefinitions,
|
|
1216
|
-
};
|