dsh-completion-guard 0.8.0 → 0.8.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/dist/index.js CHANGED
@@ -1,16 +1,17 @@
1
- import { $ as PROOF_KINDS, $i as BOUNDED_ARTIFACT_TYPES, $n as capabilityConsequence, $r as statefulActionsOfScope, $t as reservationFor, A as PROTOCOL_V4_NOTICE, Ai as DEFAULT_HOST_LOCK, An as isCurrentAcceptedBoundary, Ar as interpretMessage, At as carriesCleanupCondition, B as extractToolSubject, Bi as evaluateToolSurfaceCapability, Bn as replayRebindResult, Br as legacyQuestionReadingIsInformational, Bt as sourceItemForCoreRequirement, C as SESSION_EVENT_ENVELOPE_INVALID, Ci as resolveActiveProfileHostLock, Cn as hasCurrentCertificate, Cr as clauseIsProtected, Ct as CLEANUP_CONDITION_RULE_COMPACT, D as CAPTURE_V042_NOTICE, Di as ACTIVE_HOST_COHORT_IDS, Dn as BOUNDARY_RECORD_PREFIX, Dr as hasQuestionScope, Dt as V6_ORDINARY_COMPLETION_RULE, E as projectCoreV2, Ei as ACTIVE_HOST_COHORT_ID, En as unitDescendantIds, Er as hasOrderedCoordination, Et as MIN_RECOVERY_CHAR_BUDGET, F as legacyRecordsNeedingReview, Fi as bindExecutableIdentity, Fn as proposeRebind, Fr as isOpenObligation, Ft as recoveryTitle, G as isRunExecutable, Gi as SUPPORTED_HOST_RANGE, Gn as deriveItemDiagnosis, Gr as opensWithDirective, Gt as inFlightReservation, H as persistedToolResultStatus, Hi as selectHostCohort, Hn as isFrozenV042RebindResponse, Hr as maskQuotedSpans, Ht as RELEASE_OPERATIONS, I as rootLocatorFlavor, Ii as bindLiveGoalCapability, In as proposeRebindOutcome, Ir as isQuestionScopeNeedingReview, It as renderRecoveryPacket, J as authorityCaptureCounts, Ji as evaluateMinimumHostVersion, Jn as nativeFileTwoRole, Jr as questionHeadsClause, Jt as normalizeSettlement, K as parsePwshCommand, Ki as SUPPORTED_HOST_VERSIONS, Kn as evidenceAvailabilityReason, Kr as presentExplanationHead, Kt as normalizeReleaseContract, L as supersedeItem, Li as evaluateExternalWaitCapability, Ln as proposeRebindV042, Lr as isRestatement, Lt as v6CurrentRootBoundaries, M as PROTOCOL_V6_NOTICE, Mi as GOAL_HOST_PACKAGES, Mn as currentContractDigest, Mr as isExecutableItem, Mt as closingHint, N as applyUpgradeEligibility, Ni as HOST_CAPABILITY_PACKAGE_GROUPS, Nn as createProjection, Nr as isExplanationScope, Nt as openItems, O as DEFAULT_DELEGATION_TOOL_NAMES, Oi as ACTIVE_HOST_LAUNCHER_VERSION, On as availableBoundaryQualifications, Or as hasWorkPredicate, Ot as V6_ORDINARY_COMPLETION_RULE_COMPACT, P as deriveProjection, Pi as HOST_COHORTS, Pn as confirmRebind, Pr as isInformationalFragment, Pt as recoveryDigest, Q as PROOF_CAPABILITY_MATRIX, Qi as ACTION_MANIFEST_VERSION, Qn as admissibleForRemoval, Qr as splitTextFragments, Qt as releasePreEffectDecision, R as evidenceFromPersistedToolResult, Ri as evaluateHostCapability, Rn as rebindAttemptKey, Rr as itemHoldsExecutionAuthority, Rt as currentV6Feedback, S as SESSION_API_UNSUPPORTED, Si as readActiveHostGraph, Sn as goalCompletionDenial, Sr as clauseIsGoverned, St as CLEANUP_CONDITION_RULE, T as snapshotSessionEvents, Ti as verifyComposedHostLockDump, Tn as certificateClosure, Tr as governedClauseRestrictsExecution, Tt as DEFAULT_RECOVERY_CHAR_BUDGET, U as withDurability, Ui as LATEST_SUPPORTED_HOST_VERSION, Un as parseConfirmationMessage, Ur as namedActions, Ut as RELEASE_OPERATION_SURFACES, V as isDeterministicCheck, Vi as hostVersionFromPackages, Vn as CONFIRM_LINE_PATTERN, Vr as maskCodeSpans, Vt as OUTCOME_STRENGTH, W as canonicalArgvFromCommand, Wi as MIN_SUPPORTED_HOST_VERSION, Wn as capabilityRemedyPhrase, Wr as opensConditionLead, Wt as contractById, X as bindingIndividuallyAccepted, Xi as satisfiesSupportedHostRange, Xn as DEPENDENCY_FREE_ONLY_CONDITION, Xr as restatedContentOf, Xt as releaseContractFor, Y as segmentAuthorityBlocks, Yi as parseHostVersion, Yn as relevantEvidence, Yr as reportingHeadGoverns, Yt as readbackSettlesContract, Z as certifyCheckpoint, Zi as ACTION_MANIFEST, Zn as actionHasCertificationPath, Zr as semanticActionOfScope, Zt as releaseCoverage, _ as projectSessionCoreV2, _a as RC017_RC2_HOST_PACKAGES, _i as hostLockRowsFromComposedDump, _n as latestRootInstruction, _r as GRANTED_QUALIFICATION, _t as scopeCoverageDigest, a as createGitPrestateEnvelope, aa as STOP_PROTOCOL_VERSION_V2, ai as normalizeClause, an as NO_PROGRESS_RECORD_PREFIX, ar as captureItem, at as bindProofV2ToProjection, b as captureHostWorkdir, bi as packageRowsFromActiveGraph, bn as testOutcomePredicate, br as clarifiedSpanOf, bt as validateProofManifest, c as parseGitCommandManifest, ca as boundedArtifactChoiceMatches, ci as sha256, cn as assessmentOutcomePredicate, cr as extractArtifactPaths, ct as createProofManifestV2, d as FIRST_STEP_GUIDANCE, da as requestedTargetAuthorizesMutation, di as auditedDefaultWorkdirHost, dn as decideTurnBoundary, dr as isInformationalMessage, dt as proofDigestV2, ea as CERTIFICATE_VERSION, ei as verbIsNegated, en as bindingSatisfies, er as capabilityFactOf, et as PROOF_KINDS_V2, f as claimedBatchHasRealRootInput, fa as requestedTargetMatchesResolved, fi as auditedDefaultWorkdirProvider, fn as decideTurnStopping, fr as segmentClauses, ft as proofEvidenceConstraints, g as previewFirstStepInjection, ga as validateActionTarget, gi as hostLockContextFromComposedDump, gn as latestAssistantText, gr as classifyUserInteraction, gt as requiredSubjectsOf, h as lifecyclePhase, ha as validateActionManifest, hi as combineHostPolicy, hn as isWholeTaskCompletionClaim, hr as classifyTaskIntent, ht as proofV2Rejection, i as commitTreeSnapshotDigest, ia as STOP_PROTOCOL_VERSION, ii as digestStrings, in as CONTROL_RECORD_PREFIX, ir as captureClause, it as bindProofToProjection, j as PROTOCOL_V5_NOTICE, ji as EXPECTED_HOST_PACKAGES, jn as qualifyBoundary, jr as introducesActionClause, jt as cleanupConditionFor, k as PROTOCOL_V3_NOTICE, ki as BASE_HOST_PACKAGES, kn as effectuateBoundary, kr as interpretClause, kt as V6_ORDINARY_COMPLETION_RULE_SHORT, l as revalidateGitPrestate, la as isStatefulAction, li as HostProfileError, ln as classifyCompletionClaim, lr as extractMethod, lt as proofCapabilityReport, m as firstStepGuidanceV6, ma as semanticActionFromText, mi as auditedHostImplementation, mn as isRootPauseRequest, mr as npmEscapedPackageName, mt as proofOperationMatches, n as GIT_COMMAND_TEMPLATES, na as SEMANTIC_ACTIONS, ni as validateManifest, nn as evidenceMatchesItem, nr as removalIsComplete, nt as PROOF_PROTOCOL_VERSION, o as executeRevalidatedGitEffect, oa as SUPPORTED_EVIDENCE_ADAPTERS, oi as sanitizeClauseText, on as NO_PROGRESS_TURNS_BEFORE_STOP, or as classifyClause, ot as canonicalProjection, p as firstStepGuidance, pa as semanticActionFromCommand, pi as auditedForegroundRenderers, pn as decisionBoundaryKey, pr as canonicalRegistryBase, pt as proofHostSurfacesOf, q as parseShellCommand, qi as compareHostVersions, qn as itemDiagnosis, qr as qualificationOfClause, qt as normalizeReservation, r as commitIndexSnapshotDigest, ra as STATEFUL_ACTIONS, ri as canonicalizePath, rn as isVerifyingCapability, rr as removalIsPartiallyKnown, rt as PROOF_PROTOCOL_VERSION_V2, s as gitCommandMatchesTarget, sa as actionCompatible, si as sanitizeUrl, sn as assessmentAction, sr as environmentDefaultRepositoryTarget, st as createProofManifest, t as GIT_COMMAND_MANIFEST_IDS, ta as CERTIFICATE_VERSION_V2, ti as COMMAND_SURFACE_MANIFEST, tn as evidenceCoverage, tr as partialFailureOf, tt as PROOF_MANIFEST_DOMAIN_V2, u as verifiedLinearCommitReadback, ua as requestedIdentityKey, ui as activeRendererModule, un as currentActionBases, ur as extractOperation, ut as proofDigest, v as sessionCoreSnapshot, vi as injectActiveProfileHostLock, vn as observeAssistantOutcome, vr as LEGACY_QUALIFICATION, vt as sessionQuery, w as SessionApiError, wi as resolveInstalledHostLock, wn as certifiableOpenItems, wr as explanationHasActionResidue, wt as CLEANUP_CONDITION_RULE_SHORT, x as sourcedNamedTestRoot, xi as packageRowsFromPnpmLock, xn as v6TestPredicate, xr as clauseAsksOwnQuestion, xt as validateProofManifestV2, y as HOST_WORKDIR_PREFIX, yi as inspectTargetHostGraph, yn as progressFingerprint, yr as actionVerbMatches, yt as sessionQueryV2, z as extractTextContent, zi as evaluateHostLock, zn as rebindResponse, zr as kindOfScope, zt as isV6PendingRootWait } from "./domain-D0zTh3O_.js";
1
+ import { $ as PROOF_KINDS, $i as hostVersionFromPackages, $n as capabilityConsequence, $r as statefulActionsOfScope, $t as reservationFor, A as PROTOCOL_V4_NOTICE, Aa as RC020_RC1_HOST_PACKAGES, Ai as HostTrustError, An as isCurrentAcceptedBoundary, Ar as interpretMessage, At as carriesCleanupCondition, B as extractToolSubject, Bi as BASE_HOST_PACKAGES, Bn as replayRebindResult, Br as legacyQuestionReadingIsInformational, Bt as sourceItemForCoreRequirement, C as SESSION_EVENT_ENVELOPE_INVALID, Ca as requestedIdentityKey, Ci as packageRowsFromPnpmLock, Cn as hasCurrentCertificate, Cr as clauseIsProtected, Ct as CLEANUP_CONDITION_RULE_COMPACT, D as CAPTURE_V042_NOTICE, Da as semanticActionFromText, Di as resolveActiveProfileHostLock, Dn as BOUNDARY_RECORD_PREFIX, Dr as hasQuestionScope, Dt as V6_ORDINARY_COMPLETION_RULE, E as projectCoreV2, Ea as semanticActionFromCommand, Ei as readActiveHostGraph, En as unitDescendantIds, Er as hasOrderedCoordination, Et as MIN_RECOVERY_CHAR_BUDGET, F as legacyRecordsNeedingReview, Fi as registryArchiveFiles, Fn as proposeRebind, Fr as isOpenObligation, Ft as recoveryTitle, G as isRunExecutable, Gi as HOST_COHORTS, Gn as deriveItemDiagnosis, Gr as opensWithDirective, Gt as inFlightReservation, H as persistedToolResultStatus, Hi as EXPECTED_HOST_PACKAGES, Hn as isFrozenV042RebindResponse, Hr as maskQuotedSpans, Ht as RELEASE_OPERATIONS, I as rootLocatorFlavor, Ii as registryArchiveModules, In as proposeRebindOutcome, Ir as isQuestionScopeNeedingReview, It as renderRecoveryPacket, J as authorityCaptureCounts, Ji as evaluateExternalWaitCapability, Jn as nativeFileTwoRole, Jr as questionHeadsClause, Jt as normalizeSettlement, K as parsePwshCommand, Ki as bindExecutableIdentity, Kn as evidenceAvailabilityReason, Kr as presentExplanationHead, Kt as normalizeReleaseContract, L as supersedeItem, Li as ACTIVE_HOST_COHORT_ID, Ln as proposeRebindV042, Lr as isRestatement, Lt as v6CurrentRootBoundaries, M as PROTOCOL_V6_NOTICE, Mi as hostTrustDigest, Mn as currentContractDigest, Mr as isExecutableItem, Mt as closingHint, N as applyUpgradeEligibility, Ni as parseHostTrust, Nn as createProjection, Nr as isExplanationScope, Nt as openItems, O as DEFAULT_DELEGATION_TOOL_NAMES, Oa as validateActionManifest, Oi as resolveInstalledHostLock, On as availableBoundaryQualifications, Or as hasWorkPredicate, Ot as V6_ORDINARY_COMPLETION_RULE_COMPACT, P as deriveProjection, Pi as qualifyHostTrust, Pn as confirmRebind, Pr as isInformationalFragment, Pt as recoveryDigest, Q as PROOF_CAPABILITY_MATRIX, Qi as evaluateToolSurfaceCapability, Qn as admissibleForRemoval, Qr as splitTextFragments, Qt as releasePreEffectDecision, R as evidenceFromPersistedToolResult, Ri as ACTIVE_HOST_COHORT_IDS, Rn as rebindAttemptKey, Rr as itemHoldsExecutionAuthority, Rt as currentV6Feedback, S as SESSION_API_UNSUPPORTED, Sa as isStatefulAction, Si as packageRowsFromActiveGraph, Sn as goalCompletionDenial, Sr as clauseIsGoverned, St as CLEANUP_CONDITION_RULE, T as snapshotSessionEvents, Ta as requestedTargetMatchesResolved, Ti as prepareTargetHostTrust, Tn as certificateClosure, Tr as governedClauseRestrictsExecution, Tt as DEFAULT_RECOVERY_CHAR_BUDGET, U as withDurability, Ui as GOAL_HOST_PACKAGES, Un as parseConfirmationMessage, Ur as namedActions, Ut as RELEASE_OPERATION_SURFACES, V as isDeterministicCheck, Vi as DEFAULT_HOST_LOCK, Vn as CONFIRM_LINE_PATTERN, Vr as maskCodeSpans, Vt as OUTCOME_STRENGTH, W as canonicalArgvFromCommand, Wi as HOST_CAPABILITY_PACKAGE_GROUPS, Wn as capabilityRemedyPhrase, Wr as opensConditionLead, Wt as contractById, X as bindingIndividuallyAccepted, Xi as evaluateHostCapability, Xn as DEPENDENCY_FREE_ONLY_CONDITION, Xr as restatedContentOf, Xt as releaseContractFor, Y as segmentAuthorityBlocks, Yi as evaluateGraphDerivedHostLock, Yn as relevantEvidence, Yr as reportingHeadGoverns, Yt as readbackSettlesContract, Z as certifyCheckpoint, Zi as evaluateHostLock, Zn as actionHasCertificationPath, Zr as semanticActionOfScope, Zt as releaseCoverage, _ as projectSessionCoreV2, _a as STOP_PROTOCOL_VERSION, _i as evaluateConfiguredHostLock, _n as latestRootInstruction, _r as GRANTED_QUALIFICATION, _t as scopeCoverageDigest, a as createGitPrestateEnvelope, aa as SUPPORTED_HOST_VERSIONS, ai as normalizeClause, an as NO_PROGRESS_RECORD_PREFIX, ar as captureItem, at as bindProofV2ToProjection, b as captureHostWorkdir, ba as actionCompatible, bi as injectActiveProfileHostLock, bn as testOutcomePredicate, br as clarifiedSpanOf, bt as validateProofManifest, c as parseGitCommandManifest, ca as parseHostVersion, ci as sha256, cn as assessmentOutcomePredicate, cr as extractArtifactPaths, ct as createProofManifestV2, d as FIRST_STEP_GUIDANCE, da as ACTION_MANIFEST_VERSION, di as auditedDefaultWorkdirHost, dn as decideTurnBoundary, dr as isInformationalMessage, dt as proofDigestV2, ea as selectHostCohort, ei as verbIsNegated, en as bindingSatisfies, er as capabilityFactOf, et as PROOF_KINDS_V2, f as claimedBatchHasRealRootInput, fa as BOUNDED_ARTIFACT_TYPES, fi as auditedDefaultWorkdirProvider, fn as decideTurnStopping, fr as segmentClauses, ft as proofEvidenceConstraints, g as previewFirstStepInjection, ga as STATEFUL_ACTIONS, gi as evaluateActiveHostLock, gn as latestAssistantText, gr as classifyUserInteraction, gt as requiredSubjectsOf, h as lifecyclePhase, ha as SEMANTIC_ACTIONS, hi as combineHostPolicy, hn as isWholeTaskCompletionClaim, hr as classifyTaskIntent, ht as proofV2Rejection, i as commitTreeSnapshotDigest, ia as SUPPORTED_HOST_RANGE, ii as digestStrings, in as CONTROL_RECORD_PREFIX, ir as captureClause, it as bindProofToProjection, j as PROTOCOL_V5_NOTICE, ja as createHostAuditSession, ji as acquireHostTrust, jn as qualifyBoundary, jr as introducesActionClause, jt as cleanupConditionFor, k as PROTOCOL_V3_NOTICE, ka as validateActionTarget, ki as verifyComposedHostLockDump, kn as effectuateBoundary, kr as interpretClause, kt as V6_ORDINARY_COMPLETION_RULE_SHORT, l as revalidateGitPrestate, la as satisfiesSupportedHostRange, li as HostProfileError, ln as classifyCompletionClaim, lr as extractMethod, lt as proofCapabilityReport, m as firstStepGuidanceV6, ma as CERTIFICATE_VERSION_V2, mi as auditedHostImplementation, mn as isRootPauseRequest, mr as npmEscapedPackageName, mt as proofOperationMatches, n as GIT_COMMAND_TEMPLATES, na as LATEST_TESTED_HOST_VERSION, ni as validateManifest, nn as evidenceMatchesItem, nr as removalIsComplete, nt as PROOF_PROTOCOL_VERSION, o as executeRevalidatedGitEffect, oa as compareHostVersions, oi as sanitizeClauseText, on as NO_PROGRESS_TURNS_BEFORE_STOP, or as classifyClause, ot as canonicalProjection, p as firstStepGuidance, pa as CERTIFICATE_VERSION, pi as auditedForegroundRenderers, pn as decisionBoundaryKey, pr as canonicalRegistryBase, pt as proofHostSurfacesOf, q as parseShellCommand, qi as bindLiveGoalCapability, qn as itemDiagnosis, qr as qualificationOfClause, qt as normalizeReservation, r as commitIndexSnapshotDigest, ra as MIN_SUPPORTED_HOST_VERSION, ri as canonicalizePath, rn as isVerifyingCapability, rr as removalIsPartiallyKnown, rt as PROOF_PROTOCOL_VERSION_V2, s as gitCommandMatchesTarget, sa as evaluateMinimumHostVersion, si as sanitizeUrl, sn as assessmentAction, sr as environmentDefaultRepositoryTarget, st as createProofManifest, t as GIT_COMMAND_MANIFEST_IDS, ta as HOST_VALIDATED_VERSIONS, ti as COMMAND_SURFACE_MANIFEST, tn as evidenceCoverage, tr as partialFailureOf, tt as PROOF_MANIFEST_DOMAIN_V2, u as verifiedLinearCommitReadback, ua as ACTION_MANIFEST, ui as activeRendererModule, un as currentActionBases, ur as extractOperation, ut as proofDigest, v as sessionCoreSnapshot, va as STOP_PROTOCOL_VERSION_V2, vi as hostLockContextFromComposedDump, vn as observeAssistantOutcome, vr as LEGACY_QUALIFICATION, vt as sessionQuery, w as SessionApiError, wa as requestedTargetAuthorizesMutation, wi as prepareActiveHostTrust, wn as certifiableOpenItems, wr as explanationHasActionResidue, wt as CLEANUP_CONDITION_RULE_SHORT, x as sourcedNamedTestRoot, xa as boundedArtifactChoiceMatches, xi as inspectTargetHostGraph, xn as v6TestPredicate, xr as clauseAsksOwnQuestion, xt as validateProofManifestV2, y as HOST_WORKDIR_PREFIX, ya as SUPPORTED_EVIDENCE_ADAPTERS, yi as hostLockRowsFromComposedDump, yn as progressFingerprint, yr as actionVerbMatches, yt as sessionQueryV2, z as extractTextContent, zi as ACTIVE_HOST_LAUNCHER_VERSION, zn as rebindResponse, zr as kindOfScope, zt as isV6PendingRootWait } from "./domain-Jo13xgPJ.js";
2
2
  import { boundContextSummary, createUserMessage } from "@deepseek-ai/dsh-llm";
