@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,462 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import { RuntimeStateManager } from '@principles/core/runtime-v2';
|
|
4
|
-
import { SqliteContextAssembler } from '@principles/core/runtime-v2';
|
|
5
|
-
import { SqliteHistoryQuery } from '@principles/core/runtime-v2';
|
|
6
|
-
import { StoreEventEmitter } from '@principles/core/runtime-v2';
|
|
7
|
-
import {
|
|
8
|
-
SplitDiagnosticianRunner,
|
|
9
|
-
DiagRootCauseRunner,
|
|
10
|
-
DiagDistillerRunner,
|
|
11
|
-
DiagRouterRunner,
|
|
12
|
-
DefaultDiagRootCauseValidator,
|
|
13
|
-
DefaultDiagDistillerValidator,
|
|
14
|
-
} from '@principles/core/runtime-v2';
|
|
15
|
-
import { SqliteDiagnosticianCommitter } from '@principles/core/runtime-v2';
|
|
16
|
-
import { TestDoubleRuntimeAdapter } from '@principles/core/runtime-v2';
|
|
17
|
-
import { PainSignalBridge } from '@principles/core/runtime-v2';
|
|
18
|
-
import { CandidateIntakeService } from '@principles/core/runtime-v2';
|
|
19
|
-
import { PrincipleTreeLedgerAdapter } from '@principles/core/runtime-v2';
|
|
20
|
-
import { makeDeterministicDiagnosticianOutput } from '@principles/core/runtime-v2';
|
|
21
|
-
import type {
|
|
22
|
-
PainFloodSimulationSummary,
|
|
23
|
-
PainFloodStage,
|
|
24
|
-
PainFloodScenarioName,
|
|
25
|
-
} from '@principles/core/runtime-v2';
|
|
26
|
-
import {
|
|
27
|
-
computeFloodStatus,
|
|
28
|
-
computeFloodTotals,
|
|
29
|
-
recommendFloodNextIssue,
|
|
30
|
-
boundedFloodEvidence,
|
|
31
|
-
maxEvidencePreviewLength,
|
|
32
|
-
formatContextBudgetSummary,
|
|
33
|
-
truncateReason,
|
|
34
|
-
FLOOD_SCENARIO_EXPECTATIONS,
|
|
35
|
-
computeMaxAllowedTasks,
|
|
36
|
-
} from '@principles/core/runtime-v2';
|
|
37
|
-
|
|
38
|
-
export interface PainFloodSimulationRunnerOptions {
|
|
39
|
-
workspaceDir: string;
|
|
40
|
-
workspaceMode: 'temp' | 'explicit_workspace';
|
|
41
|
-
identicalCount?: number;
|
|
42
|
-
similarCount?: number;
|
|
43
|
-
stressCount?: number;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function generatePainId(prefix: string, index: number): string {
|
|
47
|
-
return `flood-${prefix}-${index}`;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function generateSimilarReason(index: number): string {
|
|
51
|
-
return `Flood simulation pain signal #${index}: deterministic test message with small variation.`;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
type PainSignalInput = { painId: string; painType: 'tool_failure' | 'subagent_error'; reason: string };
|
|
55
|
-
|
|
56
|
-
interface RunScenarioOptions {
|
|
57
|
-
stateManager: RuntimeStateManager;
|
|
58
|
-
bridge: PainSignalBridge;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async function runScenario(
|
|
62
|
-
deps: RunScenarioOptions,
|
|
63
|
-
scenarioName: PainFloodScenarioName,
|
|
64
|
-
painSignals: PainSignalInput[],
|
|
65
|
-
): Promise<PainFloodStage> {
|
|
66
|
-
const { stateManager, bridge } = deps;
|
|
67
|
-
const errors: string[] = [];
|
|
68
|
-
let skippedDuplicateCount = 0;
|
|
69
|
-
let failedSignalCount = 0;
|
|
70
|
-
const seenTaskIds = new Set<string>();
|
|
71
|
-
|
|
72
|
-
const tasksBefore = await stateManager.listTasks();
|
|
73
|
-
let candidatesBefore = 0;
|
|
74
|
-
for (const task of tasksBefore) {
|
|
75
|
-
const candidates = await stateManager.getCandidatesByTaskId(task.taskId);
|
|
76
|
-
candidatesBefore += candidates.length;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
for (const signal of painSignals) {
|
|
80
|
-
try {
|
|
81
|
-
const result = await bridge.onPainDetected({
|
|
82
|
-
painId: signal.painId,
|
|
83
|
-
painType: signal.painType,
|
|
84
|
-
source: 'pain-flood-simulation',
|
|
85
|
-
reason: signal.reason,
|
|
86
|
-
// Synthetic flood is a deterministic dedup/stress tool — it has no real
|
|
87
|
-
// host session. Provide synthetic evidence so the PEAT-B1 admission gate
|
|
88
|
-
// (default-on) does not short-circuit every signal before diagnosis,
|
|
89
|
-
// which would mask the dedup behaviour this tool exists to verify.
|
|
90
|
-
evidence: [{ sourceRef: `synthetic-flood:${signal.painId}`, note: 'Synthetic flood deterministic evidence anchor' }],
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
if (result.status === 'failed' || result.status === 'retried') {
|
|
94
|
-
failedSignalCount++;
|
|
95
|
-
errors.push(`${signal.painId}: bridge returned ${result.status} — ${result.message ?? 'no message'}`);
|
|
96
|
-
} else if (result.status === 'skipped') {
|
|
97
|
-
skippedDuplicateCount++;
|
|
98
|
-
} else if (result.status === 'succeeded') {
|
|
99
|
-
if (seenTaskIds.has(result.taskId)) {
|
|
100
|
-
skippedDuplicateCount++;
|
|
101
|
-
} else {
|
|
102
|
-
seenTaskIds.add(result.taskId);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
} catch (err) {
|
|
106
|
-
failedSignalCount++;
|
|
107
|
-
errors.push(`${signal.painId}: threw — ${err instanceof Error ? err.message : String(err)}`);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const tasksAfter = await stateManager.listTasks();
|
|
112
|
-
let candidatesAfter = 0;
|
|
113
|
-
for (const task of tasksAfter) {
|
|
114
|
-
const candidates = await stateManager.getCandidatesByTaskId(task.taskId);
|
|
115
|
-
candidatesAfter += candidates.length;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const deltaTasks = tasksAfter.length - tasksBefore.length;
|
|
119
|
-
const deltaCandidates = candidatesAfter - candidatesBefore;
|
|
120
|
-
|
|
121
|
-
const expectation = FLOOD_SCENARIO_EXPECTATIONS[scenarioName];
|
|
122
|
-
const maxAllowedTasks = computeMaxAllowedTasks(painSignals, expectation);
|
|
123
|
-
const dedupeViolation = deltaTasks > maxAllowedTasks;
|
|
124
|
-
|
|
125
|
-
const passed = errors.length === 0 && !dedupeViolation;
|
|
126
|
-
|
|
127
|
-
const stage: PainFloodStage = {
|
|
128
|
-
scenarioName,
|
|
129
|
-
status: passed ? 'passed' : 'failed',
|
|
130
|
-
inputCount: painSignals.length,
|
|
131
|
-
acceptedCount: deltaTasks,
|
|
132
|
-
skippedCount: skippedDuplicateCount,
|
|
133
|
-
failedCount: failedSignalCount,
|
|
134
|
-
taskCount: deltaTasks,
|
|
135
|
-
candidateCount: deltaCandidates,
|
|
136
|
-
evidence: boundedFloodEvidence({
|
|
137
|
-
inputCount: painSignals.length,
|
|
138
|
-
acceptedCount: deltaTasks,
|
|
139
|
-
skippedCount: skippedDuplicateCount,
|
|
140
|
-
failedCount: failedSignalCount,
|
|
141
|
-
uniqueTaskIds: seenTaskIds.size,
|
|
142
|
-
deltaTasks,
|
|
143
|
-
deltaCandidates,
|
|
144
|
-
errorCount: errors.length,
|
|
145
|
-
}),
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
if (errors.length > 0) {
|
|
149
|
-
stage.reason = truncateReason(`Scenario ${scenarioName}: ${errors.length} errors. First: ${errors[0]}`);
|
|
150
|
-
} else if (dedupeViolation) {
|
|
151
|
-
stage.reason = truncateReason(`Scenario ${scenarioName}: dedupe violation — created ${deltaTasks} tasks, expected at most ${maxAllowedTasks} (${expectation.description})`);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
return stage;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export async function runPainFloodSimulation(opts: PainFloodSimulationRunnerOptions): Promise<PainFloodSimulationSummary> {
|
|
158
|
-
const { workspaceDir, workspaceMode } = opts;
|
|
159
|
-
const identicalCount = opts.identicalCount ?? 10;
|
|
160
|
-
const similarCount = opts.similarCount ?? 10;
|
|
161
|
-
const stressCount = opts.stressCount ?? 50;
|
|
162
|
-
|
|
163
|
-
const stages: PainFloodStage[] = [];
|
|
164
|
-
const generatedAt = new Date().toISOString();
|
|
165
|
-
|
|
166
|
-
const pdDir = path.join(workspaceDir, '.pd');
|
|
167
|
-
const stateDir = path.join(workspaceDir, '.state');
|
|
168
|
-
|
|
169
|
-
let stateManager: RuntimeStateManager | undefined = undefined;
|
|
170
|
-
|
|
171
|
-
try {
|
|
172
|
-
await fs.promises.mkdir(pdDir, { recursive: true });
|
|
173
|
-
await fs.promises.mkdir(stateDir, { recursive: true });
|
|
174
|
-
|
|
175
|
-
stateManager = new RuntimeStateManager({ workspaceDir });
|
|
176
|
-
await stateManager.initialize();
|
|
177
|
-
|
|
178
|
-
// Create shared infrastructure
|
|
179
|
-
const { connection: sqliteConn, taskStore, runStore } = stateManager;
|
|
180
|
-
const historyQuery = new SqliteHistoryQuery(sqliteConn);
|
|
181
|
-
const contextAssembler = new SqliteContextAssembler(taskStore, historyQuery, runStore);
|
|
182
|
-
const eventEmitter = new StoreEventEmitter();
|
|
183
|
-
const committer = new SqliteDiagnosticianCommitter(sqliteConn);
|
|
184
|
-
const runIdToTaskId = new Map<string, string>();
|
|
185
|
-
let runCounter = 0;
|
|
186
|
-
|
|
187
|
-
// Single test-double adapter handles all pains with stage-aware output
|
|
188
|
-
const runtimeAdapter = new TestDoubleRuntimeAdapter({
|
|
189
|
-
onStartRun: (input) => {
|
|
190
|
-
runCounter += 1;
|
|
191
|
-
const runId = `td-${runCounter}`;
|
|
192
|
-
const taskId = input.taskRef?.taskId ?? '';
|
|
193
|
-
runIdToTaskId.set(runId, taskId);
|
|
194
|
-
return {
|
|
195
|
-
runId,
|
|
196
|
-
runtimeKind: 'test-double',
|
|
197
|
-
startedAt: new Date().toISOString(),
|
|
198
|
-
};
|
|
199
|
-
},
|
|
200
|
-
onFetchOutput: async (runId: string) => {
|
|
201
|
-
const taskId = runIdToTaskId.get(runId) ?? '';
|
|
202
|
-
if (taskId.includes('diag_rootcause')) {
|
|
203
|
-
return {
|
|
204
|
-
runId,
|
|
205
|
-
payload: {
|
|
206
|
-
valid: true,
|
|
207
|
-
diagnosisId: `diag-${runId}`,
|
|
208
|
-
taskId,
|
|
209
|
-
summary: 'Mock rootcause summary for pain-flood-simulation',
|
|
210
|
-
causalChain: [{ why: 1, statement: 'why', evidenceRefs: ['ref-1'] }],
|
|
211
|
-
rootCause: 'Design: Mock rootcause',
|
|
212
|
-
rootCauseCategory: 'Design',
|
|
213
|
-
evidence: [{ sourceRef: 'ref-1', note: 'note' }],
|
|
214
|
-
confidence: 0.9,
|
|
215
|
-
},
|
|
216
|
-
};
|
|
217
|
-
} else if (taskId.includes('diag_distiller')) {
|
|
218
|
-
const parentTaskId = taskId.replace('diag_distiller-', '');
|
|
219
|
-
const stageATaskId = `diag_rootcause-${parentTaskId}`;
|
|
220
|
-
const artifacts = stateManager
|
|
221
|
-
? await stateManager.piArtifactStore.listBySourceTaskId(stageATaskId)
|
|
222
|
-
: [];
|
|
223
|
-
const sourceRootCauseArtifactId = artifacts[0]?.artifactId ?? 'art-rc';
|
|
224
|
-
return {
|
|
225
|
-
runId,
|
|
226
|
-
payload: {
|
|
227
|
-
valid: true,
|
|
228
|
-
taskId,
|
|
229
|
-
sourceRootCauseArtifactId,
|
|
230
|
-
abstractedPrinciple: 'Mock abstracted principle',
|
|
231
|
-
rationale: 'Mock rationale',
|
|
232
|
-
groundedOnCorePrincipleIds: ['T-01'],
|
|
233
|
-
scope: 'domain',
|
|
234
|
-
confidence: 0.9,
|
|
235
|
-
},
|
|
236
|
-
};
|
|
237
|
-
} else {
|
|
238
|
-
return {
|
|
239
|
-
runId,
|
|
240
|
-
payload: makeDeterministicDiagnosticianOutput(runId),
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
},
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
const rootCauseRunner = new DiagRootCauseRunner(
|
|
247
|
-
{
|
|
248
|
-
stateManager,
|
|
249
|
-
runtimeAdapter,
|
|
250
|
-
eventEmitter,
|
|
251
|
-
artifactStore: stateManager.piArtifactStore,
|
|
252
|
-
validator: new DefaultDiagRootCauseValidator(),
|
|
253
|
-
contextAssembler,
|
|
254
|
-
},
|
|
255
|
-
{
|
|
256
|
-
owner: 'pain-flood-simulation',
|
|
257
|
-
runtimeKind: 'test-double',
|
|
258
|
-
pollIntervalMs: 50,
|
|
259
|
-
timeoutMs: 10000,
|
|
260
|
-
},
|
|
261
|
-
);
|
|
262
|
-
|
|
263
|
-
const distillerRunner = new DiagDistillerRunner(
|
|
264
|
-
{
|
|
265
|
-
stateManager,
|
|
266
|
-
runtimeAdapter,
|
|
267
|
-
eventEmitter,
|
|
268
|
-
artifactStore: stateManager.piArtifactStore,
|
|
269
|
-
validator: new DefaultDiagDistillerValidator(),
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
owner: 'pain-flood-simulation',
|
|
273
|
-
runtimeKind: 'test-double',
|
|
274
|
-
pollIntervalMs: 50,
|
|
275
|
-
timeoutMs: 10000,
|
|
276
|
-
},
|
|
277
|
-
);
|
|
278
|
-
|
|
279
|
-
const routerRunner = new DiagRouterRunner(
|
|
280
|
-
{
|
|
281
|
-
stateManager,
|
|
282
|
-
runtimeAdapter,
|
|
283
|
-
eventEmitter,
|
|
284
|
-
artifactStore: stateManager.piArtifactStore,
|
|
285
|
-
committer,
|
|
286
|
-
},
|
|
287
|
-
{
|
|
288
|
-
owner: 'pain-flood-simulation',
|
|
289
|
-
runtimeKind: 'test-double',
|
|
290
|
-
pollIntervalMs: 50,
|
|
291
|
-
timeoutMs: 10000,
|
|
292
|
-
},
|
|
293
|
-
);
|
|
294
|
-
|
|
295
|
-
const runner = new SplitDiagnosticianRunner({
|
|
296
|
-
rootCauseRunner,
|
|
297
|
-
distillerRunner,
|
|
298
|
-
routerRunner,
|
|
299
|
-
stateManager,
|
|
300
|
-
committer,
|
|
301
|
-
perStageTimeoutMs: 10000,
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
const ledgerAdapter = new PrincipleTreeLedgerAdapter({ stateDir });
|
|
305
|
-
const intakeService = new CandidateIntakeService({ stateManager, ledgerAdapter });
|
|
306
|
-
|
|
307
|
-
const bridge = new PainSignalBridge({
|
|
308
|
-
stateManager,
|
|
309
|
-
runner,
|
|
310
|
-
intakeService,
|
|
311
|
-
ledgerAdapter,
|
|
312
|
-
autoIntakeEnabled: true,
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
// ── Scenario 1: Identical flood ──────────────────────────────────────────────
|
|
316
|
-
const identicalPainId = 'flood-identical-shared';
|
|
317
|
-
const identicalSignals = Array.from({ length: identicalCount }, () => ({
|
|
318
|
-
painId: identicalPainId,
|
|
319
|
-
painType: 'tool_failure' as const,
|
|
320
|
-
reason: 'Identical pain flood: repeated tool failure signal',
|
|
321
|
-
}));
|
|
322
|
-
stages.push(await runScenario({ stateManager, bridge }, 'identical_flood', identicalSignals));
|
|
323
|
-
|
|
324
|
-
// ── Scenario 2: Similar flood ────────────────────────────────────────────────
|
|
325
|
-
const similarSignals = Array.from({ length: similarCount }, (_, i) => ({
|
|
326
|
-
painId: generatePainId('similar', i),
|
|
327
|
-
painType: 'tool_failure' as const,
|
|
328
|
-
reason: generateSimilarReason(i),
|
|
329
|
-
}));
|
|
330
|
-
stages.push(await runScenario({ stateManager, bridge }, 'similar_flood', similarSignals));
|
|
331
|
-
|
|
332
|
-
// ── Scenario 3: Duplicate submission ─────────────────────────────────────────
|
|
333
|
-
const dupPainId = 'flood-dup-test';
|
|
334
|
-
const dupSignals = [
|
|
335
|
-
{ painId: dupPainId, painType: 'tool_failure' as const, reason: 'Duplicate submission: first' },
|
|
336
|
-
{ painId: dupPainId, painType: 'tool_failure' as const, reason: 'Duplicate submission: repeat' },
|
|
337
|
-
];
|
|
338
|
-
stages.push(await runScenario({ stateManager, bridge }, 'duplicate_submission', dupSignals));
|
|
339
|
-
|
|
340
|
-
// ── Scenario 4: Tool failure flood ───────────────────────────────────────────
|
|
341
|
-
const toolFailPainId = 'flood-tool-failure-shared';
|
|
342
|
-
const toolFailSignals = Array.from({ length: 5 }, (_, i) => ({
|
|
343
|
-
painId: toolFailPainId,
|
|
344
|
-
painType: 'tool_failure' as const,
|
|
345
|
-
reason: `Tool failure flood #${i}: EACCES error on file write`,
|
|
346
|
-
}));
|
|
347
|
-
stages.push(await runScenario({ stateManager, bridge }, 'tool_failure_flood', toolFailSignals));
|
|
348
|
-
|
|
349
|
-
// ── Scenario 5: Stress test ──────────────────────────────────────────────────
|
|
350
|
-
const stressSignals: PainSignalInput[] = [];
|
|
351
|
-
// 60% unique, 40% duplicates using shared painIds
|
|
352
|
-
const stressUniqueCount = Math.floor(stressCount * 0.6);
|
|
353
|
-
const stressDupCount = stressCount - stressUniqueCount;
|
|
354
|
-
|
|
355
|
-
for (let i = 0; i < stressUniqueCount; i++) {
|
|
356
|
-
stressSignals.push({
|
|
357
|
-
painId: generatePainId('stress-unique', i),
|
|
358
|
-
painType: i % 3 === 0 ? 'subagent_error' : 'tool_failure',
|
|
359
|
-
reason: `Stress test unique pain #${i}`,
|
|
360
|
-
});
|
|
361
|
-
}
|
|
362
|
-
// Add duplicate batches using shared painIds
|
|
363
|
-
const sharedIds = ['flood-stress-shared-A', 'flood-stress-shared-B', 'flood-stress-shared-C'];
|
|
364
|
-
for (let i = 0; i < stressDupCount; i++) {
|
|
365
|
-
const sharedId = sharedIds[i % sharedIds.length];
|
|
366
|
-
if (!sharedId) {
|
|
367
|
-
throw new Error('sharedIds array is empty; cannot generate duplicate pain ID');
|
|
368
|
-
}
|
|
369
|
-
stressSignals.push({
|
|
370
|
-
painId: sharedId,
|
|
371
|
-
painType: 'tool_failure',
|
|
372
|
-
reason: `Stress test duplicate batch ${i}`,
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
stages.push(await runScenario({ stateManager, bridge }, 'stress_test', stressSignals));
|
|
377
|
-
|
|
378
|
-
// ── Build summary ────────────────────────────────────────────────────────────
|
|
379
|
-
const totals = computeFloodTotals(stages);
|
|
380
|
-
const maxPreview = maxEvidencePreviewLength(stages);
|
|
381
|
-
const status = computeFloodStatus(stages);
|
|
382
|
-
const recommendedNextIssue = recommendFloodNextIssue(stages);
|
|
383
|
-
|
|
384
|
-
const failedStages = stages.filter(s => s.status === 'failed');
|
|
385
|
-
const [firstFailedStage] = failedStages;
|
|
386
|
-
const reason = failedStages.length > 0 && firstFailedStage
|
|
387
|
-
? truncateReason(`${failedStages.length} scenario(s) failed: ${failedStages.map(s => s.scenarioName).join(', ')}. ${firstFailedStage.reason ?? 'unknown reason'}`)
|
|
388
|
-
: undefined;
|
|
389
|
-
const nextAction = recommendedNextIssue
|
|
390
|
-
? `Investigate: ${recommendedNextIssue}`
|
|
391
|
-
: undefined;
|
|
392
|
-
|
|
393
|
-
return {
|
|
394
|
-
status,
|
|
395
|
-
workspaceMode,
|
|
396
|
-
generatedAt,
|
|
397
|
-
inputPainCount: totals.inputPainCount,
|
|
398
|
-
acceptedPainCount: totals.acceptedPainCount,
|
|
399
|
-
skippedDuplicateCount: totals.skippedDuplicateCount,
|
|
400
|
-
failedCount: totals.failedCount,
|
|
401
|
-
candidateCount: totals.candidateCount,
|
|
402
|
-
taskCount: totals.taskCount,
|
|
403
|
-
maxEvidencePreviewLength: maxPreview,
|
|
404
|
-
contextBudgetSummary: formatContextBudgetSummary(maxPreview),
|
|
405
|
-
stages,
|
|
406
|
-
reason,
|
|
407
|
-
nextAction,
|
|
408
|
-
recommendedNextIssue,
|
|
409
|
-
};
|
|
410
|
-
} catch (err) {
|
|
411
|
-
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
412
|
-
const scenarioNames: PainFloodScenarioName[] = [
|
|
413
|
-
'identical_flood',
|
|
414
|
-
'similar_flood',
|
|
415
|
-
'duplicate_submission',
|
|
416
|
-
'tool_failure_flood',
|
|
417
|
-
'stress_test',
|
|
418
|
-
];
|
|
419
|
-
const existingNames = new Set(stages.map(s => s.scenarioName));
|
|
420
|
-
for (const name of scenarioNames) {
|
|
421
|
-
if (!existingNames.has(name)) {
|
|
422
|
-
stages.push({
|
|
423
|
-
scenarioName: name,
|
|
424
|
-
status: 'failed',
|
|
425
|
-
inputCount: 0,
|
|
426
|
-
acceptedCount: 0,
|
|
427
|
-
skippedCount: 0,
|
|
428
|
-
failedCount: 0,
|
|
429
|
-
taskCount: 0,
|
|
430
|
-
candidateCount: 0,
|
|
431
|
-
reason: truncateReason(`Unexpected error: ${errorMessage}`),
|
|
432
|
-
});
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
const partialTotals = computeFloodTotals(stages);
|
|
437
|
-
const partialMaxPreview = maxEvidencePreviewLength(stages);
|
|
438
|
-
const recommendedNextIssue = recommendFloodNextIssue(stages);
|
|
439
|
-
|
|
440
|
-
return {
|
|
441
|
-
status: 'error',
|
|
442
|
-
workspaceMode,
|
|
443
|
-
generatedAt,
|
|
444
|
-
inputPainCount: partialTotals.inputPainCount,
|
|
445
|
-
acceptedPainCount: partialTotals.acceptedPainCount,
|
|
446
|
-
skippedDuplicateCount: partialTotals.skippedDuplicateCount,
|
|
447
|
-
failedCount: partialTotals.failedCount,
|
|
448
|
-
candidateCount: partialTotals.candidateCount,
|
|
449
|
-
taskCount: partialTotals.taskCount,
|
|
450
|
-
maxEvidencePreviewLength: partialMaxPreview,
|
|
451
|
-
contextBudgetSummary: formatContextBudgetSummary(partialMaxPreview),
|
|
452
|
-
stages,
|
|
453
|
-
reason: truncateReason(`Simulation error: ${errorMessage}`),
|
|
454
|
-
nextAction: 'Check workspace permissions and disk space, then re-run',
|
|
455
|
-
recommendedNextIssue,
|
|
456
|
-
};
|
|
457
|
-
} finally {
|
|
458
|
-
if (stateManager) {
|
|
459
|
-
await stateManager.close();
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
}
|