create-principles-disciple 1.152.5 → 1.153.1
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/_release/product-identity.json +1 -1
- package/agent-skill/pd-setup/SKILL.md +70 -0
- package/codex-adapter/dist/background-selection.d.ts +9 -0
- package/codex-adapter/dist/background-selection.js +142 -0
- package/codex-adapter/dist/ingestion/adaptive-append-state.d.ts +209 -0
- package/codex-adapter/dist/ingestion/adaptive-append-state.js +544 -0
- package/codex-adapter/dist/pd-hook.js +329 -5
- package/codex-adapter/package.json +1 -1
- package/console/dist/server/config/pd-config-store.d.ts +11 -15
- package/console/dist/server/config/pd-config-store.js +92 -17
- package/console/dist/server/models/ActivationsConsoleModel.d.ts +8 -0
- package/console/dist/server/models/ActivationsConsoleModel.js +3 -2
- package/console/dist/server/models/AdaptiveActivationConsoleModel.d.ts +43 -4
- package/console/dist/server/models/AdaptiveActivationConsoleModel.js +36 -7
- package/console/dist/server/models/ExaminerEvidenceModel.d.ts +6 -2
- package/console/dist/server/models/ExaminerEvidenceModel.js +13 -2
- package/console/dist/server/routes/config.js +34 -8
- package/console/dist/server/routes/examiner-executor.d.ts +33 -0
- package/console/dist/server/routes/examiner-executor.js +95 -0
- package/console/dist/server/routes/examiner.js +12 -9
- package/console/dist/web/assets/app.css +14 -10
- package/console/dist/web/assets/app.js +27 -27
- package/core/dist/ledger-file-lock.d.ts +38 -0
- package/core/dist/ledger-file-lock.d.ts.map +1 -0
- package/core/dist/ledger-file-lock.js +240 -0
- package/core/dist/ledger-file-lock.js.map +1 -0
- package/core/dist/principle-text-normalization.d.ts +32 -0
- package/core/dist/principle-text-normalization.d.ts.map +1 -0
- package/core/dist/principle-text-normalization.js +34 -0
- package/core/dist/principle-text-normalization.js.map +1 -0
- package/core/dist/principle-tree-ledger.d.ts +22 -21
- package/core/dist/principle-tree-ledger.d.ts.map +1 -1
- package/core/dist/principle-tree-ledger.js +77 -204
- package/core/dist/principle-tree-ledger.js.map +1 -1
- package/core/dist/runtime/activation/sqlite-approval-store.d.ts.map +1 -1
- package/core/dist/runtime/activation/sqlite-approval-store.js +7 -1
- package/core/dist/runtime/activation/sqlite-approval-store.js.map +1 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts +13 -0
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.js +90 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.js.map +1 -1
- package/core/dist/runtime/adapter/schema-prompt-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/schema-prompt-adapter.js +21 -30
- package/core/dist/runtime/adapter/schema-prompt-adapter.js.map +1 -1
- package/core/dist/runtime/candidate-intake-service.d.ts +40 -1
- package/core/dist/runtime/candidate-intake-service.d.ts.map +1 -1
- package/core/dist/runtime/candidate-intake-service.js +548 -110
- package/core/dist/runtime/candidate-intake-service.js.map +1 -1
- package/core/dist/runtime/candidate-intake.d.ts +59 -2
- package/core/dist/runtime/candidate-intake.d.ts.map +1 -1
- package/core/dist/runtime/candidate-intake.js +23 -0
- package/core/dist/runtime/candidate-intake.js.map +1 -1
- package/core/dist/runtime/candidate-seed-suppression.d.ts +63 -0
- package/core/dist/runtime/candidate-seed-suppression.d.ts.map +1 -0
- package/core/dist/runtime/candidate-seed-suppression.js +29 -0
- package/core/dist/runtime/candidate-seed-suppression.js.map +1 -0
- package/core/dist/runtime/config/pd-config-agent-binding.d.ts +5 -5
- package/core/dist/runtime/config/pd-config-agent-binding.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-agent-binding.js +22 -16
- package/core/dist/runtime/config/pd-config-agent-binding.js.map +1 -1
- package/core/dist/runtime/config/pd-config-feature-flags.d.ts +10 -0
- package/core/dist/runtime/config/pd-config-feature-flags.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-feature-flags.js +14 -0
- package/core/dist/runtime/config/pd-config-feature-flags.js.map +1 -1
- package/core/dist/runtime/config/pd-config-types.d.ts +9 -0
- package/core/dist/runtime/config/pd-config-types.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-types.js.map +1 -1
- package/core/dist/runtime/config/pd-config-validate.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-validate.js +10 -2
- package/core/dist/runtime/config/pd-config-validate.js.map +1 -1
- package/core/dist/runtime/config/pd-credentials.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-credentials.js +7 -1
- package/core/dist/runtime/config/pd-credentials.js.map +1 -1
- package/core/dist/runtime/diagnostician/distiller-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/distiller-prompt-builder.js +30 -3
- package/core/dist/runtime/diagnostician/distiller-prompt-builder.js.map +1 -1
- package/core/dist/runtime/diagnostician/rootcause-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/rootcause-prompt-builder.js +16 -5
- package/core/dist/runtime/diagnostician/rootcause-prompt-builder.js.map +1 -1
- package/core/dist/runtime/diagnostician/router-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/router-prompt-builder.js +16 -4
- package/core/dist/runtime/diagnostician/router-prompt-builder.js.map +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.d.ts.map +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js +13 -2
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js.map +1 -1
- package/core/dist/runtime/index.d.ts +4 -2
- package/core/dist/runtime/index.d.ts.map +1 -1
- package/core/dist/runtime/index.js +3 -1
- package/core/dist/runtime/index.js.map +1 -1
- package/core/dist/runtime/intent/intent-doc.d.ts +22 -0
- package/core/dist/runtime/intent/intent-doc.d.ts.map +1 -1
- package/core/dist/runtime/intent/intent-doc.js +79 -0
- package/core/dist/runtime/intent/intent-doc.js.map +1 -1
- package/core/dist/runtime/intent/intent-friction-block.d.ts +7 -0
- package/core/dist/runtime/intent/intent-friction-block.d.ts.map +1 -1
- package/core/dist/runtime/intent/intent-friction-block.js +34 -1
- package/core/dist/runtime/intent/intent-friction-block.js.map +1 -1
- package/core/dist/runtime/intent/intent-snapshot.d.ts +44 -5
- package/core/dist/runtime/intent/intent-snapshot.d.ts.map +1 -1
- package/core/dist/runtime/intent/intent-snapshot.js +83 -15
- package/core/dist/runtime/intent/intent-snapshot.js.map +1 -1
- package/core/dist/runtime/intent/strategic-conflict-gate.d.ts +19 -0
- package/core/dist/runtime/intent/strategic-conflict-gate.d.ts.map +1 -1
- package/core/dist/runtime/intent/strategic-conflict-gate.js +94 -26
- package/core/dist/runtime/intent/strategic-conflict-gate.js.map +1 -1
- package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts +22 -11
- package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/diag-rootcause-runner.js +101 -28
- package/core/dist/runtime/internalization/diag-rootcause-runner.js.map +1 -1
- package/core/dist/runtime/internalization/dreamer-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/dreamer-prompt-builder.js +177 -28
- package/core/dist/runtime/internalization/dreamer-prompt-builder.js.map +1 -1
- package/core/dist/runtime/internalization/dreamer-runner.d.ts +9 -2
- package/core/dist/runtime/internalization/dreamer-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/dreamer-runner.js +11 -1
- package/core/dist/runtime/internalization/dreamer-runner.js.map +1 -1
- package/core/dist/runtime/internalization/evaluator-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/evaluator-runner.js +7 -0
- package/core/dist/runtime/internalization/evaluator-runner.js.map +1 -1
- package/core/dist/runtime/internalization/formation-context.d.ts +16 -0
- package/core/dist/runtime/internalization/formation-context.d.ts.map +1 -1
- package/core/dist/runtime/internalization/formation-context.js +109 -8
- package/core/dist/runtime/internalization/formation-context.js.map +1 -1
- package/core/dist/runtime/internalization/index.d.ts +2 -2
- package/core/dist/runtime/internalization/index.d.ts.map +1 -1
- package/core/dist/runtime/internalization/index.js +1 -1
- package/core/dist/runtime/internalization/index.js.map +1 -1
- package/core/dist/runtime/internalization/intent-contract.d.ts +55 -4
- package/core/dist/runtime/internalization/intent-contract.d.ts.map +1 -1
- package/core/dist/runtime/internalization/intent-contract.js +111 -30
- package/core/dist/runtime/internalization/intent-contract.js.map +1 -1
- package/core/dist/runtime/internalization/internalization-orchestrator.d.ts +16 -2
- package/core/dist/runtime/internalization/internalization-orchestrator.d.ts.map +1 -1
- package/core/dist/runtime/internalization/internalization-orchestrator.js +48 -14
- package/core/dist/runtime/internalization/internalization-orchestrator.js.map +1 -1
- package/core/dist/runtime/internalization/philosopher-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/philosopher-prompt-builder.js +7 -6
- package/core/dist/runtime/internalization/philosopher-prompt-builder.js.map +1 -1
- package/core/dist/runtime/internalization/philosopher-runner.d.ts +9 -2
- package/core/dist/runtime/internalization/philosopher-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/philosopher-runner.js +11 -1
- package/core/dist/runtime/internalization/philosopher-runner.js.map +1 -1
- package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts +13 -6
- package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/scribe-prompt-builder.js +15 -10
- package/core/dist/runtime/internalization/scribe-prompt-builder.js.map +1 -1
- package/core/dist/runtime/internalization/scribe-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/scribe-runner.js +17 -7
- package/core/dist/runtime/internalization/scribe-runner.js.map +1 -1
- package/core/dist/runtime/pain-signal-bridge.d.ts +3 -0
- package/core/dist/runtime/pain-signal-bridge.d.ts.map +1 -1
- package/core/dist/runtime/pain-signal-bridge.js +224 -93
- package/core/dist/runtime/pain-signal-bridge.js.map +1 -1
- package/core/dist/runtime/pain-submit-capability.d.ts.map +1 -1
- package/core/dist/runtime/pain-submit-capability.js +3 -5
- package/core/dist/runtime/pain-submit-capability.js.map +1 -1
- package/core/dist/runtime/pain-to-principle-service.d.ts.map +1 -1
- package/core/dist/runtime/pain-to-principle-service.js +18 -21
- package/core/dist/runtime/pain-to-principle-service.js.map +1 -1
- package/core/dist/runtime/store/candidate/admission-document.d.ts +129 -0
- package/core/dist/runtime/store/candidate/admission-document.d.ts.map +1 -1
- package/core/dist/runtime/store/candidate/admission-document.js +196 -0
- package/core/dist/runtime/store/candidate/admission-document.js.map +1 -1
- package/core/dist/runtime/store/candidate/candidate-store.d.ts +54 -1
- package/core/dist/runtime/store/candidate/candidate-store.d.ts.map +1 -1
- package/core/dist/runtime/store/candidate/memory-candidate-store.d.ts +32 -1
- package/core/dist/runtime/store/candidate/memory-candidate-store.d.ts.map +1 -1
- package/core/dist/runtime/store/candidate/memory-candidate-store.js +24 -1
- package/core/dist/runtime/store/candidate/memory-candidate-store.js.map +1 -1
- package/core/dist/runtime/store/candidate/sqlite-candidate-store.d.ts +32 -1
- package/core/dist/runtime/store/candidate/sqlite-candidate-store.d.ts.map +1 -1
- package/core/dist/runtime/store/candidate/sqlite-candidate-store.js +76 -1
- package/core/dist/runtime/store/candidate/sqlite-candidate-store.js.map +1 -1
- package/core/dist/runtime/store/intent/sqlite-intent-decision-store.d.ts +10 -0
- package/core/dist/runtime/store/intent/sqlite-intent-decision-store.d.ts.map +1 -1
- package/core/dist/runtime/store/intent/sqlite-intent-decision-store.js +15 -4
- package/core/dist/runtime/store/intent/sqlite-intent-decision-store.js.map +1 -1
- package/core/dist/runtime/store/runtime-state-manager.d.ts +34 -1
- package/core/dist/runtime/store/runtime-state-manager.d.ts.map +1 -1
- package/core/dist/runtime/store/runtime-state-manager.js +10 -0
- package/core/dist/runtime/store/runtime-state-manager.js.map +1 -1
- package/core/dist/telemetry-event.d.ts +2 -2
- package/core/dist/telemetry-event.d.ts.map +1 -1
- package/core/dist/telemetry-event.js +6 -0
- package/core/dist/telemetry-event.js.map +1 -1
- package/core/package.json +1 -1
- package/dist/agent-skill.d.ts +59 -0
- package/dist/agent-skill.d.ts.map +1 -0
- package/dist/agent-skill.js +198 -0
- package/dist/agent-skill.js.map +1 -0
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +12 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +171 -3
- package/dist/index.js.map +1 -1
- package/dist/install-summary.d.ts +52 -0
- package/dist/install-summary.d.ts.map +1 -1
- package/dist/install-summary.js +104 -0
- package/dist/install-summary.js.map +1 -1
- package/host-runtime/dist/adaptive-background-append.d.ts +70 -0
- package/host-runtime/dist/adaptive-background-append.js +165 -0
- package/host-runtime/dist/governance-signal-admission.js +1 -5
- package/host-runtime/dist/index.d.ts +1 -0
- package/host-runtime/dist/index.js +5 -0
- package/host-runtime/package.json +1 -1
- package/package.json +3 -2
- package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
- package/pd-cli/dist/commands/candidate.js +243 -28
- package/pd-cli/dist/commands/candidate.js.map +1 -1
- package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
- package/pd-cli/dist/commands/diagnose.js +110 -7
- package/pd-cli/dist/commands/diagnose.js.map +1 -1
- package/pd-cli/dist/commands/health-console.d.ts +21 -0
- package/pd-cli/dist/commands/health-console.d.ts.map +1 -0
- package/pd-cli/dist/commands/health-console.js +106 -0
- package/pd-cli/dist/commands/health-console.js.map +1 -0
- package/pd-cli/dist/commands/health.d.ts +159 -0
- package/pd-cli/dist/commands/health.d.ts.map +1 -1
- package/pd-cli/dist/commands/health.js +162 -2
- package/pd-cli/dist/commands/health.js.map +1 -1
- package/pd-cli/dist/commands/mcp-probe.d.ts +48 -0
- package/pd-cli/dist/commands/mcp-probe.d.ts.map +1 -0
- package/pd-cli/dist/commands/mcp-probe.js +479 -0
- package/pd-cli/dist/commands/mcp-probe.js.map +1 -0
- package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-retry.js +3 -0
- package/pd-cli/dist/commands/pain-retry.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-once.js +70 -4
- package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
- package/pd-cli/dist/program.d.ts.map +1 -1
- package/pd-cli/dist/program.js +68 -1
- package/pd-cli/dist/program.js.map +1 -1
- package/pd-cli/dist/services/admission-write-gate.d.ts.map +1 -1
- package/pd-cli/dist/services/admission-write-gate.js +18 -7
- package/pd-cli/dist/services/admission-write-gate.js.map +1 -1
- package/pd-cli/dist/services/console-launcher.d.ts +3 -0
- package/pd-cli/dist/services/console-launcher.d.ts.map +1 -1
- package/pd-cli/dist/services/console-launcher.js +3 -2
- package/pd-cli/dist/services/console-launcher.js.map +1 -1
- package/pd-cli/dist/services/demo-story-a-runner.d.ts.map +1 -1
- package/pd-cli/dist/services/demo-story-a-runner.js +8 -3
- package/pd-cli/dist/services/demo-story-a-runner.js.map +1 -1
- package/pd-cli/dist/services/reuse-park-release.d.ts +142 -0
- package/pd-cli/dist/services/reuse-park-release.d.ts.map +1 -0
- package/pd-cli/dist/services/reuse-park-release.js +201 -0
- package/pd-cli/dist/services/reuse-park-release.js.map +1 -0
- package/pd-cli/package.json +1 -1
- package/plugin/dist/bundle.js +914 -640
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/release-manager/dist/i18n.js +12 -0
- package/release-manager/package.json +2 -1
- package/workbuddy-adapter/dist/pd-hook.js +37 -3
- package/workbuddy-adapter/package.json +1 -1
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { appliedOwnerDecision, buildOwnerDecisionIntent, fingerprintAdmissionMaterial, pendingOwnerDecision, } from '@principles/core/runtime';
|
|
2
|
+
/**
|
|
3
|
+
* Static policy identity for reuse-park release records. Distinct from the
|
|
4
|
+
* full-gate ADMISSION_POLICY_VERSION on purpose: the append idempotency key
|
|
5
|
+
* is (materialFingerprint, policyVersion), so a release record can never be
|
|
6
|
+
* deduplicated against a full-gate evaluation, and a re-issued release with
|
|
7
|
+
* the same Owner reason is an idempotent reuse.
|
|
8
|
+
*/
|
|
9
|
+
export const REUSE_PARK_RELEASE_POLICY_VERSION = 'reuse-park-release@1';
|
|
10
|
+
function parkPresent(document) {
|
|
11
|
+
return document?.processing?.state === 'awaiting_owner'
|
|
12
|
+
&& document.processing.blockedReason === 'reuse_pending_owner';
|
|
13
|
+
}
|
|
14
|
+
function parkFingerprintOf(document) {
|
|
15
|
+
const park = document?.processing;
|
|
16
|
+
if (!parkPresent(document) || park === undefined)
|
|
17
|
+
return undefined;
|
|
18
|
+
return fingerprintAdmissionMaterial([
|
|
19
|
+
'reuse-park',
|
|
20
|
+
String(park.attempts),
|
|
21
|
+
park.lastAttemptAt ?? 'unknown',
|
|
22
|
+
park.blockedReason ?? 'unknown',
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Build the release audit evaluation for a park being lifted in Phase C. The
|
|
27
|
+
* released park's own context travels INSIDE the record (and its idempotency
|
|
28
|
+
* fingerprint): once processing is cleared, these fields exist nowhere else.
|
|
29
|
+
*/
|
|
30
|
+
export function buildReuseParkReleaseEvaluation(input) {
|
|
31
|
+
const parkContext = `park[blockedReason=${input.park.blockedReason ?? 'unknown'},attempts=${input.park.attempts},lastAttemptAt=${input.park.lastAttemptAt ?? 'unknown'}]`;
|
|
32
|
+
const materialFingerprint = fingerprintAdmissionMaterial([
|
|
33
|
+
input.candidateId,
|
|
34
|
+
'reuse-park-release',
|
|
35
|
+
input.decide,
|
|
36
|
+
input.reason,
|
|
37
|
+
parkContext,
|
|
38
|
+
]);
|
|
39
|
+
return {
|
|
40
|
+
evaluationId: `ae_${fingerprintAdmissionMaterial([input.candidateId, materialFingerprint, REUSE_PARK_RELEASE_POLICY_VERSION]).slice(0, 16)}`,
|
|
41
|
+
decision: 'admitted',
|
|
42
|
+
reason: `reuse-park release (${input.decide}) by Owner — released ${parkContext} — reason: ${input.reason}`,
|
|
43
|
+
nextAction: input.decide === 'create'
|
|
44
|
+
? 'create the Principle via intake (Owner verdict)'
|
|
45
|
+
: 'resolve onto the existing Principle via reuseEvidence (Owner verdict)',
|
|
46
|
+
evaluatedAt: new Date().toISOString(),
|
|
47
|
+
policyVersion: REUSE_PARK_RELEASE_POLICY_VERSION,
|
|
48
|
+
provenance: `pd-candidate-review owner=${input.ownerId} source=${input.identitySource}`,
|
|
49
|
+
// The release evaluates no new admission material — the Owner reviewed the
|
|
50
|
+
// parked candidate — so the material counts are truthful zeros and the
|
|
51
|
+
// released park context is carried in the reason/provenance.
|
|
52
|
+
inputEvidenceCount: 0,
|
|
53
|
+
ownerStatementPresent: false,
|
|
54
|
+
recommendationKind: input.rawRecommendationKind ?? 'unknown',
|
|
55
|
+
confidence: null,
|
|
56
|
+
materialFingerprint,
|
|
57
|
+
materialSummary: {
|
|
58
|
+
inputEvidenceCount: 0,
|
|
59
|
+
outputEvidenceCount: 0,
|
|
60
|
+
ownerStatementPresent: false,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Phase A — persist (or idempotently resume) the Owner decision INTENT. The
|
|
66
|
+
* park is NOT cleared. Callers must have verified the Owner identity and
|
|
67
|
+
* validated the reuse selection (INV-R08) BEFORE this call.
|
|
68
|
+
*/
|
|
69
|
+
async function recordOwnerDecisionIntentSection(args) {
|
|
70
|
+
const { stateManager, executionProbe, candidateId, decide, reason, ownerId, identitySource } = args;
|
|
71
|
+
const admission = await stateManager.getAdmissionDocument(candidateId);
|
|
72
|
+
// An UNREADABLE admission document can never prove the decision state —
|
|
73
|
+
// recording an intent over it would park the verdict on unknown ground.
|
|
74
|
+
// Fail closed (CodeRabbit: same posture as the old release path).
|
|
75
|
+
if (!admission.ok) {
|
|
76
|
+
return {
|
|
77
|
+
status: 'failed',
|
|
78
|
+
reason: `admission document unreadable (${admission.reason}); cannot verify the decision state, so the ${decide} intent was NOT recorded`,
|
|
79
|
+
nextAction: 'inspect principle_candidates.admission_json for this candidate, repair the document, then re-run the decision',
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const document = admission.document ?? null;
|
|
83
|
+
const intent = buildOwnerDecisionIntent({
|
|
84
|
+
candidateId,
|
|
85
|
+
decision: decide,
|
|
86
|
+
...(decide === 'reuse' ? { selectedPrincipleId: args.selectedPrincipleId } : {}),
|
|
87
|
+
ownerId,
|
|
88
|
+
identitySource,
|
|
89
|
+
reason,
|
|
90
|
+
parkFingerprint: parkFingerprintOf(document),
|
|
91
|
+
});
|
|
92
|
+
// Same intent already completed → idempotent re-run: report the applied
|
|
93
|
+
// record; Phase B/C are skipped by the caller.
|
|
94
|
+
const appliedSame = appliedOwnerDecision(document);
|
|
95
|
+
if (appliedSame !== null && appliedSame.decisionId === intent.decisionId) {
|
|
96
|
+
return { status: 'already_applied', decision: appliedSame };
|
|
97
|
+
}
|
|
98
|
+
// A DIFFERENT pending intent may only be superseded when it provably never
|
|
99
|
+
// executed (directive §2.2: never require the Owner to re-choose a recorded
|
|
100
|
+
// verdict, and never leave a half-executed one behind).
|
|
101
|
+
const pending = pendingOwnerDecision(document);
|
|
102
|
+
if (pending !== null && (pending.decision !== decide || pending.selectedPrincipleId !== args.selectedPrincipleId)) {
|
|
103
|
+
const executed = pending.decision === 'reuse'
|
|
104
|
+
? executionProbe.findReuseResolutionForCandidate(candidateId) !== null
|
|
105
|
+
: executionProbe.existsForCandidate(candidateId) !== null;
|
|
106
|
+
if (executed) {
|
|
107
|
+
return {
|
|
108
|
+
status: 'failed',
|
|
109
|
+
reason: `a pending ${pending.decision} decision (${pending.decisionId}) already executed its ${pending.decision === 'reuse' ? 'reuseEvidence' : 'ledger entry'} but did not complete; superseding it now would create conflicting authorities`,
|
|
110
|
+
nextAction: `re-run the SAME ${pending.decision} verdict to complete the recorded decision, then decide again if still needed`,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const recorded = await stateManager.recordOwnerDecision(candidateId, intent);
|
|
115
|
+
if (recorded.status === 'refused') {
|
|
116
|
+
return {
|
|
117
|
+
status: 'failed',
|
|
118
|
+
reason: `owner decision intent could not be persisted (${recorded.reason}); the ${decide} verdict was NOT executed and the candidate state is intact`,
|
|
119
|
+
nextAction: 'inspect principle_candidates.admission_json for this candidate, repair the document, then re-run the decision',
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
status: 'recorded',
|
|
124
|
+
decision: recorded.decision,
|
|
125
|
+
resumed: recorded.status === 'resumed',
|
|
126
|
+
...(recorded.status === 'superseded' ? { supersededPrevious: recorded.supersededDecisionId } : {}),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Phase A — persist (or idempotently resume) the Owner decision INTENT. The
|
|
131
|
+
* park is NOT cleared. Callers must have verified the Owner identity and
|
|
132
|
+
* validated the reuse selection (INV-R08) BEFORE this call.
|
|
133
|
+
*
|
|
134
|
+
* P1-1: the read → probe → persist sequence inside the section runs under
|
|
135
|
+
* the SAME candidate coordination lock as Phase B — a concurrent differing
|
|
136
|
+
* verdict can never interleave between another process's verify and write.
|
|
137
|
+
* Adapters without the capability (test doubles) run the section directly.
|
|
138
|
+
*/
|
|
139
|
+
export async function recordOwnerDecisionIntent(args) {
|
|
140
|
+
if (args.coordination?.withCandidateCoordination !== undefined) {
|
|
141
|
+
return args.coordination.withCandidateCoordination(args.candidateId, () => recordOwnerDecisionIntentSection(args));
|
|
142
|
+
}
|
|
143
|
+
return recordOwnerDecisionIntentSection(args);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Phase C — atomically finalize the executed decision: applied + release
|
|
147
|
+
* audit (when a park was lifted) + processing complete, in ONE admission
|
|
148
|
+
* write. `already_completed` is the idempotent re-run (crash after
|
|
149
|
+
* completion, lost response): the caller reports the completed result.
|
|
150
|
+
*/
|
|
151
|
+
async function completeOwnerDecisionSection(args) {
|
|
152
|
+
const { stateManager, candidateId, decision } = args;
|
|
153
|
+
const admission = await stateManager.getAdmissionDocument(candidateId);
|
|
154
|
+
if (!admission.ok) {
|
|
155
|
+
return {
|
|
156
|
+
status: 'failed',
|
|
157
|
+
reason: `admission document unreadable (${admission.reason}); the decision's ledger side is durable but the completion could not be recorded`,
|
|
158
|
+
nextAction: 'inspect principle_candidates.admission_json for this candidate; re-running the SAME verdict resumes Phase C idempotently',
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
// The release audit exists ONLY when this decision actually lifted a park.
|
|
162
|
+
let releaseEvaluation;
|
|
163
|
+
if (parkPresent(admission.document ?? null)) {
|
|
164
|
+
const park = admission.document?.processing;
|
|
165
|
+
if (park !== undefined) {
|
|
166
|
+
releaseEvaluation = buildReuseParkReleaseEvaluation({
|
|
167
|
+
candidateId,
|
|
168
|
+
decide: decision.decision,
|
|
169
|
+
reason: decision.reason,
|
|
170
|
+
ownerId: args.ownerId,
|
|
171
|
+
identitySource: args.identitySource,
|
|
172
|
+
rawRecommendationKind: args.rawRecommendationKind,
|
|
173
|
+
park: { blockedReason: park.blockedReason, attempts: park.attempts, lastAttemptAt: park.lastAttemptAt },
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const completed = await stateManager.completeOwnerDecision(candidateId, decision.decisionId, {
|
|
178
|
+
resultingPrincipleId: args.resultingPrincipleId,
|
|
179
|
+
...(releaseEvaluation !== undefined ? { releaseEvaluation } : {}),
|
|
180
|
+
});
|
|
181
|
+
if (completed.status === 'refused') {
|
|
182
|
+
return {
|
|
183
|
+
status: 'failed',
|
|
184
|
+
reason: `owner decision completion could not be persisted (${completed.reason}); the decision's ledger side is durable and the decision stays pending`,
|
|
185
|
+
nextAction: 'inspect principle_candidates.admission_json for this candidate; re-running the SAME verdict resumes Phase C idempotently',
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
return completed.status === 'completed'
|
|
189
|
+
? { status: 'completed' }
|
|
190
|
+
: { status: 'already_completed' };
|
|
191
|
+
}
|
|
192
|
+
export async function completeOwnerDecisionExecution(args) {
|
|
193
|
+
// P1-1: Phase C is also serialized on the candidate lock — the applied
|
|
194
|
+
// mark + release audit + processing transition must never interleave with
|
|
195
|
+
// a concurrent Phase A supersede/record of a differing verdict.
|
|
196
|
+
if (args.coordination?.withCandidateCoordination !== undefined) {
|
|
197
|
+
return args.coordination.withCandidateCoordination(args.candidateId, () => completeOwnerDecisionSection(args));
|
|
198
|
+
}
|
|
199
|
+
return completeOwnerDecisionSection(args);
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=reuse-park-release.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reuse-park-release.js","sourceRoot":"","sources":["../../src/services/reuse-park-release.ts"],"names":[],"mappings":"AAoCA,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,4BAA4B,EAC5B,oBAAoB,GAIrB,MAAM,0BAA0B,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,sBAAsB,CAAC;AAExE,SAAS,WAAW,CAAC,QAAuD;IAC1E,OAAO,QAAQ,EAAE,UAAU,EAAE,KAAK,KAAK,gBAAgB;WAClD,QAAQ,CAAC,UAAU,CAAC,aAAa,KAAK,qBAAqB,CAAC;AACnE,CAAC;AAED,SAAS,iBAAiB,CAAC,QAAuD;IAChF,MAAM,IAAI,GAAG,QAAQ,EAAE,UAAU,CAAC;IAClC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACnE,OAAO,4BAA4B,CAAC;QAClC,YAAY;QACZ,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;QACrB,IAAI,CAAC,aAAa,IAAI,SAAS;QAC/B,IAAI,CAAC,aAAa,IAAI,SAAS;KAChC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,+BA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