3
- import { closeSync, constants, existsSync, fchmodSync, fstatSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, unlinkSync, writeSync } from "node:fs";
4
3
  import { basename, delimiter, dirname, isAbsolute, join, posix, resolve, win32 } from "node:path";
5
- import { createHash } from "node:crypto";
6
4
  import { fileURLToPath } from "node:url";
5
+ import { createHash } from "node:crypto";
6
+ import { closeSync, constants, existsSync, fchmodSync, fstatSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, unlinkSync, writeSync } from "node:fs";
7
+ import { gunzip } from "node:zlib";
8
+ import { execFile } from "node:child_process";
9
+ import { homedir, tmpdir } from "node:os";
7
10
  import { JobId } from "@deepseek-ai/dsh-jobs";
8
11
  import { defineTool } from "@deepseek-ai/dsh-tools";
9
- import { homedir, tmpdir } from "node:os";
12
+ import { AsyncLocalStorage } from "node:async_hooks";
10
13
  import { promisify } from "node:util";
11
- import { execFile } from "node:child_process";
12
14
  import { access, readFile, realpath } from "node:fs/promises";
13
- import { gunzip } from "node:zlib";
14
15
  import { SESSION_FORMAT_VERSION, Session, SessionId } from "@deepseek-ai/dsh-session";
