@principles/pd-cli 1.152.11 → 1.152.13
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/dist/commands/candidate.d.ts +3 -3
- package/dist/commands/candidate.d.ts.map +1 -1
- package/dist/commands/candidate.js +9 -21
- package/dist/commands/candidate.js.map +1 -1
- package/dist/index.js +0 -0
- package/dist/services/rulehost-pipeline-runner.d.ts.map +1 -1
- package/dist/services/rulehost-pipeline-runner.js +4 -17
- package/dist/services/rulehost-pipeline-runner.js.map +1 -1
- package/package.json +13 -7
- package/dist/commands/__tests__/intent-flag-wiring.test.d.ts +0 -9
- package/dist/commands/__tests__/intent-flag-wiring.test.d.ts.map +0 -1
- package/dist/commands/__tests__/intent-flag-wiring.test.js +0 -237
- package/dist/commands/__tests__/intent-flag-wiring.test.js.map +0 -1
- package/dist/commands/__tests__/legacy-cleanup.test.d.ts +0 -18
- package/dist/commands/__tests__/legacy-cleanup.test.d.ts.map +0 -1
- package/dist/commands/__tests__/legacy-cleanup.test.js +0 -467
- package/dist/commands/__tests__/legacy-cleanup.test.js.map +0 -1
- package/dist/commands/__tests__/mvp-smoke.test.d.ts +0 -15
- package/dist/commands/__tests__/mvp-smoke.test.d.ts.map +0 -1
- package/dist/commands/__tests__/mvp-smoke.test.js +0 -262
- package/dist/commands/__tests__/mvp-smoke.test.js.map +0 -1
- package/dist/commands/__tests__/pain-retry-maxTokens-flag.test.d.ts +0 -2
- package/dist/commands/__tests__/pain-retry-maxTokens-flag.test.d.ts.map +0 -1
- package/dist/commands/__tests__/pain-retry-maxTokens-flag.test.js +0 -60
- package/dist/commands/__tests__/pain-retry-maxTokens-flag.test.js.map +0 -1
- package/dist/commands/__tests__/rulecode-flag-wiring.test.d.ts +0 -21
- package/dist/commands/__tests__/rulecode-flag-wiring.test.d.ts.map +0 -1
- package/dist/commands/__tests__/rulecode-flag-wiring.test.js +0 -186
- package/dist/commands/__tests__/rulecode-flag-wiring.test.js.map +0 -1
- package/dist/commands/__tests__/rulecode-handler.test.d.ts +0 -16
- package/dist/commands/__tests__/rulecode-handler.test.d.ts.map +0 -1
- package/dist/commands/__tests__/rulecode-handler.test.js +0 -285
- package/dist/commands/__tests__/rulecode-handler.test.js.map +0 -1
- package/dist/commands/__tests__/run-rulehost-flag-wiring.test.d.ts +0 -24
- package/dist/commands/__tests__/run-rulehost-flag-wiring.test.d.ts.map +0 -1
- package/dist/commands/__tests__/run-rulehost-flag-wiring.test.js +0 -232
- package/dist/commands/__tests__/run-rulehost-flag-wiring.test.js.map +0 -1
- package/dist/commands/__tests__/runtime-activation-nextaction.test.d.ts +0 -15
- package/dist/commands/__tests__/runtime-activation-nextaction.test.d.ts.map +0 -1
- package/dist/commands/__tests__/runtime-activation-nextaction.test.js +0 -73
- package/dist/commands/__tests__/runtime-activation-nextaction.test.js.map +0 -1
- package/dist/commands/__tests__/runtime-probe-config.test.d.ts +0 -20
- package/dist/commands/__tests__/runtime-probe-config.test.d.ts.map +0 -1
- package/dist/commands/__tests__/runtime-probe-config.test.js +0 -389
- package/dist/commands/__tests__/runtime-probe-config.test.js.map +0 -1
- package/dist/commands/__tests__/telemetry-flag-wiring.test.d.ts +0 -9
- package/dist/commands/__tests__/telemetry-flag-wiring.test.d.ts.map +0 -1
- package/dist/commands/__tests__/telemetry-flag-wiring.test.js +0 -76
- package/dist/commands/__tests__/telemetry-flag-wiring.test.js.map +0 -1
- package/dist/commands/__tests__/version.test.d.ts +0 -2
- package/dist/commands/__tests__/version.test.d.ts.map +0 -1
- package/dist/commands/__tests__/version.test.js +0 -238
- package/dist/commands/__tests__/version.test.js.map +0 -1
- package/dist/commands/runtime-uat.guard.test.d.ts +0 -2
- package/dist/commands/runtime-uat.guard.test.d.ts.map +0 -1
- package/dist/commands/runtime-uat.guard.test.js +0 -153
- package/dist/commands/runtime-uat.guard.test.js.map +0 -1
- package/dist/services/__tests__/cli-output.test.d.ts +0 -18
- package/dist/services/__tests__/cli-output.test.d.ts.map +0 -1
- package/dist/services/__tests__/cli-output.test.js +0 -103
- package/dist/services/__tests__/cli-output.test.js.map +0 -1
- package/dist/services/__tests__/evaluator-runner-deps.test.d.ts +0 -2
- package/dist/services/__tests__/evaluator-runner-deps.test.d.ts.map +0 -1
- package/dist/services/__tests__/evaluator-runner-deps.test.js +0 -343
- package/dist/services/__tests__/evaluator-runner-deps.test.js.map +0 -1
- package/dist/services/__tests__/rulehost-readiness.test.d.ts +0 -2
- package/dist/services/__tests__/rulehost-readiness.test.d.ts.map +0 -1
- package/dist/services/__tests__/rulehost-readiness.test.js +0 -311
- package/dist/services/__tests__/rulehost-readiness.test.js.map +0 -1
- package/dist/services/__tests__/runtime-adapter-resolver.test.d.ts +0 -18
- package/dist/services/__tests__/runtime-adapter-resolver.test.d.ts.map +0 -1
- package/dist/services/__tests__/runtime-adapter-resolver.test.js +0 -673
- package/dist/services/__tests__/runtime-adapter-resolver.test.js.map +0 -1
- package/dist/utils/production-workspace-guard.test.d.ts +0 -2
- package/dist/utils/production-workspace-guard.test.d.ts.map +0 -1
- package/dist/utils/production-workspace-guard.test.js +0 -137
- package/dist/utils/production-workspace-guard.test.js.map +0 -1
- package/scripts/llm-dogfood.ts +0 -456
- package/scripts/migrate-illegal-expected-decision.ts +0 -252
- package/src/commands/__tests__/intent-flag-wiring.test.ts +0 -282
- package/src/commands/__tests__/legacy-cleanup.test.ts +0 -602
- package/src/commands/__tests__/mvp-smoke.test.ts +0 -300
- package/src/commands/__tests__/pain-retry-maxTokens-flag.test.ts +0 -73
- package/src/commands/__tests__/rulecode-flag-wiring.test.ts +0 -237
- package/src/commands/__tests__/rulecode-handler.test.ts +0 -369
- package/src/commands/__tests__/run-rulehost-flag-wiring.test.ts +0 -292
- package/src/commands/__tests__/runtime-activation-nextaction.test.ts +0 -81
- package/src/commands/__tests__/runtime-probe-config.test.ts +0 -432
- package/src/commands/__tests__/telemetry-flag-wiring.test.ts +0 -84
- package/src/commands/__tests__/version.test.ts +0 -251
- package/src/commands/admission-gate.ts +0 -30
- package/src/commands/artifact.ts +0 -82
- package/src/commands/build-trajectory-evidence.ts +0 -298
- package/src/commands/candidate.ts +0 -1260
- package/src/commands/codex-ingest-catchup.ts +0 -114
- package/src/commands/codex-ingest-quarantine.ts +0 -127
- package/src/commands/codex-reconcile.ts +0 -84
- package/src/commands/codex-setup.ts +0 -476
- package/src/commands/codex-worker.ts +0 -185
- package/src/commands/command-helpers.ts +0 -24
- package/src/commands/config-doctor.ts +0 -193
- package/src/commands/console.ts +0 -797
- package/src/commands/context.ts +0 -72
- package/src/commands/demo-story-a.ts +0 -241
- package/src/commands/diagnose.ts +0 -756
- package/src/commands/errors-list.ts +0 -441
- package/src/commands/evolution-tasks-list.ts +0 -48
- package/src/commands/evolution-tasks-show.ts +0 -62
- package/src/commands/flow.ts +0 -60
- package/src/commands/health-codex.ts +0 -576
- package/src/commands/health.ts +0 -315
- package/src/commands/history.ts +0 -63
- package/src/commands/intent.ts +0 -457
- package/src/commands/legacy-cleanup.ts +0 -531
- package/src/commands/legacy-import.ts +0 -104
- package/src/commands/mvp-smoke.ts +0 -160
- package/src/commands/pain-evidence.ts +0 -226
- package/src/commands/pain-list.ts +0 -239
- package/src/commands/pain-record.ts +0 -612
- package/src/commands/pain-retry.ts +0 -916
- package/src/commands/principles-stats.ts +0 -700
- package/src/commands/proven-channel-baseline.ts +0 -115
- package/src/commands/quality-scorecard.ts +0 -272
- package/src/commands/remediation-output.ts +0 -66
- package/src/commands/rulecode.ts +0 -465
- package/src/commands/run.ts +0 -89
- package/src/commands/runtime-activation.ts +0 -1629
- package/src/commands/runtime-artifact-repair.ts +0 -524
- package/src/commands/runtime-canary.ts +0 -395
- package/src/commands/runtime-compatibility-scan.ts +0 -105
- package/src/commands/runtime-diagnostics-export.ts +0 -229
- package/src/commands/runtime-features.ts +0 -153
- package/src/commands/runtime-gfi-snapshot.ts +0 -135
- package/src/commands/runtime-health-snapshot.ts +0 -108
- package/src/commands/runtime-init.ts +0 -429
- package/src/commands/runtime-internalization-enqueue-successors.ts +0 -530
- package/src/commands/runtime-internalization-integrity-repair.ts +0 -79
- package/src/commands/runtime-internalization-integrity.ts +0 -107
- package/src/commands/runtime-internalization-queue.ts +0 -135
- package/src/commands/runtime-internalization-retry.ts +0 -191
- package/src/commands/runtime-internalization-run-once.ts +0 -791
- package/src/commands/runtime-internalization-run-rulehost.ts +0 -749
- package/src/commands/runtime-internalization-wake-once.ts +0 -87
- package/src/commands/runtime-pain-flood-simulation.ts +0 -121
- package/src/commands/runtime-pruning.ts +0 -438
- package/src/commands/runtime-recovery-failed-tasks.ts +0 -258
- package/src/commands/runtime-recovery.ts +0 -109
- package/src/commands/runtime-synthetic-baseline.ts +0 -70
- package/src/commands/runtime-uat.guard.test.ts +0 -175
- package/src/commands/runtime-uat.ts +0 -380
- package/src/commands/runtime.ts +0 -473
- package/src/commands/samples-list.ts +0 -39
- package/src/commands/samples-review.ts +0 -36
- package/src/commands/task.ts +0 -271
- package/src/commands/telemetry.ts +0 -349
- package/src/commands/trace.ts +0 -174
- package/src/commands/trajectory-db-unavailable.ts +0 -19
- package/src/commands/trajectory.ts +0 -64
- package/src/commands/version.ts +0 -49
- package/src/config-reader.ts +0 -122
- package/src/index.ts +0 -1276
- package/src/legacy/legacy-import.ts +0 -179
- package/src/legacy/session-history-import.ts +0 -203
- package/src/resolve-workspace.ts +0 -106
- package/src/services/__tests__/cli-output.test.ts +0 -130
- package/src/services/__tests__/evaluator-runner-deps.test.ts +0 -382
- package/src/services/__tests__/rulehost-readiness.test.ts +0 -363
- package/src/services/__tests__/runtime-adapter-resolver.test.ts +0 -793
- package/src/services/cli-output.ts +0 -95
- package/src/services/config-doctor.ts +0 -697
- package/src/services/console-launcher.ts +0 -537
- package/src/services/demo-rule-compiler.ts +0 -40
- package/src/services/demo-story-a-runner.ts +0 -471
- package/src/services/mainline-snapshot-assembler.ts +0 -579
- package/src/services/pain-flood-simulation-runner.ts +0 -462
- package/src/services/pd-config-loader.ts +0 -433
- package/src/services/proven-channel-baseline-runner.ts +0 -157
- package/src/services/quality-scorecard/data-extractor.ts +0 -150
- package/src/services/quality-scorecard/local-evaluator.ts +0 -142
- package/src/services/quality-scorecard/strong-model-gate.ts +0 -202
- package/src/services/resolve-runtime-from-pd-config.ts +0 -230
- package/src/services/rulehost-pipeline-runner.ts +0 -1216
- package/src/services/rulehost-readiness.ts +0 -326
- package/src/services/runtime-adapter-resolver.ts +0 -364
- package/src/services/synthetic-baseline-runner.ts +0 -400
- package/src/services/version-report.ts +0 -253
- package/src/services/workspace-tool-semantics.ts +0 -26
- package/src/utils/path-security.ts +0 -96
- package/src/utils/production-workspace-guard.test.ts +0 -157
- package/src/utils/production-workspace-guard.ts +0 -210
- package/tests/bdd/cli-contract.steps.ts +0 -346
- package/tests/bdd/principles-stats.steps.ts +0 -211
- package/tests/bdd/support/gherkin-loader.ts +0 -147
- package/tests/bdd/support/repo-root.ts +0 -62
- package/tests/bdd/support/vitest-bdd.ts +0 -179
- package/tests/commands/admission-gate-coverage.test.ts +0 -79
- package/tests/commands/build-trajectory-evidence.test.ts +0 -508
- package/tests/commands/candidate-audit-repair.test.ts +0 -421
- package/tests/commands/candidate-intake.test.ts +0 -732
- package/tests/commands/candidate-internalization-backfill.test.ts +0 -548
- package/tests/commands/candidate-internalize-lineage.test.ts +0 -565
- package/tests/commands/candidate-internalize.test.ts +0 -299
- package/tests/commands/candidate-route.test.ts +0 -329
- package/tests/commands/candidate-show.test.ts +0 -95
- package/tests/commands/cli-command-tree.test.ts +0 -144
- package/tests/commands/cli-help-snapshot.test.ts +0 -155
- package/tests/commands/cli-skill-contract.test.ts +0 -121
- package/tests/commands/codex-consent-reversibility.steps.test.ts +0 -299
- package/tests/commands/codex-ingest-quarantine.test.ts +0 -136
- package/tests/commands/codex-setup.test.ts +0 -297
- package/tests/commands/codex-worker-daemon.test.ts +0 -95
- package/tests/commands/codex-worker-registration.test.ts +0 -207
- package/tests/commands/config-doctor.test.ts +0 -336
- package/tests/commands/console-launcher-edge-cases.test.ts +0 -388
- package/tests/commands/console-open.test.ts +0 -1381
- package/tests/commands/context.test.ts +0 -114
- package/tests/commands/demo-story-a.test.ts +0 -318
- package/tests/commands/diagnose.test.ts +0 -1803
- package/tests/commands/errors-list.test.ts +0 -679
- package/tests/commands/evolution-tasks-list.test.ts +0 -41
- package/tests/commands/evolution-tasks-show.test.ts +0 -46
- package/tests/commands/health-codex.test.ts +0 -349
- package/tests/commands/health-host-wiring.test.ts +0 -76
- package/tests/commands/health-reliability.test.ts +0 -99
- package/tests/commands/health.test.ts +0 -413
- package/tests/commands/intent.test.ts +0 -321
- package/tests/commands/legacy-cleanup.test.ts +0 -148
- package/tests/commands/pain-evidence.test.ts +0 -518
- package/tests/commands/pain-list.test.ts +0 -219
- package/tests/commands/pain-record-async.test.ts +0 -335
- package/tests/commands/pain-record-session-parser.test.ts +0 -228
- package/tests/commands/pain-record.test.ts +0 -851
- package/tests/commands/pain-retry.test.ts +0 -1121
- package/tests/commands/plugin-config-resolution-cutover.test.ts +0 -229
- package/tests/commands/pri-393-runtime-config-unification.test.ts +0 -443
- package/tests/commands/principles-stats-wiring.test.ts +0 -135
- package/tests/commands/principles-stats.test.ts +0 -274
- package/tests/commands/product-path-regression.test.ts +0 -86
- package/tests/commands/proven-channel-baseline.test.ts +0 -441
- package/tests/commands/rulecode.test.ts +0 -177
- package/tests/commands/run-rulehost-handler.test.ts +0 -908
- package/tests/commands/runtime-activation-approve-flag-wiring.test.ts +0 -227
- package/tests/commands/runtime-activation-deactivate-flag-wiring.test.ts +0 -167
- package/tests/commands/runtime-activation-dispatch-flag-wiring.test.ts +0 -262
- package/tests/commands/runtime-activation-governance-audit.test.ts +0 -95
- package/tests/commands/runtime-activation-list-flag-wiring.test.ts +0 -193
- package/tests/commands/runtime-activation-promote-flag-wiring.test.ts +0 -248
- package/tests/commands/runtime-activation-shadow-telemetry.test.ts +0 -130
- package/tests/commands/runtime-activation.test.ts +0 -2052
- package/tests/commands/runtime-artifact-repair-registration.test.ts +0 -74
- package/tests/commands/runtime-artifact-repair.test.ts +0 -404
- package/tests/commands/runtime-canary.test.ts +0 -430
- package/tests/commands/runtime-compatibility-scan.test.ts +0 -146
- package/tests/commands/runtime-diagnostics-export.test.ts +0 -175
- package/tests/commands/runtime-features.test.ts +0 -249
- package/tests/commands/runtime-health-snapshot.test.ts +0 -358
- package/tests/commands/runtime-init-empty-workspace.test.ts +0 -252
- package/tests/commands/runtime-init.test.ts +0 -420
- package/tests/commands/runtime-internalization-enqueue-successors.test.ts +0 -782
- package/tests/commands/runtime-internalization-integrity-repair.test.ts +0 -239
- package/tests/commands/runtime-internalization-integrity.test.ts +0 -140
- package/tests/commands/runtime-internalization-queue.test.ts +0 -380
- package/tests/commands/runtime-internalization-retry-owner-authority.test.ts +0 -431
- package/tests/commands/runtime-internalization-run-once-evaluator-parity.test.ts +0 -269
- package/tests/commands/runtime-internalization-run-once-language.test.ts +0 -303
- package/tests/commands/runtime-internalization-run-once-real-config.test.ts +0 -237
- package/tests/commands/runtime-internalization-run-once-rollout-parity.test.ts +0 -706
- package/tests/commands/runtime-internalization-run-once.test.ts +0 -1791
- package/tests/commands/runtime-internalization-wake-once.test.ts +0 -171
- package/tests/commands/runtime-internalization.test.ts +0 -53
- package/tests/commands/runtime-pain-flood-simulation.test.ts +0 -418
- package/tests/commands/runtime-pruning.test.ts +0 -694
- package/tests/commands/runtime-recovery-failed-tasks.test.ts +0 -328
- package/tests/commands/runtime-recovery.test.ts +0 -120
- package/tests/commands/runtime-synthetic-baseline.test.ts +0 -249
- package/tests/commands/runtime-uat.test.ts +0 -397
- package/tests/commands/runtime.test.ts +0 -392
- package/tests/commands/samples-list.test.ts +0 -43
- package/tests/commands/samples-review.test.ts +0 -41
- package/tests/commands/task.test.ts +0 -153
- package/tests/commands/telemetry.test.ts +0 -190
- package/tests/commands/trace.test.ts +0 -316
- package/tests/config-reader.test.ts +0 -143
- package/tests/e2e/candidate-intake-e2e.test.ts +0 -338
- package/tests/e2e/cli-full-flow.test.ts +0 -233
- package/tests/e2e/cross-package-acceptance.test.ts +0 -635
- package/tests/helpers/pd-cli-path.ts +0 -5
- package/tests/pd-cli-smoke.test.ts +0 -13
- package/tests/resolve-workspace.test.ts +0 -196
- package/tests/services/config-doctor-signal-health.test.ts +0 -109
- package/tests/services/console-launcher.test.ts +0 -114
- package/tests/services/demo-rule-compiler.test.ts +0 -242
- package/tests/services/mainline-snapshot-assembler.test.ts +0 -572
- package/tests/services/pd-config-loader.test.ts +0 -505
- package/tests/services/proven-channel-baseline-runner.test.ts +0 -30
- package/tests/services/quality-scorecard/strong-model-gate.test.ts +0 -133
- package/tests/services/resolve-runtime-from-pd-config.test.ts +0 -485
- package/tests/services/rulehost-pipeline-e2e.test.ts +0 -538
- package/tests/services/rulehost-pipeline-runner.test.ts +0 -1175
- package/tests/services/workspace-tool-semantics.test.ts +0 -76
- package/tests/utils/path-security.test.ts +0 -180
- package/tsconfig.json +0 -26
- package/vitest.config.ts +0 -9
|
@@ -1,299 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, expect, vi } from 'vitest';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import os from 'node:os';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import * as yaml from 'js-yaml';
|
|
6
|
-
import { getDefaultPdConfig } from '@principles/core/runtime-v2';
|
|
7
|
-
import { catchUpCodexIngestion } from '@principles/codex-adapter';
|
|
8
|
-
import {
|
|
9
|
-
ingestGovernanceObservations,
|
|
10
|
-
listGovernanceObservations,
|
|
11
|
-
promoteGovernanceEvidence,
|
|
12
|
-
readCodexIngestionConsent,
|
|
13
|
-
CODEX_INGESTION_DISCLOSURE_VERSION,
|
|
14
|
-
} from '@principles/host-runtime';
|
|
15
|
-
import { createStepRegistry, defineFeature } from '../../../principles-core/tests/bdd/support/vitest-bdd.js';
|
|
16
|
-
import { resolveFeaturePath } from '../../../principles-core/tests/bdd/support/repo-root.js';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Codex Governance Closure Slice D (PRI-625): consent & reversibility BDD
|
|
20
|
-
* steps for SPEC rev 2 §18 scenarios 17 and 15 (flag-off half). Drives the
|
|
21
|
-
* REAL setup handler (the installed-path consent authority) and the REAL
|
|
22
|
-
* catch-up/consent/evidence seams. The uninstall/legacy-migration half of
|
|
23
|
-
* §18-15 is bound in create-principles-disciple's installer suites.
|
|
24
|
-
*
|
|
25
|
-
* R1 behaviors proven here (SPEC §3):
|
|
26
|
-
* R1-1 the disclosure is presented before ingestion can be enabled;
|
|
27
|
-
* R1-2 declining leaves the flag off and governance working unchanged;
|
|
28
|
-
* R1-3 declining never opens or reads the transcript;
|
|
29
|
-
* R1-4 upgrade/machine paths never enable ingestion implicitly.
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
let logLines: string[];
|
|
33
|
-
|
|
34
|
-
/** Guarded path builder: only allowlisted basenames under <root>/.pd. */
|
|
35
|
-
function pdFile(root: string, name: string): string | null {
|
|
36
|
-
if (!FILENAME_ALLOWLIST.includes(name)) return null;
|
|
37
|
-
const base = path.join(root, '.pd');
|
|
38
|
-
const target = path.join(base, name);
|
|
39
|
-
if (!target.startsWith(base + path.sep)) return null;
|
|
40
|
-
return target;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const FILENAME_ALLOWLIST = ['config.yaml', 'codex-ingestion-consent.json'];
|
|
44
|
-
|
|
45
|
-
function makeWorkspace(options: { handEnableIngestion?: boolean } = {}): string {
|
|
46
|
-
const ws = fs.mkdtempSync(path.join(os.tmpdir(), 'pd-bdd-consent-'));
|
|
47
|
-
fs.mkdirSync(path.join(ws, '.pd'), { recursive: true });
|
|
48
|
-
fs.mkdirSync(path.join(ws, '.state'), { recursive: true });
|
|
49
|
-
fs.writeFileSync(path.join(ws, '.state', 'trajectory.db'), '');
|
|
50
|
-
const config = getDefaultPdConfig();
|
|
51
|
-
config.features['host.codex'].enabled = true;
|
|
52
|
-
if (options.handEnableIngestion) {
|
|
53
|
-
config.features['codex_conversation_ingestion'].enabled = true;
|
|
54
|
-
}
|
|
55
|
-
// Multi-line YAML dump: the line-targeted editor needs a `features:` line.
|
|
56
|
-
fs.writeFileSync(path.join(ws, '.pd', 'config.yaml'), yaml.dump(config, { indent: 2, lineWidth: 200, noRefs: true }));
|
|
57
|
-
return ws;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/** Snapshot the fixed, allowlisted file set a consent run may touch. */
|
|
61
|
-
function snapshot(root: string): Map<string, string> {
|
|
62
|
-
const files = new Map<string, string>();
|
|
63
|
-
for (const name of FILENAME_ALLOWLIST) {
|
|
64
|
-
const full = pdFile(root, name);
|
|
65
|
-
if (full === null) continue;
|
|
66
|
-
// Read first, no stat-then-read window (CodeQL FS race): ENOENT simply
|
|
67
|
-
// means the file is absent for this snapshot.
|
|
68
|
-
try {
|
|
69
|
-
files.set(full, fs.readFileSync(full, 'utf8'));
|
|
70
|
-
} catch {
|
|
71
|
-
// absent file — snapshot stays empty for it
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return files;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
async function runSetup(options: Record<string, unknown>): Promise<Record<string, unknown>> {
|
|
78
|
-
const { handleCodexSetup } = await import('../../src/commands/codex-setup.js');
|
|
79
|
-
const captured: string[] = [];
|
|
80
|
-
// Install the capture INSIDE the step: defineFeature-created tests may not
|
|
81
|
-
// see file-level console/stdout spies reliably, and the capture must wrap
|
|
82
|
-
// exactly the handler call.
|
|
83
|
-
const logSpy = vi.spyOn(console, 'log').mockImplementation((...args: unknown[]) => {
|
|
84
|
-
captured.push(args.map(String).join(' '));
|
|
85
|
-
});
|
|
86
|
-
const outSpy = vi.spyOn(process.stdout, 'write').mockImplementation(((chunk: unknown) => {
|
|
87
|
-
captured.push(String(chunk));
|
|
88
|
-
return true;
|
|
89
|
-
}) as typeof process.stdout.write);
|
|
90
|
-
try {
|
|
91
|
-
await handleCodexSetup({ ...options, json: options.json === true } as never);
|
|
92
|
-
} finally {
|
|
93
|
-
logSpy.mockRestore();
|
|
94
|
-
outSpy.mockRestore();
|
|
95
|
-
}
|
|
96
|
-
logLines.push(...captured);
|
|
97
|
-
const jsonLine = captured.reverse().find((line) => line.startsWith('{'));
|
|
98
|
-
if (jsonLine === undefined) return {};
|
|
99
|
-
try {
|
|
100
|
-
return JSON.parse(jsonLine) as Record<string, unknown>;
|
|
101
|
-
} catch {
|
|
102
|
-
return {};
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
beforeEach(() => {
|
|
107
|
-
logLines = [];
|
|
108
|
-
vi.spyOn(console, 'log').mockImplementation((...args: unknown[]) => {
|
|
109
|
-
logLines.push(args.map(String).join(' '));
|
|
110
|
-
});
|
|
111
|
-
vi.spyOn(process.stdout, 'write').mockImplementation(((chunk: unknown) => {
|
|
112
|
-
logLines.push(String(chunk));
|
|
113
|
-
return true;
|
|
114
|
-
}) as typeof process.stdout.write);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
afterEach(() => {
|
|
118
|
-
vi.restoreAllMocks();
|
|
119
|
-
process.exitCode = undefined;
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
const registry = createStepRegistry();
|
|
123
|
-
let ws: string;
|
|
124
|
-
let beforeFiles: Map<string, string>;
|
|
125
|
-
|
|
126
|
-
registry.given('an isolated Codex Workspace without a consent record', () => {
|
|
127
|
-
ws = makeWorkspace();
|
|
128
|
-
beforeFiles = snapshot(ws);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
registry.given('an isolated Codex Workspace with the ingestion flag hand-enabled and no consent record', () => {
|
|
132
|
-
ws = makeWorkspace({ handEnableIngestion: true });
|
|
133
|
-
beforeFiles = snapshot(ws);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
registry.when('setup presents the ingestion disclosure', async () => {
|
|
137
|
-
await runSetup({ workspace: ws, showDisclosure: true });
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
registry.then('the frozen Chinese text is shown verbatim with the version of the approved decision package', () => {
|
|
141
|
-
const output = logLines.join('\n');
|
|
142
|
-
expect(output, `captured=${JSON.stringify(logLines).slice(0, 200)}`).toContain('### Principles Disciple — 对话观察与治理闭环(Codex)');
|
|
143
|
-
expect(output).toContain('默认关闭。只有你在看到本说明后明确选择开启才会生效;升级 PD 永远不会替你开启。');
|
|
144
|
-
expect(CODEX_INGESTION_DISCLOSURE_VERSION).toBe('g2a-2026-08-28');
|
|
145
|
-
const read = readCodexIngestionConsent(ws);
|
|
146
|
-
expect(read.ok && read.record).toBeNull();
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
registry.when('the Owner explicitly accepts after the disclosure', async () => {
|
|
150
|
-
// The disclosure was presented first (R1-1 ordering): show, then accept.
|
|
151
|
-
await runSetup({ workspace: ws, showDisclosure: true });
|
|
152
|
-
const report = await runSetup({ workspace: ws, accept: true, json: true });
|
|
153
|
-
expect(report.status, JSON.stringify(report)).toBe('ok');
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
registry.then('the consent record exists with the granted decision and the ingestion flag is enabled', () => {
|
|
157
|
-
const read = readCodexIngestionConsent(ws);
|
|
158
|
-
expect(read.ok && read.record?.decision).toBe('granted');
|
|
159
|
-
if (read.ok && read.record) {
|
|
160
|
-
expect(read.record.disclosureVersion).toBe(CODEX_INGESTION_DISCLOSURE_VERSION);
|
|
161
|
-
expect(read.record.decidedVia).toBe('pd_codex_setup');
|
|
162
|
-
}
|
|
163
|
-
const config = pdFile(ws, 'config.yaml');
|
|
164
|
-
expect(config).not.toBeNull();
|
|
165
|
-
if (config !== null) {
|
|
166
|
-
expect(fs.readFileSync(config, 'utf8')).toContain('enabled: true');
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
registry.then('no config outside the workspace consent flow was modified', () => {
|
|
171
|
-
// The consent flow touches exactly two files: config.yaml and the consent
|
|
172
|
-
// record (the allowlisted snapshot). New files may only be the consent
|
|
173
|
-
// record; every pre-existing file may only be the config.yaml flip.
|
|
174
|
-
const after = snapshot(ws);
|
|
175
|
-
for (const [file, content] of beforeFiles) {
|
|
176
|
-
if (file.endsWith('config.yaml')) continue; // the flag flip is the point
|
|
177
|
-
expect(after.get(file) ?? '', `unexpected change: ${file}`).toBe(content);
|
|
178
|
-
}
|
|
179
|
-
const consentPath = path.join(ws, '.pd', 'codex-ingestion-consent.json');
|
|
180
|
-
expect(after.has(consentPath), 'the consent record must be the only new file').toBe(true);
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
registry.when('the Owner explicitly declines', async () => {
|
|
184
|
-
const report = await runSetup({ workspace: ws, decline: true, json: true });
|
|
185
|
-
expect(report.status).toBe('ok');
|
|
186
|
-
expect(report.decision).toBe('revoked');
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
registry.then('the consent record exists with the declined decision and the ingestion flag is off', () => {
|
|
190
|
-
const read = readCodexIngestionConsent(ws);
|
|
191
|
-
expect(read.ok && read.record?.decision).toBe('revoked');
|
|
192
|
-
const config = pdFile(ws, 'config.yaml');
|
|
193
|
-
expect(config).not.toBeNull();
|
|
194
|
-
if (config !== null) {
|
|
195
|
-
const content = fs.readFileSync(config, 'utf8');
|
|
196
|
-
expect(content).toContain('codex_conversation_ingestion:');
|
|
197
|
-
expect(content).toContain('enabled: false');
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
registry.then('no transcript was opened by the decline', () => {
|
|
202
|
-
// The decline only rewrites the two allowlisted .pd files; the handler has
|
|
203
|
-
// no transcript argument and no Codex-home FS surface. (The CODEX_HOME env
|
|
204
|
-
// assertion was removed in review round 3: it depends on the developer's
|
|
205
|
-
// machine environment, not on the behavior under test.)
|
|
206
|
-
expect(readCodexIngestionConsent(ws).ok && readCodexIngestionConsent(ws).record?.decision).toBe('revoked');
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
registry.when('setup runs in machine mode without an explicit accept or decline', async () => {
|
|
210
|
-
const report = await runSetup({ workspace: ws, json: true });
|
|
211
|
-
expect(report.reason).toBe('decision_required');
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
registry.then('nothing is recorded and nothing is enabled', () => {
|
|
215
|
-
expect(readCodexIngestionConsent(ws).ok && readCodexIngestionConsent(ws).record).toBeNull();
|
|
216
|
-
const after = snapshot(ws);
|
|
217
|
-
for (const [file, content] of beforeFiles) {
|
|
218
|
-
expect(after.get(file) ?? '').toBe(content);
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
// ── §18-15 flag-off reversibility ─────────────────────────────────────────────
|
|
223
|
-
|
|
224
|
-
registry.given('an isolated Codex Workspace with conversation ingestion enabled and evidence recorded', () => {
|
|
225
|
-
ws = makeWorkspace({ handEnableIngestion: true });
|
|
226
|
-
const now = new Date();
|
|
227
|
-
const seeded = ingestGovernanceObservations({
|
|
228
|
-
workspaceDir: ws,
|
|
229
|
-
now,
|
|
230
|
-
observations: [{
|
|
231
|
-
hostKind: 'codex', rolloutIdentity: 'r-evidence', rootSessionId: 'root-evidence',
|
|
232
|
-
hostTurnId: 't1', kind: 'user_turn', logicalObservationKey: 'codex|r-evidence|t1|user',
|
|
233
|
-
source: 'transcript', completeness: 'complete', observedAt: now.toISOString(),
|
|
234
|
-
recordByteStart: 100, recordOrdinal: 1, visibleText: 'owner correction evidence',
|
|
235
|
-
}],
|
|
236
|
-
});
|
|
237
|
-
expect(seeded.ok).toBe(true);
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
registry.when('the ingestion flag is turned off', async () => {
|
|
241
|
-
const report = await runSetup({ workspace: ws, decline: true, json: true });
|
|
242
|
-
expect(report.status).toBe('ok');
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
registry.then('catch-up reports feature_disabled with zero transcript reads', async () => {
|
|
246
|
-
const result = await catchUpCodexIngestion({ workspaceDir: ws });
|
|
247
|
-
expect(result.status).toBe('skipped');
|
|
248
|
-
if (result.status === 'skipped') {
|
|
249
|
-
expect(result.reason).toBe('feature_disabled');
|
|
250
|
-
expect(result.nextAction).toContain('codex_conversation_ingestion');
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
registry.then('previously promoted evidence remains intact', async () => {
|
|
255
|
-
const promotion = promoteGovernanceEvidence({
|
|
256
|
-
workspaceDir: ws, hostKind: 'codex', rolloutIdentity: 'r-evidence',
|
|
257
|
-
triggerLogicalKey: 'codex|r-evidence|t1|user', painRef: 'pain_reversibility_1',
|
|
258
|
-
});
|
|
259
|
-
expect(promotion.ok).toBe(true);
|
|
260
|
-
const listed = listGovernanceObservations({ workspaceDir: ws });
|
|
261
|
-
expect(listed.ok).toBe(true);
|
|
262
|
-
if (!listed.ok) return;
|
|
263
|
-
expect(listed.observations.find((row) => row.logicalKey === 'codex|r-evidence|t1|user')?.retentionClass).toBe('promoted');
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
// ── §18-15 / R1-4: the upgrade path never enables ingestion ──────────────────
|
|
267
|
-
|
|
268
|
-
registry.given('an isolated Codex Workspace where the Owner declined ingestion', async () => {
|
|
269
|
-
ws = makeWorkspace();
|
|
270
|
-
const report = await runSetup({ workspace: ws, decline: true, json: true });
|
|
271
|
-
expect(report.status).toBe('ok');
|
|
272
|
-
expect(report.decision).toBe('revoked');
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
registry.when('the production runtime initializer re-runs over the workspace', async () => {
|
|
276
|
-
// `pd runtime init` is the upgrade/re-init entry over an existing workspace.
|
|
277
|
-
const { handleRuntimeInit } = await import('../../src/commands/runtime-init.js');
|
|
278
|
-
const captured: string[] = [];
|
|
279
|
-
const logSpy = vi.spyOn(console, 'log').mockImplementation((...args: unknown[]) => {
|
|
280
|
-
captured.push(args.map(String).join(' '));
|
|
281
|
-
});
|
|
282
|
-
try {
|
|
283
|
-
await handleRuntimeInit({ workspace: ws, confirm: true, json: true });
|
|
284
|
-
} finally {
|
|
285
|
-
logSpy.mockRestore();
|
|
286
|
-
}
|
|
287
|
-
void captured;
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
registry.then('the ingestion flag is still off and the declined consent record is untouched', () => {
|
|
291
|
-
const read = readCodexIngestionConsent(ws);
|
|
292
|
-
expect(read.ok && read.record?.decision).toBe('revoked');
|
|
293
|
-
const config = fs.readFileSync(path.join(ws, '.pd', 'config.yaml'), 'utf8');
|
|
294
|
-
expect(config).toContain('codex_conversation_ingestion:');
|
|
295
|
-
expect(config).toContain('enabled: false');
|
|
296
|
-
expect(config).not.toMatch(/codex_conversation_ingestion:[\s\S]{0,40}enabled: true/);
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
defineFeature(fs.readFileSync(resolveFeaturePath('docs/specs/features/codex-governance/codex-consent-reversibility.feature'), 'utf8'), registry);
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* pd codex ingest quarantine command tests (Slice D, SPEC §15).
|
|
3
|
-
*
|
|
4
|
-
* Functional, real-filesystem: seeds a workspace trajectory.db through the
|
|
5
|
-
* production store, then exercises the handler. Proven:
|
|
6
|
-
* - dry run is the DEFAULT: --json reports dryRun=true and the record row is
|
|
7
|
-
* untouched;
|
|
8
|
-
* - --confirm quarantines (row becomes terminal, bodies dropped);
|
|
9
|
-
* - missing/invalid flags are refused with reason + nextAction, exit 1, and
|
|
10
|
-
* mutate nothing (cli-5);
|
|
11
|
-
* - --json emits exactly one parseable object (cli-1).
|
|
12
|
-
*/
|
|
13
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
14
|
-
import fs from 'node:fs';
|
|
15
|
-
import os from 'node:os';
|
|
16
|
-
import path from 'node:path';
|
|
17
|
-
import { getDefaultPdConfig } from '@principles/core/runtime-v2';
|
|
18
|
-
import { ingestGovernanceObservations, listGovernanceObservations } from '@principles/host-runtime';
|
|
19
|
-
|
|
20
|
-
let workspaceDir: string;
|
|
21
|
-
let corruptRecordId = 0;
|
|
22
|
-
let logSpy: ReturnType<typeof vi.spyOn>;
|
|
23
|
-
let savedExitCode: number | undefined;
|
|
24
|
-
|
|
25
|
-
beforeEach(() => {
|
|
26
|
-
workspaceDir = fs.mkdtempSync(path.join(os.tmpdir(), 'pd-cli-quarantine-'));
|
|
27
|
-
fs.mkdirSync(path.join(workspaceDir, '.pd'), { recursive: true });
|
|
28
|
-
fs.mkdirSync(path.join(workspaceDir, '.state'), { recursive: true });
|
|
29
|
-
fs.writeFileSync(path.join(workspaceDir, '.state', 'trajectory.db'), '');
|
|
30
|
-
const config = getDefaultPdConfig();
|
|
31
|
-
config.features['host.codex'].enabled = true;
|
|
32
|
-
config.features.codex_conversation_ingestion.enabled = true;
|
|
33
|
-
fs.writeFileSync(path.join(workspaceDir, '.pd', 'config.yaml'), JSON.stringify(config));
|
|
34
|
-
const now = new Date('2026-08-29T12:00:00.000Z');
|
|
35
|
-
const seeded = ingestGovernanceObservations({
|
|
36
|
-
workspaceDir,
|
|
37
|
-
now,
|
|
38
|
-
observations: [
|
|
39
|
-
{ hostKind: 'codex', rolloutIdentity: 'rollout-uuid-1', rootSessionId: 'root-1', hostTurnId: 't1', kind: 'user_turn', logicalObservationKey: 'codex|rollout-uuid-1|t1|user', source: 'transcript', completeness: 'complete', observedAt: now.toISOString(), recordByteStart: 100, recordOrdinal: 1, visibleText: 'first' },
|
|
40
|
-
{ hostKind: 'codex', rolloutIdentity: 'rollout-uuid-1', rootSessionId: 'root-1', hostTurnId: 't2', kind: 'user_turn', logicalObservationKey: 'codex|rollout-uuid-1|t2|user', source: 'transcript', completeness: 'partial', observedAt: now.toISOString(), recordByteStart: 300, recordOrdinal: 3, visibleText: 'corrupt record' },
|
|
41
|
-
],
|
|
42
|
-
});
|
|
43
|
-
expect(seeded.ok, JSON.stringify(seeded)).toBe(true);
|
|
44
|
-
const listed = listGovernanceObservations({ workspaceDir });
|
|
45
|
-
expect(listed.ok).toBe(true);
|
|
46
|
-
if (!listed.ok) throw new Error('unreachable');
|
|
47
|
-
const corrupt = listed.observations.find((row) => row.logicalKey === 'codex|rollout-uuid-1|t2|user');
|
|
48
|
-
expect(corrupt).toBeDefined();
|
|
49
|
-
corruptRecordId = corrupt.id;
|
|
50
|
-
|
|
51
|
-
savedExitCode = process.exitCode;
|
|
52
|
-
process.exitCode = undefined;
|
|
53
|
-
logSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
afterEach(() => {
|
|
57
|
-
logSpy.mockRestore();
|
|
58
|
-
process.exitCode = savedExitCode;
|
|
59
|
-
fs.rmSync(workspaceDir, { recursive: true, force: true });
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
function findRecord(): { retentionClass: string; visibleText: string | null } {
|
|
63
|
-
const listed = listGovernanceObservations({ workspaceDir });
|
|
64
|
-
if (!listed.ok) throw new Error('list failed');
|
|
65
|
-
const row = listed.observations.find((entry) => entry.id === corruptRecordId);
|
|
66
|
-
if (!row) throw new Error('record vanished');
|
|
67
|
-
return row;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
async function run(options: Record<string, unknown>): Promise<Record<string, unknown>> {
|
|
71
|
-
const { handleCodexIngestQuarantine } = await import('../../src/commands/codex-ingest-quarantine.js');
|
|
72
|
-
const callsBefore = logSpy.mock.calls.length;
|
|
73
|
-
await handleCodexIngestQuarantine({ workspace: workspaceDir, ...options } as never);
|
|
74
|
-
const newOutput = logSpy.mock.calls.slice(callsBefore).map((call) => String(call[0]));
|
|
75
|
-
const jsonLine = newOutput.reverse().find((line) => line.startsWith('{'));
|
|
76
|
-
expect(jsonLine, 'handler must emit exactly one JSON object for --json').toBeDefined();
|
|
77
|
-
return JSON.parse(jsonLine as string) as Record<string, unknown>;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
describe('pd codex ingest quarantine (functional)', () => {
|
|
81
|
-
it('dry run is the default: reports digest/gap, mutates nothing, exits 0', { timeout: 20_000 }, async () => {
|
|
82
|
-
const report = await run({ rollout: 'rollout-uuid-1', record: String(corruptRecordId), reason: 'stable-invalid', json: true });
|
|
83
|
-
expect(report.status).toBe('ok');
|
|
84
|
-
expect(report.dryRun).toBe(true);
|
|
85
|
-
expect(report.confirmed).toBe(false);
|
|
86
|
-
expect(report.transcriptTouched).toBe(false);
|
|
87
|
-
const record = report.record as { digest: string; gap: string; id: number };
|
|
88
|
-
expect(record.id).toBe(corruptRecordId);
|
|
89
|
-
expect(record.digest).toMatch(/^[0-9a-f]{64}$/);
|
|
90
|
-
expect(record.gap).toContain('prev=');
|
|
91
|
-
expect(findRecord().retentionClass).toBe('operational');
|
|
92
|
-
expect(process.exitCode ?? 0).toBe(0);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('--confirm quarantines the record; a repeat is idempotent', { timeout: 20_000 }, async () => {
|
|
96
|
-
const report = await run({ rollout: 'rollout-uuid-1', record: String(corruptRecordId), reason: 'stable-invalid', operator: 'tester', confirm: true, json: true });
|
|
97
|
-
expect(report.dryRun).toBe(false);
|
|
98
|
-
expect(report.alreadyQuarantined).toBe(false);
|
|
99
|
-
expect(findRecord().retentionClass).toBe('quarantined');
|
|
100
|
-
expect(findRecord().visibleText).toBeNull();
|
|
101
|
-
|
|
102
|
-
const repeat = await run({ rollout: 'rollout-uuid-1', record: String(corruptRecordId), reason: 'stable-invalid', confirm: true, json: true });
|
|
103
|
-
expect(repeat.alreadyQuarantined).toBe(true);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('refuses invalid arguments with reason+nextAction and no mutation (cli-5/cli-6)', { timeout: 30_000 }, async () => {
|
|
107
|
-
// Case table is built INSIDE the test so record ids reference the row
|
|
108
|
-
// seeded in beforeEach (an it.each table would evaluate before seeding).
|
|
109
|
-
const cases: [Record<string, unknown>, string][] = [
|
|
110
|
-
[{ reason: 'x' }, 'rollout_required'],
|
|
111
|
-
[{ rollout: 'rollout-uuid-1', reason: 'x' }, 'record_required'],
|
|
112
|
-
[{ rollout: 'rollout-uuid-1', record: 'abc' }, 'record_required'],
|
|
113
|
-
[{ rollout: 'rollout-uuid-1', record: String(corruptRecordId) }, 'reason_required'],
|
|
114
|
-
[{ rollout: 'unknown-rollout', record: String(corruptRecordId), reason: 'x' }, 'rollout_not_found'],
|
|
115
|
-
];
|
|
116
|
-
for (const [options, expectedReason] of cases) {
|
|
117
|
-
process.exitCode = undefined;
|
|
118
|
-
const report = await run({ ...options, json: true });
|
|
119
|
-
expect(report.status, JSON.stringify({ options, report })).toBe('refused');
|
|
120
|
-
expect(report.reason).toBe(expectedReason);
|
|
121
|
-
expect(String(report.nextAction).length).toBeGreaterThan(0);
|
|
122
|
-
expect(process.exitCode).toBe(1);
|
|
123
|
-
expect(findRecord().retentionClass, String(expectedReason)).toBe('operational');
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it('text output includes the dry-run next action', { timeout: 20_000 }, async () => {
|
|
128
|
-
const { handleCodexIngestQuarantine } = await import('../../src/commands/codex-ingest-quarantine.js');
|
|
129
|
-
await handleCodexIngestQuarantine({ workspace: workspaceDir, rollout: 'rollout-uuid-1', record: String(corruptRecordId), reason: 'stable-invalid' });
|
|
130
|
-
const output = logSpy.mock.calls.map((call) => String(call[0])).join('\n');
|
|
131
|
-
expect(output).toContain('dry-run');
|
|
132
|
-
expect(output).toContain('digest:');
|
|
133
|
-
expect(output).toContain('--confirm');
|
|
134
|
-
expect(process.exitCode ?? 0).toBe(0);
|
|
135
|
-
});
|
|
136
|
-
});
|