15
16
 
16
17
  //#region src/tools/rebind.ts
@@ -410,7 +411,7 @@ function openItemForTool(projection, item) {
410
411
  ...template ? { binding_template: template } : {}
411
412
  };
412
413
  }
413
- function createCheckpointTool(getProjection, onRejected, prepare = async () => true) {
414
+ function createCheckpointTool(getProjection, onRejected, prepare = async () => true, revalidate = () => {}) {
414
415
  return defineTool({
415
416
  name: "context_guard_checkpoint",
416
417
  description: "Read current ordinary closure from confirmed observations; request a certificate only for an explicitly adopted proof, Goal, or release contract.",
@@ -836,6 +837,7 @@ function createCheckpointTool(getProjection, onRejected, prepare = async () => t
836
837
  order: closure.order
837
838
  })) } : {}
838
839
  }));
840
+ revalidate();
839
841
  let proofState = {
840
842
  status: "absent",
841
843
  reason_codes: []
@@ -2487,6 +2489,10 @@ async function executeGuardAction(action, resolution, roots, signal, executableI
2487
2489
  const tgzPath = requireString(resolution.commandManifest, "tgz_path");
2488
2490
  const identity = tgzPath ? await tgzIdentity(tgzPath) : void 0;
2489
2491
  if (!executableIdentity$1 || !tgzPath || !identity || identity.name !== target.package_id || identity.version !== target.version || identity.integrity !== target.integrity_digest || roots.profile?.name !== target.profile) return { status: "unavailable" };
2492
+ if (roots.preEffectVeto?.() === false) return {
2493
+ status: "unavailable",
2494
+ reasonCode: "pre_effect_host_veto_refused"
2495
+ };
2490
2496
  await runCommand(roots, executableIdentity$1, [
2491
2497
  "plugin",
2492
2498
  "--profile",
@@ -2501,6 +2507,10 @@ async function executeGuardAction(action, resolution, roots, signal, executableI
2501
2507
  const identity = tgzPath ? await tgzIdentity(tgzPath) : void 0;
2502
2508
  const registry = typeof target.registry === "string" ? canonicalRegistryBase(target.registry, { allowLoopbackHttp: roots.allowLoopbackHttpRegistry }) : void 0;
2503
2509
  if (!executableIdentity$1 || !tgzPath || !identity || identity.name !== target.artifact_id || identity.version !== target.version || identity.integrity !== target.integrity_digest || !registry || registry !== target.registry) return { status: "unavailable" };
2510
+ if (roots.preEffectVeto?.() === false) return {
2511
+ status: "unavailable",
2512
+ reasonCode: "pre_effect_host_veto_refused"
2513
+ };
2504
2514
  await runCommand(roots, executableIdentity$1, [
2505
2515
  "publish",
2506
2516
  tgzPath,
@@ -3025,7 +3035,8 @@ function normalizedRoots(options) {
3025
3035
  ...options.readExecutableIdentity ? { readExecutableIdentity: options.readExecutableIdentity } : {},
3026
3036
  ...options.allowLoopbackHttpRegistry ? { allowLoopbackHttpRegistry: true } : {},
3027
3037
  ...options.releaseGate ? { releaseGate: options.releaseGate } : {},
3028
- ...options.releaseSettle ? { releaseSettle: options.releaseSettle } : {}
3038
+ ...options.releaseSettle ? { releaseSettle: options.releaseSettle } : {},
3039
+ ...options.preEffectVeto ? { preEffectVeto: options.preEffectVeto } : {}
3029
3040
  };
3030
3041
  }
3031
3042
  function createActionTool(options = {}) {
@@ -3139,11 +3150,6 @@ function createActionTool(options = {}) {
3139
3150
  reason_code: "action_adapter_unavailable",
3140
3151
  ...empty
3141
3152
  };
3142
- if (roots.hostCapability?.(action).status !== "supported" && roots.hostCapability) return {
3143
- status: "unavailable",
3144
- reason_code: "host_capability_unavailable",
3145
- ...empty
3146
- };
3147
3153
  let durable = false;
3148
3154
  try {
3149
3155
  durable = await roots.prepareMutation?.(agent) === true;
@@ -3173,6 +3179,31 @@ function createActionTool(options = {}) {
3173
3179
  reason_code: "target_digest_mismatch",
3174
3180
  ...identity
3175
3181
  };
3182
+ const executable = executableFor(action);
3183
+ let currentExecutable;
3184
+ if (executable) {
3185
+ currentExecutable = await (roots.readExecutableIdentity ?? executableIdentity)(executable, exec.signal);
3186
+ if (bindExecutableIdentity(resolution.executableIdentity, currentExecutable).status !== "supported") return {
3187
+ status: "unavailable",
3188
+ reason_code: "executable_identity_drift",
3189
+ ...identity
3190
+ };
3191
+ }
3192
+ const releaseOperation = action === "publish" ? "npm_publish" : void 0;
3193
+ let observed;
3194
+ if (releaseOperation && roots.releaseGate) {
3195
+ observed = await observePublishCandidate(resolution, roots, exec.signal, cwdOf(agent));
3196
+ if (!observed) return {
3197
+ status: "unavailable",
3198
+ reason_code: "release_candidate_unobservable",
3199
+ ...identity
3200
+ };
3201
+ }
3202
+ if (roots.hostCapability?.(action).status !== "supported" && roots.hostCapability) return {
3203
+ status: "unavailable",
3204
+ reason_code: "host_capability_unavailable",
3205
+ ...empty
3206
+ };
3176
3207
  let authorization;
3177
3208
  try {
3178
3209
  authorization = roots.authorizeMutation?.({
@@ -3189,26 +3220,9 @@ function createActionTool(options = {}) {
3189
3220
  reason_code: authorization?.reasonCode ?? "mutation_authority_unavailable",
3190
3221
  ...identity
3191
3222
  };
3192
- const executable = executableFor(action);
3193
- let currentExecutable;
3194
- if (executable) {
3195
- currentExecutable = await (roots.readExecutableIdentity ?? executableIdentity)(executable, exec.signal);
3196
- if (bindExecutableIdentity(resolution.executableIdentity, currentExecutable).status !== "supported") return {
3197
- status: "unavailable",
3198
- reason_code: "executable_identity_drift",
3199
- ...identity
3200
- };
3201
- }
3202
- const releaseOperation = action === "publish" ? "npm_publish" : void 0;
3203
3223
  let releaseGranted = false;
3204
3224
  let releaseContractId;
3205
3225
  if (releaseOperation && roots.releaseGate) {
3206
- const observed = await observePublishCandidate(resolution, roots, exec.signal, cwdOf(agent));
3207
- if (!observed) return {
3208
- status: "unavailable",
3209
- reason_code: "release_candidate_unobservable",
3210
- ...identity
3211
- };
3212
3226
  let decision;
3213
3227
  try {
3214
3228
  decision = await roots.releaseGate({
@@ -5486,6 +5500,7 @@ const Config = Schema.object({
5486
5500
  hostLockPolicy: Schema.string(),
5487
5501
  hostLockRuntimeRoot: Schema.string(),
5488
5502
  hostLockProfileRoot: Schema.string(),
5503
+ hostLockTrust: Schema.string(),
5489
5504
  hostLockPackages: Schema.array(Schema.object({
5490
5505
  name: Schema.string().required(),
5491
5506
  version: Schema.string(),
@@ -5520,9 +5535,11 @@ function resolveConfig(config) {
5520
5535
  for (const key of [
5521
5536
  "hostLockPolicy",
5522
5537
  "hostLockRuntimeRoot",
5523
- "hostLockProfileRoot"
5538
+ "hostLockProfileRoot",
5539
+ "hostLockTrust"
5524
5540
  ]) if (config[key] !== void 0 && (typeof config[key] !== "string" || !config[key])) throw new TypeError(`${key} must be a non-empty string`);
5525
5541
  return {
5542
+ ...typeof config.hostLockTrust === "string" ? { hostLockTrust: config.hostLockTrust } : {},
5526
5543
  ...typeof config.hostLockPolicy === "string" ? { hostLockPolicy: config.hostLockPolicy } : {},
5527
5544
  ...typeof config.hostLockRuntimeRoot === "string" ? { hostLockRuntimeRoot: config.hostLockRuntimeRoot } : {},
5528
5545
  ...typeof config.hostLockProfileRoot === "string" ? { hostLockProfileRoot: config.hostLockProfileRoot } : {},
@@ -6107,8 +6124,9 @@ async function handleGuardTurnStopping(agent, runtime, access$1) {
6107
6124
  durable = false;
6108
6125
  }
6109
6126
  runtime.setDurability(durable);
6110
- runtime.sync();
6127
+ runtime.sync({ revalidateHostLock: true });
6111
6128
  if (!durable) return "boundary_flush_failed";
6129
+ const hostSupported = access$1.hostSupported && runtime.projection.hostStatus === "supported";
6112
6130
  const rootInstruction = latestRootInstruction(agent.session?.snapshotEvents?.() ?? []);
6113
6131
  if (rootInstruction !== void 0 && isRootPauseRequest(rootInstruction.text) && !runtime.projection.handledControlSeqs.has(rootInstruction.seq) && access$1.pauseAccess) {
6114
6132
  agent.session.append("user/message", createUserMessage({
@@ -6177,7 +6195,7 @@ async function handleGuardTurnStopping(agent, runtime, access$1) {
6177
6195
  return decision.reason ?? "protocol_correction_steer";
6178
6196
  }
6179
6197
  if (decision.reason === "no_progress_bounded_disarm") {
6180
- if (!access$1.goalAccess || !access$1.hostSupported) {
6198
+ if (!access$1.goalAccess || !hostSupported) {
6181
6199
  runtime.projection.integrity = "unknown";
6182
6200
  runtime.projection.integrityViolations.push("boundary_host_lock_unsupported");
6183
6201
  return "boundary_host_lock_unsupported";
@@ -6195,7 +6213,7 @@ async function handleGuardTurnStopping(agent, runtime, access$1) {
6195
6213
  const current = runtime.projection.boundaries.at(-1);
6196
6214
  const alreadyCurrent = current && isCurrentAcceptedBoundary(runtime.projection, current) && current.disposition === "user_wait" && current.qualificationIds.slice().sort().join(",") === waiting.join(",");
6197
6215
  if (waiting.length > 0 && !alreadyCurrent) {
6198
- if (!access$1.hostSupported) {
6216
+ if (!hostSupported) {
6199
6217
  runtime.projection.integrity = "unknown";
6200
6218
  runtime.projection.integrityViolations.push("boundary_host_lock_unsupported");
6201
6219
  return "boundary_host_lock_unsupported";
@@ -6212,15 +6230,17 @@ async function handleGuardTurnStopping(agent, runtime, access$1) {
6212
6230
  if (decision.reason !== "accepted_boundary_pending_effectuation") return decision.reason ?? "safe_yield_pending_preserved";
6213
6231
  const boundary = runtime.projection.boundaries.at(-1);
6214
6232
  if (!boundary || !isCurrentAcceptedBoundary(runtime.projection, boundary)) return "boundary_candidate_stale";
6215
- if (boundary.goalRef && (!access$1.goalAccess || !access$1.hostSupported)) {
6233
+ if (boundary.goalRef && (!access$1.goalAccess || !hostSupported)) {
6216
6234
  runtime.projection.integrity = "unknown";
6217
6235
  runtime.projection.integrityViolations.push("boundary_host_lock_unsupported");
6218
6236
  return "boundary_host_lock_unsupported";
6219
6237
  }
6220
- const requalify = boundary.disposition === "external_wait" ? async () => access$1.externalWaitCapability?.status === "supported" && boundary.qualificationIds.every((id) => {
6221
- const row = access$1.readExternalOperation(id);
6222
- return row?.status === "running" || row?.status === "pending";
6223
- }) : void 0;
6238
+ const requalify = boundary.disposition === "external_wait" ? async () => {
6239
+ return (access$1.refreshExternalWaitCapability?.() ?? access$1.externalWaitCapability)?.status === "supported" && boundary.qualificationIds.every((id) => {
6240
+ const row = access$1.readExternalOperation(id);
6241
+ return row?.status === "running" || row?.status === "pending";
6242
+ });
6243
+ } : void 0;
6224
6244
  const effect = await effectuateBoundary(boundary, {
6225
6245
  ...access$1.goalAccess ?? {
6226
6246
  get: async () => void 0,
@@ -6285,7 +6305,6 @@ function createRuntime(agent, config, hostLock = DEFAULT_HOST_LOCK, readGoalStat
6285
6305
  const persistenceCorrectionAttempts = projection.persistenceCorrectionAttempts;
6286
6306
  const rebuild = () => {
6287
6307
  const previousReleaseContracts = projection.releaseContracts.length;
6288
- if (refreshHostLock) hostLock = refreshHostLock();
6289
6308
  const header = session.header;
6290
6309
  const priorRecoveryDigest = projection.lastRecoveryDigest;
6291
6310
  const sessionHeader = sessionHeaderForDigest(session);
@@ -6372,11 +6391,33 @@ function createRuntime(agent, config, hostLock = DEFAULT_HOST_LOCK, readGoalStat
6372
6391
  observedCompactionSeq = derived.lastCompactionSeq;
6373
6392
  }
6374
6393
  };
6375
- const sync = () => {
6394
+ const entryStorage = new AsyncLocalStorage();
6395
+ const sync = (options) => {
6396
+ if (options?.revalidateHostLock && refreshHostLock) {
6397
+ const cell = entryStorage.getStore();
6398
+ if (cell && !cell.stale) hostLock = cell.lock;
6399
+ else {
6400
+ hostLock = refreshHostLock();
6401
+ if (cell) {
6402
+ cell.lock = hostLock;
6403
+ cell.stale = false;
6404
+ queueMicrotask(() => {
6405
+ cell.stale = true;
6406
+ });
6407
+ }
6408
+ }
6409
+ }
6376
6410
  rebuild();
6377
6411
  };
6412
+ const runHostLockEntry = async (operation) => {
6413
+ if (!refreshHostLock) return await operation();
6414
+ return await entryStorage.run({
6415
+ lock: void 0,
6416
+ stale: true
6417
+ }, async () => await operation());
6418
+ };
6378
6419
  const setEnabled = (_enabled) => {
6379
- rebuild();
6420
+ sync({ revalidateHostLock: true });
6380
6421
  };
6381
6422
  const setDurability = (confirmed) => {
6382
6423
  durabilityConfirmed = confirmed;
@@ -6413,6 +6454,7 @@ function createRuntime(agent, config, hostLock = DEFAULT_HOST_LOCK, readGoalStat
6413
6454
  return [...pendingRecoveryCauses];
6414
6455
  },
6415
6456
  sync,
6457
+ runHostLockEntry,
6416
6458
  setEnabled,
6417
6459
  setDurability,
6418
6460
  markRecoveryNeeded,
@@ -6434,18 +6476,21 @@ function isDelegatedSession(session) {
6434
6476
  return header?.origin === "subagent" || typeof header?.delegationDepth === "number" && header.delegationDepth > 0 || typeof header?.parentSession === "string";
6435
6477
  }
6436
6478
  /** Never reinterpret a legacy injected snapshot as freshly accepted core/v1. */
6437
- function revalidateCoreLock(config, expected) {
6479
+ function revalidateCoreLock(config, expected, providedSession) {
6438
6480
  if (config.hostLockPolicy !== "dsh-core/v1" || !config.hostLockRuntimeRoot || !config.hostLockProfileRoot) return {
6439
6481
  ...expected,
6440
6482
  status: "unavailable",
6441
6483
  goalAvailable: false,
6442
6484
  reasonCode: "host_lock_migration_required"
6443
6485
  };
6486
+ const session = providedSession ?? createHostAuditSession();
6444
6487
  try {
6445
- const actual = evaluateHostLock(readActiveHostGraph(config.hostLockRuntimeRoot, config.hostLockProfileRoot), {
6488
+ const runtimeRoot = session.realpath(config.hostLockRuntimeRoot);
6489
+ const profileRoot = session.realpath(config.hostLockProfileRoot);
6490
+ const actual = evaluateActiveHostLock(runtimeRoot, profileRoot, {
6446
6491
  platform: config.hostLockPlatform,
6447
6492
  profileKind: config.hostLockProfile
6448
- });
6493
+ }, session, config.hostLockTrust);
6449
6494
  if (actual.status !== "supported") return actual;
6450
6495
  if (actual.digest !== expected.digest) return {
6451
6496
  ...actual,
@@ -6453,13 +6498,7 @@ function revalidateCoreLock(config, expected) {
6453
6498
  goalAvailable: false,
6454
6499
  reasonCode: "host_lock_installed_graph_drift"
6455
6500
  };
6456
- if (!auditedHostImplementation(config.hostLockRuntimeRoot, config.hostLockProfileRoot)) return {
6457
- ...actual,
6458
- status: "unsupported",
6459
- goalAvailable: false,
6460
- reasonCode: "host_lock_installed_graph_drift"
6461
- };
6462
- const audited = auditedForegroundRenderers(config.hostLockRuntimeRoot, config.hostLockProfileRoot);
6501
+ const audited = auditedForegroundRenderers(runtimeRoot, profileRoot, session);
6463
6502
  return audited.length ? {
6464
6503
  ...actual,
6465
6504
  auditedForegroundRenderers: audited,
@@ -6481,7 +6520,8 @@ function registerPassiveHostWorkdirObserver(agent, hostLockAtCall, attestedRoute
6481
6520
  const pre = agent.ctx.on("tools/pre-execute", async (exec, next) => {
6482
6521
  if (exec.agent === agent && (exec.name === "bash" || exec.name === "pwsh")) try {
6483
6522
  const policy = agent.ctx.get("sandboxPolicy");
6484
- const receipt = captureHostWorkdir(agent.session, exec, hostLockAtCall(), policy, await attestedRouteAtCall(exec.name, agent.ctx.get("shell"), policy), sourcedRootAtCall?.(exec) ?? null, SESSION_FORMAT_VERSION);
6523
+ const audit = createHostAuditSession();
6524
+ const receipt = captureHostWorkdir(agent.session, exec, hostLockAtCall(audit), policy, await attestedRouteAtCall(exec.name, agent.ctx.get("shell"), policy, audit), sourcedRootAtCall?.(exec) ?? null, SESSION_FORMAT_VERSION);
6485
6525
  if (receipt) pending.set(exec, receipt);
6486
6526
  } catch {}
6487
6527
  return next();
@@ -6515,13 +6555,14 @@ function registerPassiveHostWorkdirObserver(agent, hostLockAtCall, attestedRoute
6515
6555
  }
6516
6556
  function apply(ctx, rawConfig = {}, seams = {}) {
6517
6557
  const config = resolveConfig(rawConfig);
6518
- const installedHostLock = seams.hostLock ?? evaluateHostLock(config.hostLockPackages ?? [], {
6558
+ const installedHostLock = seams.hostLock ?? evaluateConfiguredHostLock(config.hostLockPackages ?? [], {
6519
6559
  platform: config.hostLockPlatform,
6520
6560
  profileKind: config.hostLockProfile
6521
- });
6561
+ }, config.hostLockTrust, config.hostLockProfileRoot);
6522
6562
  const runtimes = /* @__PURE__ */ new Map();
6523
6563
  const privateLedgerRoot = seams.privateLedgerRoot ?? resolvePrivateLedgerRoot(void 0, process.env.DSH_HOME, homedir());
6524
6564
  const hostLocks = /* @__PURE__ */ new Map();
6565
+ const qualifiedGoalService = (agent) => (hostLocks.get(agent) ?? installedHostLock).goalQualificationFailure ? void 0 : optionalGoalService(ctx, agent);
6525
6566
  const ledgerContext = (agent, fallback = installedHostLock) => ({
6526
6567
  sessionId: String(agent.session.id),
6527
6568
  sessionHeader: structuredClone(agent.session.header),
@@ -6542,19 +6583,25 @@ function apply(ctx, rawConfig = {}, seams = {}) {
6542
6583
  ctx.on("agent/disposed", ({ agent }) => {
6543
6584
  detach(agent);
6544
6585
  });
6586
+ /** One full host-lock validation for the named agent, recorded as the
6587
+ * agent's current authority. Every fresh-validation entry funnels here. */
6588
+ const fullHostLockValidation = () => {
6589
+ const evaluated = revalidateCoreLock(config, installedHostLock);
6590
+ seams.onHostLockValidation?.();
6591
+ return evaluated;
6592
+ };
6593
+ const refreshAgentHostLock = (agent) => {
6594
+ const current = bindLiveGoalCapability(seams.hostLock ?? fullHostLockValidation(), Boolean(qualifiedGoalService(agent)) && hasPinnedUpdateGoalTool(agent));
6595
+ hostLocks.set(agent, current);
6596
+ return current;
6597
+ };
6545
6598
  const ensure = (agent) => {
6546
6599
  let runtime = runtimes.get(agent);
6547
6600
  if (!runtime) {
6548
- const goals = optionalGoalService(ctx, agent);
6549
- const refreshHostLock = () => {
6550
- const current = bindLiveGoalCapability(seams.hostLock ?? revalidateCoreLock(config, installedHostLock), Boolean(goals) && hasPinnedUpdateGoalTool(agent));
6551
- hostLocks.set(agent, current);
6552
- return current;
6553
- };
6554
- const agentHostLock = refreshHostLock();
6555
- runtime = createRuntime(agent, config, agentHostLock, goals ? () => goals.get(agent) : void 0, refreshHostLock, privateLedgerRoot ? () => readPrivateLedger(privateLedgerRoot, ledgerContext(agent, agentHostLock)) : void 0, privateLedgerRoot ? () => initializePrivateLedger(privateLedgerRoot, ledgerContext(agent, agentHostLock)) : void 0);
6601
+ const goals = qualifiedGoalService(agent);
6602
+ const agentHostLock = refreshAgentHostLock(agent);
6603
+ runtime = createRuntime(agent, config, agentHostLock, goals ? () => goals.get(agent) : void 0, () => refreshAgentHostLock(agent), privateLedgerRoot ? () => readPrivateLedger(privateLedgerRoot, ledgerContext(agent, agentHostLock)) : void 0, privateLedgerRoot ? () => initializePrivateLedger(privateLedgerRoot, ledgerContext(agent, agentHostLock)) : void 0);
6556
6604
  runtimes.set(agent, runtime);
6557
- hostLocks.set(agent, agentHostLock);
6558
6605
  }
6559
6606
  return runtime;
6560
6607
  };
@@ -6585,7 +6632,12 @@ function apply(ctx, rawConfig = {}, seams = {}) {
6585
6632
  runtime.projection.lastRecoveryDigest = void 0;
6586
6633
  runtime.markRecoveryNeeded(source === "resume" ? "resume" : "compaction");
6587
6634
  }
6588
- own(registerPassiveHostWorkdirObserver(agent, () => seams.hostLock ?? revalidateCoreLock(config, installedHostLock), (tool, provider, policy) => config.hostLockRuntimeRoot && config.hostLockProfileRoot ? auditedDefaultWorkdirProvider(config.hostLockRuntimeRoot, config.hostLockProfileRoot, tool, provider, policy) : false, (exec) => {
6635
+ own(registerPassiveHostWorkdirObserver(agent, (audit) => {
6636
+ if (seams.hostLock) return seams.hostLock;
6637
+ const evaluated = revalidateCoreLock(config, installedHostLock, audit);
6638
+ seams.onHostLockValidation?.();
6639
+ return evaluated;
6640
+ }, (tool, provider, policy, audit) => config.hostLockRuntimeRoot && config.hostLockProfileRoot ? auditedDefaultWorkdirProvider(config.hostLockRuntimeRoot, config.hostLockProfileRoot, tool, provider, policy, audit) : false, (exec) => {
6589
6641
  runtime.sync();
6590
6642
  return sourcedNamedTestRoot(runtime.projection, agent.session, exec.arguments);
6591
6643
  }));
@@ -6600,7 +6652,7 @@ function apply(ctx, rawConfig = {}, seams = {}) {
6600
6652
  runtime.setDurability(durable);
6601
6653
  runtime.sync();
6602
6654
  return durable;
6603
- }));
6655
+ }, () => runtime.sync({ revalidateHostLock: true })));
6604
6656
  ownedTools.register(createBoundaryTool(() => runtime.projection, async () => {
6605
6657
  const durable = await ctx.sessions.flush(agent.session);
6606
6658
  runtime.setDurability(durable);
@@ -6615,11 +6667,17 @@ function apply(ctx, rawConfig = {}, seams = {}) {
6615
6667
  runtime.sync();
6616
6668
  return durable;
6617
6669
  };
6670
+ const hostCapabilityFromCache = (action) => createHostCapabilityEvaluator(hostLocks.get(agent) ?? installedHostLock)(action);
6618
6671
  const evidenceOptions = {
6619
- hostCapability: createHostCapabilityEvaluator(hostLocks.get(agent) ?? installedHostLock),
6672
+ hostCapability: hostCapabilityFromCache,
6620
6673
  ...seams.commandRunner ? { commandRunner: seams.commandRunner } : {},
6621
6674
  ...seams.fetcher ? { fetcher: seams.fetcher } : {},
6675
+ ...seams.readExecutableIdentity ? { readExecutableIdentity: seams.readExecutableIdentity } : {},
6622
6676
  ...seams.allowLoopbackHttpRegistry ? { allowLoopbackHttpRegistry: true } : {},
6677
+ preEffectVeto: () => {
6678
+ runtime.sync({ revalidateHostLock: true });
6679
+ return runtime.projection.hostStatus === "supported";
6680
+ },
6623
6681
  prepareMutation: async (toolAgent) => {
6624
6682
  if (toolAgent.session !== agent.session) return false;
6625
6683
  const durable = await ctx.sessions.flush(agent.session);
@@ -6628,20 +6686,14 @@ function apply(ctx, rawConfig = {}, seams = {}) {
6628
6686
  return durable;
6629
6687
  },
6630
6688
  authorizeMutation: (request) => {
6631
- runtime.sync();
6689
+ runtime.sync({ revalidateHostLock: true });
6632
6690
  return authorizeMutationFromProjection(runtime.projection, request);
6633
6691
  },
6634
6692
  marketOrigin: optionalMarketOrigin(ctx, agent),
6635
6693
  hasRestartIntent: (resolutionCallId, serviceId, preGeneration) => hasPrivateRestartIntent(readPrivateLedger(privateLedgerRoot, ledgerContext(agent)), resolutionCallId, serviceId, preGeneration),
6636
6694
  releaseGate: async (request) => {
6637
- runtime.sync();
6638
- const projection = runtime.projection;
6639
- if (!(projection.policy === "release" || projection.releaseContracts.length > 0)) return {
6640
- status: "denied",
6641
- reasonCode: "release_contract_not_adopted"
6642
- };
6643
6695
  const observed = { ...request.observed };
6644
- const declaredRef = releaseContractFor(projection, request.operation)?.candidate.ref;
6696
+ const declaredRef = releaseContractFor(runtime.projection, request.operation)?.candidate.ref;
6645
6697
  if (declaredRef !== void 0 && observed.ref === void 0) {
6646
6698
  const refSha = await resolveAuditedRef(sessionCwd(runtime.session), declaredRef, evidenceOptions, requestSignal());
6647
6699
  if (refSha !== void 0) {
@@ -6649,6 +6701,16 @@ function apply(ctx, rawConfig = {}, seams = {}) {
6649
6701
  observed.refSha = refSha;
6650
6702
  }
6651
6703
  }
6704
+ runtime.sync({ revalidateHostLock: true });
6705
+ const projection = runtime.projection;
6706
+ if (!(projection.policy === "release" || projection.releaseContracts.length > 0)) return {
6707
+ status: "denied",
6708
+ reasonCode: "release_contract_not_adopted"
6709
+ };
6710
+ if (projection.hostStatus !== "supported") return {
6711
+ status: "denied",
6712
+ reasonCode: projection.hostReasonCode ?? "host_lock_unavailable"
6713
+ };
6652
6714
  const decision = releasePreEffectDecision(projection, {
6653
6715
  operation: request.operation,
6654
6716
  observed,
@@ -6723,7 +6785,17 @@ function apply(ctx, rawConfig = {}, seams = {}) {
6723
6785
  fs: ctx.fs,
6724
6786
  flush: (session) => ctx.sessions.flush(session)
6725
6787
  }));
6726
- ownedTools.register(createActionTool(evidenceOptions));
6788
+ const actionTool = createActionTool({
6789
+ ...evidenceOptions,
6790
+ hostCapability: (action) => {
6791
+ runtime.sync({ revalidateHostLock: true });
6792
+ return createHostCapabilityEvaluator(hostLocks.get(agent) ?? installedHostLock)(action);
6793
+ }
6794
+ });
6795
+ ownedTools.register({
6796
+ ...actionTool,
6797
+ execute: (...args) => runtime.runHostLockEntry(() => actionTool.execute(...args))
6798
+ });
6727
6799
  ownedTools.register(createPrepareTool({
6728
6800
  getProjection: () => runtime.projection,
6729
6801
  hostCapability: (action) => {
@@ -6765,7 +6837,10 @@ function apply(ctx, rawConfig = {}, seams = {}) {
6765
6837
  })
6766
6838
  }));
6767
6839
  ownedTools.register(createExternalOperationTool((id, toolAgent) => readExternalOperation(ctx, toolAgent, id), () => evaluateExternalWaitCapability(hostLocks.get(agent) ?? installedHostLock)));
6768
- ownedTools.guard((exec) => goalCompletionDenial(runtime.projection, exec.name, exec.arguments));
6840
+ ownedTools.guard((exec) => {
6841
+ if (exec.name === "update_goal" && exec.arguments?.action === "complete" && runtime.projection.enabled) runtime.sync({ revalidateHostLock: true });
6842
+ return goalCompletionDenial(runtime.projection, exec.name, exec.arguments);
6843
+ });
6769
6844
  } catch (error) {
6770
6845
  detach(agent);
6771
6846
  throw error;
@@ -6835,11 +6910,12 @@ function apply(ctx, rawConfig = {}, seams = {}) {
6835
6910
  });
6836
6911
  ctx.on("agent/turn-stopping", async ({ agent }) => {
6837
6912
  const runtime = ensure(agent);
6838
- const goals = optionalGoalService(ctx, agent);
6913
+ const goals = qualifiedGoalService(agent);
6839
6914
  await handleGuardTurnStopping(agent, runtime, {
6840
6915
  flush: () => ctx.sessions.flush(agent.session),
6841
6916
  hostSupported: runtime.projection.hostStatus === "supported",
6842
6917
  externalWaitCapability: evaluateExternalWaitCapability(hostLocks.get(agent) ?? installedHostLock),
6918
+ refreshExternalWaitCapability: () => evaluateExternalWaitCapability(hostLocks.get(agent) ?? installedHostLock),
6843
6919
  ...goals ? { goalAccess: {
6844
6920
  get: async () => normalizeGoalState(await goals.get(agent)),
6845
6921
  disarm: async () => normalizeGoalState(await goals.disarm(agent))
@@ -7065,4 +7141,4 @@ async function replayRawV2(input) {
7065
7141
  }
7066
7142
 
7067
7143
  //#endregion
7068
- export { ACTION_MANIFEST, ACTION_MANIFEST_VERSION, ACTIVE_HOST_COHORT_ID, ACTIVE_HOST_COHORT_IDS, ACTIVE_HOST_LAUNCHER_VERSION, BASE_HOST_PACKAGES, BOUNDARY_RECORD_PREFIX, BOUNDED_ARTIFACT_TYPES, CAPTURE_V042_NOTICE, CERTIFICATE_VERSION, CERTIFICATE_VERSION_V2, CLEANUP_CONDITION_RULE, CLEANUP_CONDITION_RULE_COMPACT, CLEANUP_CONDITION_RULE_SHORT, COMMAND_SURFACE_MANIFEST, CONFIRM_LINE_PATTERN, CONTROL_RECORD_PREFIX, Config, DEFAULT_DELEGATION_TOOL_NAMES, DEFAULT_HOST_LOCK, DEFAULT_RECOVERY_CHAR_BUDGET, DEPENDENCY_FREE_ONLY_CONDITION, EXPECTED_HOST_PACKAGES, FIRST_STEP_GUIDANCE, GIT_COMMAND_MANIFEST_IDS, GIT_COMMAND_TEMPLATES, GOAL_HOST_PACKAGES, GRANTED_QUALIFICATION, HOST_CAPABILITY_PACKAGE_GROUPS, HOST_COHORTS, HostProfileError, LATEST_SUPPORTED_HOST_VERSION, LEGACY_QUALIFICATION, MIN_RECOVERY_CHAR_BUDGET, MIN_SUPPORTED_HOST_VERSION, NO_PROGRESS_RECORD_PREFIX, NO_PROGRESS_TURNS_BEFORE_STOP, PROOF_CAPABILITY_MATRIX, PROOF_KINDS, PROOF_KINDS_V2, PROOF_MANIFEST_DOMAIN_V2, PROOF_PROTOCOL_VERSION, PROOF_PROTOCOL_VERSION_V2, PROTOCOL_V3_NOTICE, PROTOCOL_V4_NOTICE, PROTOCOL_V5_NOTICE, PROTOCOL_V6_NOTICE, RC017_RC2_HOST_PACKAGES, SEMANTIC_ACTIONS, SESSION_API_UNSUPPORTED, SESSION_EVENT_ENVELOPE_INVALID, STATEFUL_ACTIONS, STOP_PROTOCOL_VERSION, STOP_PROTOCOL_VERSION_V2, SUPPORTED_EVIDENCE_ADAPTERS, SUPPORTED_HOST_RANGE, SUPPORTED_HOST_VERSIONS, SessionApiError, V6_ORDINARY_COMPLETION_RULE, V6_ORDINARY_COMPLETION_RULE_COMPACT, V6_ORDINARY_COMPLETION_RULE_SHORT, actionCompatible, actionHasCertificationPath, actionVerbMatches, activeRendererModule, admissibleForRemoval, apply, applyUpgradeEligibility, assessmentAction, assessmentOutcomePredicate, auditedDefaultWorkdirHost, auditedDefaultWorkdirProvider, auditedForegroundRenderers, auditedHostImplementation, authorityCaptureCounts, availableBoundaryQualifications, bindExecutableIdentity, bindLiveGoalCapability, bindProofToProjection, bindProofV2ToProjection, bindingIndividuallyAccepted, bindingSatisfies, boundedArtifactChoiceMatches, canonicalArgvFromCommand, canonicalProjection, canonicalizePath, capabilityConsequence, capabilityFactOf, capabilityRemedyPhrase, captureClause, captureItem, carriesCleanupCondition, certifyCheckpoint, claimedBatchHasRealRootInput, clarifiedSpanOf, classifyClause, classifyCompletionClaim, classifyTaskIntent, classifyUserInteraction, clauseAsksOwnQuestion, clauseIsGoverned, clauseIsProtected, cleanupConditionFor, closingHint, combineHostPolicy, commitIndexSnapshotDigest, commitTreeSnapshotDigest, compareHostVersions, confirmRebind, createGitPrestateEnvelope, createProjection, createProofManifest, createProofManifestV2, currentActionBases, currentContractDigest, decideTurnBoundary, decideTurnStopping, decisionBoundaryKey, deriveItemDiagnosis, deriveProjection, digestStrings, effectuateBoundary, environmentDefaultRepositoryTarget, evaluateExternalWaitCapability, evaluateHostCapability, evaluateHostLock, evaluateMinimumHostVersion, evaluateToolSurfaceCapability, evidenceAvailabilityReason, evidenceCoverage, evidenceFromPersistedToolResult, evidenceMatchesItem, executeRevalidatedGitEffect, explanationHasActionResidue, extractArtifactPaths, extractMethod, extractOperation, extractTextContent, extractToolSubject, firstStepGuidance, firstStepGuidanceV6, gitCommandMatchesTarget, goalCompletionDenial, governedClauseRestrictsExecution, hasCurrentCertificate, hasOrderedCoordination, hasQuestionScope, hasWorkPredicate, hostLockContextFromComposedDump, hostLockRowsFromComposedDump, hostVersionFromPackages, inject, injectActiveProfileHostLock, inspectTargetHostGraph, interpretClause, interpretMessage, introducesActionClause, isCurrentAcceptedBoundary, isDeterministicCheck, isExecutableItem, isExplanationScope, isFrozenV042RebindResponse, isInformationalFragment, isInformationalMessage, isOpenObligation, isQuestionScopeNeedingReview, isRestatement, isRootPauseRequest, isRunExecutable, isStatefulAction, isVerifyingCapability, isWholeTaskCompletionClaim, itemDiagnosis, itemHoldsExecutionAuthority, kindOfScope, latestAssistantText, latestRootInstruction, legacyQuestionReadingIsInformational, legacyRecordsNeedingReview, lifecyclePhase, maskCodeSpans, maskQuotedSpans, name, namedActions, nativeFileTwoRole, normalizeClause, observeAssistantOutcome, openItems, opensConditionLead, opensWithDirective, packageRowsFromActiveGraph, packageRowsFromPnpmLock, parseConfirmationMessage, parseGitCommandManifest, parseHostVersion, parsePwshCommand, parseShellCommand, partialFailureOf, persistedToolResultStatus, presentExplanationHead, previewFirstStepInjection, progressFingerprint, projectCoreV2, projectSessionCoreV2, proofCapabilityReport, proofDigest, proofDigestV2, proofEvidenceConstraints, proofHostSurfacesOf, proofOperationMatches, proofV2Rejection, proposeRebind, proposeRebindOutcome, proposeRebindV042, qualificationOfClause, qualifyBoundary, questionHeadsClause, readActiveHostGraph, rebindAttemptKey, rebindResponse, recoveryDigest, recoveryTitle, relevantEvidence, removalIsComplete, removalIsPartiallyKnown, renderRecoveryPacket, replayRawV2, replayRebindResult, reportingHeadGoverns, requestedIdentityKey, requestedTargetAuthorizesMutation, requestedTargetMatchesResolved, requiredSubjectsOf, resolveActiveProfileHostLock, resolveInstalledHostLock, restatedContentOf, revalidateGitPrestate, rootLocatorFlavor, sanitizeClauseText, sanitizeUrl, satisfiesSupportedHostRange, scopeCoverageDigest, segmentAuthorityBlocks, segmentClauses, selectHostCohort, semanticActionFromCommand, semanticActionFromText, semanticActionOfScope, sessionQuery, sessionQueryV2, sha256, snapshotSessionEvents, splitTextFragments, statefulActionsOfScope, supersedeItem, testOutcomePredicate, v6CurrentRootBoundaries, v6TestPredicate, validateActionManifest, validateActionTarget, validateManifest, validateProofManifest, validateProofManifestV2, verbIsNegated, verifiedLinearCommitReadback, verifyComposedHostLockDump, withDurability };
7144
+ export { ACTION_MANIFEST, ACTION_MANIFEST_VERSION, ACTIVE_HOST_COHORT_ID, ACTIVE_HOST_COHORT_IDS, ACTIVE_HOST_LAUNCHER_VERSION, BASE_HOST_PACKAGES, BOUNDARY_RECORD_PREFIX, BOUNDED_ARTIFACT_TYPES, CAPTURE_V042_NOTICE, CERTIFICATE_VERSION, CERTIFICATE_VERSION_V2, CLEANUP_CONDITION_RULE, CLEANUP_CONDITION_RULE_COMPACT, CLEANUP_CONDITION_RULE_SHORT, COMMAND_SURFACE_MANIFEST, CONFIRM_LINE_PATTERN, CONTROL_RECORD_PREFIX, Config, DEFAULT_DELEGATION_TOOL_NAMES, DEFAULT_HOST_LOCK, DEFAULT_RECOVERY_CHAR_BUDGET, DEPENDENCY_FREE_ONLY_CONDITION, EXPECTED_HOST_PACKAGES, FIRST_STEP_GUIDANCE, GIT_COMMAND_MANIFEST_IDS, GIT_COMMAND_TEMPLATES, GOAL_HOST_PACKAGES, GRANTED_QUALIFICATION, HOST_CAPABILITY_PACKAGE_GROUPS, HOST_COHORTS, HOST_VALIDATED_VERSIONS, HostProfileError, HostTrustError, LATEST_TESTED_HOST_VERSION, LEGACY_QUALIFICATION, MIN_RECOVERY_CHAR_BUDGET, MIN_SUPPORTED_HOST_VERSION, NO_PROGRESS_RECORD_PREFIX, NO_PROGRESS_TURNS_BEFORE_STOP, PROOF_CAPABILITY_MATRIX, PROOF_KINDS, PROOF_KINDS_V2, PROOF_MANIFEST_DOMAIN_V2, PROOF_PROTOCOL_VERSION, PROOF_PROTOCOL_VERSION_V2, PROTOCOL_V3_NOTICE, PROTOCOL_V4_NOTICE, PROTOCOL_V5_NOTICE, PROTOCOL_V6_NOTICE, RC020_RC1_HOST_PACKAGES, SEMANTIC_ACTIONS, SESSION_API_UNSUPPORTED, SESSION_EVENT_ENVELOPE_INVALID, STATEFUL_ACTIONS, STOP_PROTOCOL_VERSION, STOP_PROTOCOL_VERSION_V2, SUPPORTED_EVIDENCE_ADAPTERS, SUPPORTED_HOST_RANGE, SUPPORTED_HOST_VERSIONS, SessionApiError, V6_ORDINARY_COMPLETION_RULE, V6_ORDINARY_COMPLETION_RULE_COMPACT, V6_ORDINARY_COMPLETION_RULE_SHORT, acquireHostTrust, actionCompatible, actionHasCertificationPath, actionVerbMatches, activeRendererModule, admissibleForRemoval, apply, applyUpgradeEligibility, assessmentAction, assessmentOutcomePredicate, auditedDefaultWorkdirHost, auditedDefaultWorkdirProvider, auditedForegroundRenderers, auditedHostImplementation, authorityCaptureCounts, availableBoundaryQualifications, bindExecutableIdentity, bindLiveGoalCapability, bindProofToProjection, bindProofV2ToProjection, bindingIndividuallyAccepted, bindingSatisfies, boundedArtifactChoiceMatches, canonicalArgvFromCommand, canonicalProjection, canonicalizePath, capabilityConsequence, capabilityFactOf, capabilityRemedyPhrase, captureClause, captureItem, carriesCleanupCondition, certifyCheckpoint, claimedBatchHasRealRootInput, clarifiedSpanOf, classifyClause, classifyCompletionClaim, classifyTaskIntent, classifyUserInteraction, clauseAsksOwnQuestion, clauseIsGoverned, clauseIsProtected, cleanupConditionFor, closingHint, combineHostPolicy, commitIndexSnapshotDigest, commitTreeSnapshotDigest, compareHostVersions, confirmRebind, createGitPrestateEnvelope, createProjection, createProofManifest, createProofManifestV2, currentActionBases, currentContractDigest, decideTurnBoundary, decideTurnStopping, decisionBoundaryKey, deriveItemDiagnosis, deriveProjection, digestStrings, effectuateBoundary, environmentDefaultRepositoryTarget, evaluateActiveHostLock, evaluateConfiguredHostLock, evaluateExternalWaitCapability, evaluateGraphDerivedHostLock, evaluateHostCapability, evaluateHostLock, evaluateMinimumHostVersion, evaluateToolSurfaceCapability, evidenceAvailabilityReason, evidenceCoverage, evidenceFromPersistedToolResult, evidenceMatchesItem, executeRevalidatedGitEffect, explanationHasActionResidue, extractArtifactPaths, extractMethod, extractOperation, extractTextContent, extractToolSubject, firstStepGuidance, firstStepGuidanceV6, gitCommandMatchesTarget, goalCompletionDenial, governedClauseRestrictsExecution, hasCurrentCertificate, hasOrderedCoordination, hasQuestionScope, hasWorkPredicate, hostLockContextFromComposedDump, hostLockRowsFromComposedDump, hostTrustDigest, hostVersionFromPackages, inject, injectActiveProfileHostLock, inspectTargetHostGraph, interpretClause, interpretMessage, introducesActionClause, isCurrentAcceptedBoundary, isDeterministicCheck, isExecutableItem, isExplanationScope, isFrozenV042RebindResponse, isInformationalFragment, isInformationalMessage, isOpenObligation, isQuestionScopeNeedingReview, isRestatement, isRootPauseRequest, isRunExecutable, isStatefulAction, isVerifyingCapability, isWholeTaskCompletionClaim, itemDiagnosis, itemHoldsExecutionAuthority, kindOfScope, latestAssistantText, latestRootInstruction, legacyQuestionReadingIsInformational, legacyRecordsNeedingReview, lifecyclePhase, maskCodeSpans, maskQuotedSpans, name, namedActions, nativeFileTwoRole, normalizeClause, observeAssistantOutcome, openItems, opensConditionLead, opensWithDirective, packageRowsFromActiveGraph, packageRowsFromPnpmLock, parseConfirmationMessage, parseGitCommandManifest, parseHostTrust, parseHostVersion, parsePwshCommand, parseShellCommand, partialFailureOf, persistedToolResultStatus, prepareActiveHostTrust, prepareTargetHostTrust, presentExplanationHead, previewFirstStepInjection, progressFingerprint, projectCoreV2, projectSessionCoreV2, proofCapabilityReport, proofDigest, proofDigestV2, proofEvidenceConstraints, proofHostSurfacesOf, proofOperationMatches, proofV2Rejection, proposeRebind, proposeRebindOutcome, proposeRebindV042, qualificationOfClause, qualifyBoundary, qualifyHostTrust, questionHeadsClause, readActiveHostGraph, rebindAttemptKey, rebindResponse, recoveryDigest, recoveryTitle, registryArchiveFiles, registryArchiveModules, relevantEvidence, removalIsComplete, removalIsPartiallyKnown, renderRecoveryPacket, replayRawV2, replayRebindResult, reportingHeadGoverns, requestedIdentityKey, requestedTargetAuthorizesMutation, requestedTargetMatchesResolved, requiredSubjectsOf, resolveActiveProfileHostLock, resolveInstalledHostLock, restatedContentOf, revalidateGitPrestate, rootLocatorFlavor, sanitizeClauseText, sanitizeUrl, satisfiesSupportedHostRange, scopeCoverageDigest, segmentAuthorityBlocks, segmentClauses, selectHostCohort, semanticActionFromCommand, semanticActionFromText, semanticActionOfScope, sessionQuery, sessionQueryV2, sha256, snapshotSessionEvents, splitTextFragments, statefulActionsOfScope, supersedeItem, testOutcomePredicate, v6CurrentRootBoundaries, v6TestPredicate, validateActionManifest, validateActionTarget, validateManifest, validateProofManifest, validateProofManifestV2, verbIsNegated, verifiedLinearCommitReadback, verifyComposedHostLockDump, withDurability };