@sema-agent/core 7.71.1 → 7.73.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +500 -0
- package/dist/agents/cross-session-ref.d.ts +2 -2
- package/dist/agents/cross-session-ref.js +7 -2
- package/dist/agents/inherited-tool-pool.d.ts +30 -2
- package/dist/agents/inherited-tool-pool.js +53 -7
- package/dist/agents/parked-resume-drive.d.ts +10 -0
- package/dist/agents/parked-resume-drive.js +9 -0
- package/dist/agents/retain-ledger.d.ts +3 -0
- package/dist/agents/send-message-tool.js +7 -2
- package/dist/agents/send-user-message-tool.d.ts +12 -0
- package/dist/agents/send-user-message-tool.js +67 -0
- package/dist/agents/subagent-steps.d.ts +9 -0
- package/dist/agents/subagent-steps.js +38 -0
- package/dist/agents/subagent.d.ts +2 -0
- package/dist/agents/subagent.js +47 -12
- package/dist/agents/verify.js +23 -7
- package/dist/agents/yield-adoption.js +3 -1
- package/dist/brain/anthropic.js +14 -9
- package/dist/brain/open-responses.js +4 -5
- package/dist/brain/openai.js +30 -23
- package/dist/brain/stream-engine.js +159 -151
- package/dist/core/a2a.d.ts +24 -3
- package/dist/core/a2a.js +27 -8
- package/dist/core/actions-digest.d.ts +43 -0
- package/dist/core/actions-digest.js +22 -0
- package/dist/core/agent-state.d.ts +28 -7
- package/dist/core/agent-state.js +19 -6
- package/dist/core/allow-entry.js +3 -3
- package/dist/core/approval-object.d.ts +7 -3
- package/dist/core/approval-object.js +30 -9
- package/dist/core/auto-mode.d.ts +7 -9
- package/dist/core/auto-mode.js +114 -8
- package/dist/core/checkpoint-features.d.ts +16 -5
- package/dist/core/checkpoint-features.js +35 -6
- package/dist/core/checkpoint-rekey.d.ts +1 -1
- package/dist/core/checkpoint-rekey.js +6 -1
- package/dist/core/checkpoint-requirements.d.ts +23 -3
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-row-verdict.d.ts +1 -1
- package/dist/core/checkpoint-row-verdict.js +10 -4
- package/dist/core/checkpoint-store.d.ts +24 -2
- package/dist/core/checkpoint-store.js +1 -0
- package/dist/core/child-clamp-seats.d.ts +15 -0
- package/dist/core/child-clamp-seats.js +15 -0
- package/dist/core/delegation-frames.d.ts +1 -0
- package/dist/core/delegation-frames.js +1 -1
- package/dist/core/effective-path-target.d.ts +19 -0
- package/dist/core/effective-path-target.js +95 -38
- package/dist/core/engine-capabilities.d.ts +5 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +34 -23
- package/dist/core/engine-version.js +1 -1
- package/dist/core/entries-not-applied.d.ts +19 -7
- package/dist/core/entries-not-applied.js +33 -1
- package/dist/core/file-history-store.d.ts +15 -4
- package/dist/core/file-history-store.js +53 -23
- package/dist/core/gate-fold.js +3 -1
- package/dist/core/governance-codes.d.ts +10 -1
- package/dist/core/governance-codes.js +17 -5
- package/dist/core/hooks.d.ts +3 -0
- package/dist/core/hooks.js +1 -0
- package/dist/core/host-instance.d.ts +23 -0
- package/dist/core/host-instance.js +69 -0
- package/dist/core/instruction-preview.d.ts +63 -0
- package/dist/core/instruction-preview.js +406 -0
- package/dist/core/judged-read.d.ts +57 -0
- package/dist/core/judged-read.js +1 -0
- package/dist/core/leg-budget.d.ts +26 -0
- package/dist/core/leg-budget.js +9 -0
- package/dist/core/leg-identity.d.ts +51 -1
- package/dist/core/leg-identity.js +45 -2
- package/dist/core/manager-launch-check.d.ts +48 -0
- package/dist/core/manager-launch-check.js +64 -0
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-host-seat.d.ts +5 -0
- package/dist/core/mcp-host-seat.js +7 -1
- package/dist/core/mcp-injection-drop.d.ts +20 -10
- package/dist/core/mcp-injection-drop.js +9 -3
- package/dist/core/mcp-server-spec.d.ts +2 -1
- package/dist/core/mcp.js +3 -1
- package/dist/core/member-outcome.d.ts +3 -2
- package/dist/core/member-outcome.js +1 -1
- package/dist/core/memory-engine/deletion-record.d.ts +46 -0
- package/dist/core/memory-engine/deletion-record.js +96 -0
- package/dist/core/memory-engine/engine.js +24 -16
- package/dist/core/memory-engine/file-backend.js +7 -5
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/index.js +1 -1
- package/dist/core/memory-engine/layout.js +6 -4
- package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
- package/dist/core/memory-engine/projection-ledger.js +1 -1
- package/dist/core/memory-engine/scope-contract.d.ts +69 -11
- package/dist/core/memory-engine/scope-contract.js +99 -34
- package/dist/core/memory-engine/sync-client.js +26 -6
- package/dist/core/memory-engine/sync.d.ts +20 -2
- package/dist/core/memory-engine/sync.js +18 -17
- package/dist/core/mode-policy.d.ts +21 -6
- package/dist/core/mode-policy.js +15 -6
- package/dist/core/mounted-mcp.d.ts +7 -2
- package/dist/core/mounted-mcp.js +10 -1
- package/dist/core/own-property-receipt.js +11 -4
- package/dist/core/param-rule-reach.d.ts +8 -3
- package/dist/core/param-rule-reach.js +9 -1
- package/dist/core/parent-spec-seat.d.ts +13 -1
- package/dist/core/parent-spec-seat.js +18 -0
- package/dist/core/peer-registration.d.ts +52 -0
- package/dist/core/peer-registration.js +37 -0
- package/dist/core/peer-seat.d.ts +3 -1
- package/dist/core/peer-seat.js +3 -3
- package/dist/core/peer-task-store.d.ts +365 -0
- package/dist/core/peer-task-store.js +682 -0
- package/dist/core/permission-rule-consent.js +6 -11
- package/dist/core/permission-rule-model.d.ts +27 -0
- package/dist/core/permission-rule-model.js +34 -6
- package/dist/core/permission-rule-provider.d.ts +35 -33
- package/dist/core/permission-rule-provider.js +38 -295
- package/dist/core/permission-rule-store.d.ts +181 -8
- package/dist/core/permission-rule-store.js +420 -17
- package/dist/core/permission-rule-sync.js +15 -1
- package/dist/core/project-seat.d.ts +55 -0
- package/dist/core/project-seat.js +96 -0
- package/dist/core/protocol-http-auth.d.ts +3 -2
- package/dist/core/protocol-http-auth.js +26 -18
- package/dist/core/remote-env.d.ts +4 -4
- package/dist/core/retired-keys.js +1 -0
- package/dist/core/rule-offer-read.d.ts +1 -1
- package/dist/core/rule-offer-read.js +32 -4
- package/dist/core/run-ledger-seat.d.ts +66 -0
- package/dist/core/run-ledger-seat.js +70 -0
- package/dist/core/run-ledger.d.ts +332 -0
- package/dist/core/run-ledger.js +550 -0
- package/dist/core/runner/chain-mismatch.d.ts +32 -0
- package/dist/core/runner/chain-mismatch.js +29 -0
- package/dist/core/runner/changes-history.d.ts +1 -0
- package/dist/core/runner/changes-history.js +2 -2
- package/dist/core/runner/checkpoint-scope.d.ts +13 -3
- package/dist/core/runner/checkpoint-scope.js +12 -4
- package/dist/core/runner/construction-doors.js +6 -0
- package/dist/core/runner/contracts.d.ts +22 -3
- package/dist/core/runner/delegation-owner.d.ts +30 -0
- package/dist/core/runner/delegation-owner.js +20 -4
- package/dist/core/runner/file-history-restore.d.ts +3 -1
- package/dist/core/runner/file-history-restore.js +9 -6
- package/dist/core/runner/finish-reason-seat.js +4 -2
- package/dist/core/runner/leg-frame.js +3 -0
- package/dist/core/runner/loaded-skills.d.ts +2 -0
- package/dist/core/runner/loaded-skills.js +10 -0
- package/dist/core/runner/nested-memory-lane.d.ts +22 -5
- package/dist/core/runner/nested-memory-lane.js +91 -30
- package/dist/core/runner/person-path-rows.d.ts +23 -20
- package/dist/core/runner/person-path-rows.js +82 -18
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +105 -90
- package/dist/core/runner/prepare-config-doors.d.ts +1 -0
- package/dist/core/runner/prepare-config-doors.js +5 -3
- package/dist/core/runner/prepare-context-lane.js +1 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
- package/dist/core/runner/prepare-delegation-surface.js +6 -0
- package/dist/core/runner/prepare-execution-env.d.ts +3 -3
- package/dist/core/runner/prepare-file-history.js +1 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +10 -2
- package/dist/core/runner/prepare-hands-readface.js +36 -22
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -5
- package/dist/core/runner/prepare-inherited-gate.js +14 -6
- package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -2
- package/dist/core/runner/prepare-memory-engine-session.js +2 -2
- package/dist/core/runner/prepare-memory.js +3 -15
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +3 -7
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -0
- package/dist/core/runner/prepare-protocol-tools.js +2 -2
- package/dist/core/runner/prepare-run-refs.d.ts +1 -1
- package/dist/core/runner/prepare-run-refs.js +3 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
- package/dist/core/runner/prepare-suspend-saga.js +4 -2
- package/dist/core/runner/prepare-task.js +50 -37
- package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
- package/dist/core/runner/prepare-turn-wiring.js +2 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -1
- package/dist/core/runner/prepare-wiring-manifest.js +8 -4
- package/dist/core/runner/read-session-changes.js +1 -1
- package/dist/core/runner/resume-apply.js +11 -5
- package/dist/core/runner/resume-checkpoint-screen.d.ts +8 -7
- package/dist/core/runner/resume-checkpoint-screen.js +7 -6
- package/dist/core/runner/resume-review-outcome.d.ts +3 -0
- package/dist/core/runner/resume-review-outcome.js +24 -1
- package/dist/core/runner/rewind-files.js +3 -2
- package/dist/core/runner/run-harness-handlers.js +3 -0
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +9 -2
- package/dist/core/runner/run-notification-lane.js +20 -1
- package/dist/core/runner/run-settle-and-teardown.js +21 -12
- package/dist/core/runner/run-stop-and-final-verify.js +6 -0
- package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
- package/dist/core/runner/runtask.d.ts +6 -2
- package/dist/core/runner/runtask.js +21 -9
- package/dist/core/runner/shell-env-withheld.d.ts +3 -2
- package/dist/core/runner/shell-env-withheld.js +1 -2
- package/dist/core/runner/stop-tail-notice.d.ts +10 -2
- package/dist/core/runner/stop-tail-notice.js +9 -2
- package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
- package/dist/core/runner/stream-settle-backstop.js +1 -0
- package/dist/core/runner/task-start-doors.js +6 -3
- package/dist/core/runner/terminal-account.d.ts +10 -1
- package/dist/core/runner/terminal-account.js +23 -3
- package/dist/core/runner/tool-face-overlay.d.ts +2 -11
- package/dist/core/runner/tool-face-overlay.js +39 -0
- package/dist/core/runner/trim-stretch.js +7 -2
- package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
- package/dist/core/runner-deps.d.ts +13 -10
- package/dist/core/scheduler.d.ts +47 -7
- package/dist/core/scheduler.js +19 -7
- package/dist/core/secret-env.d.ts +60 -37
- package/dist/core/secret-env.js +45 -48
- package/dist/core/sensitive-path-policy.js +14 -7
- package/dist/core/session-checkout.d.ts +3 -0
- package/dist/core/session-checkout.js +1 -0
- package/dist/core/session-store.d.ts +12 -6
- package/dist/core/session-store.js +26 -6
- package/dist/core/session.d.ts +31 -8
- package/dist/core/shell-read-silence.js +1 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +17 -0
- package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
- package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
- package/dist/core/store-contracts/session-store-contract.js +87 -3
- package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
- package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
- package/dist/core/task-event.d.ts +11 -3
- package/dist/core/task-notification.d.ts +97 -10
- package/dist/core/task-notification.js +129 -5
- package/dist/core/task-registry-shared.d.ts +12 -1
- package/dist/core/task-registry-shared.js +3 -1
- package/dist/core/task-registry-workflow.d.ts +1 -1
- package/dist/core/task-registry-workflow.js +9 -1
- package/dist/core/task-registry.d.ts +39 -2
- package/dist/core/task-registry.js +76 -12
- package/dist/core/task-result.d.ts +13 -0
- package/dist/core/task-spec-members.d.ts +3 -1
- package/dist/core/task-spec-members.js +11 -3
- package/dist/core/task-spec.d.ts +57 -23
- package/dist/core/tool-catalog-entries.js +4 -0
- package/dist/core/tool-face-reader.js +1 -1
- package/dist/core/tool-face.d.ts +7 -0
- package/dist/core/tool-face.js +1 -0
- package/dist/core/tool-mount-facts.d.ts +5 -3
- package/dist/core/tool-mount-facts.js +4 -3
- package/dist/core/tool-mount-plan.d.ts +7 -3
- package/dist/core/tool-mount-plan.js +11 -5
- package/dist/core/tool-mount-static.d.ts +2 -2
- package/dist/core/tool-mount-static.js +28 -14
- package/dist/core/tool-registry.d.ts +33 -1
- package/dist/core/tool-registry.js +33 -0
- package/dist/core/tool-result-store.d.ts +19 -2
- package/dist/core/tool-result-store.js +51 -2
- package/dist/core/tool-roster.d.ts +16 -0
- package/dist/core/tool-roster.js +6 -0
- package/dist/core/tool-spec.d.ts +13 -4
- package/dist/core/tools.d.ts +6 -0
- package/dist/core/tools.js +1 -1
- package/dist/core/user-attachment.d.ts +5 -1
- package/dist/core/user-attachment.js +14 -7
- package/dist/core/wiring-manifest.d.ts +89 -29
- package/dist/core/wiring-manifest.js +44 -4
- package/dist/core/workflow-journal-store.d.ts +53 -10
- package/dist/core/workflow-journal-store.js +27 -4
- package/dist/core/workflow-run-store-contract.js +16 -0
- package/dist/core/workflow-run-store.d.ts +9 -7
- package/dist/core/workflow-run-store.js +4 -1
- package/dist/engine/execution-env/node-execution-env.js +3 -1
- package/dist/engine/harness/messages.d.ts +1 -1
- package/dist/engine/harness/messages.js +2 -1
- package/dist/engine/harness/types.d.ts +24 -1
- package/dist/engine/harness/types.js +10 -0
- package/dist/engine/llm/types.d.ts +5 -7
- package/dist/engine/loop/types.d.ts +2 -0
- package/dist/engine/lsp/node-lsp-manager.js +2 -1
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/session.d.ts +15 -2
- package/dist/engine/session/session.js +35 -5
- package/dist/index.d.ts +27 -12
- package/dist/index.js +20 -8
- package/dist/orchestration/run-workflow-tool.js +40 -32
- package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
- package/dist/orchestration/workflow-park-adoption.js +47 -12
- package/dist/orchestration/workflow-stop.d.ts +128 -0
- package/dist/orchestration/workflow-stop.js +156 -0
- package/dist/orchestration/workflow.d.ts +30 -6
- package/dist/orchestration/workflow.js +117 -54
- package/dist/prompts/manager-recipe.d.ts +18 -0
- package/dist/prompts/manager-recipe.js +24 -0
- package/dist/stores/file/adoption/marker.d.ts +2 -27
- package/dist/stores/file/adoption/marker.js +12 -0
- package/dist/stores/file/index.d.ts +1 -1
- package/dist/stores/file/index.js +1 -1
- package/dist/stores/file/permission-rule-store.d.ts +3 -1
- package/dist/stores/file/permission-rule-store.js +0 -1
- package/dist/stores/file/workflow-journal-store.d.ts +16 -3
- package/dist/stores/file/workflow-journal-store.js +93 -5
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/tools/artifact/artifact-tool.js +11 -6
- package/dist/tools/fs/file-read-check.d.ts +45 -11
- package/dist/tools/fs/file-read-check.js +200 -57
- package/dist/tools/fs/file-write-check.js +9 -3
- package/dist/tools/fs/index.d.ts +8 -7
- package/dist/tools/fs/index.js +4 -4
- package/dist/tools/fs/judged-reads.d.ts +51 -0
- package/dist/tools/fs/judged-reads.js +68 -0
- package/dist/tools/fs/read-deny-home.d.ts +1 -1
- package/dist/tools/fs/read-deny-home.js +5 -5
- package/dist/tools/fs/read-deny.d.ts +33 -8
- package/dist/tools/fs/read-deny.js +114 -25
- package/dist/tools/fs/safety.d.ts +12 -1
- package/dist/tools/fs/safety.js +16 -3
- package/dist/tools/fs/shell-read-check.d.ts +25 -5
- package/dist/tools/fs/shell-read-check.js +100 -15
- package/dist/tools/fs/shell-read-establish.d.ts +9 -0
- package/dist/tools/fs/shell-read-establish.js +34 -14
- package/dist/tools/fs/shell-read-judge.d.ts +13 -1
- package/dist/tools/fs/shell-read-judge.js +26 -7
- package/dist/tools/fs/shell-read-plan.d.ts +5 -0
- package/dist/tools/fs/shell-read-write-targets.js +17 -9
- package/dist/tools/scheduler-store-move.d.ts +74 -0
- package/dist/tools/scheduler-store-move.js +103 -0
- package/dist/tools/scheduler-tools.d.ts +43 -29
- package/dist/tools/scheduler-tools.js +161 -118
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +173 -3
- package/wire-changes/answers/core-stores-sql@7.72.0.json +12 -0
- package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
- package/wire-changes/answers/core@7.72.0.json +84 -0
- package/wire-changes/answers/core@7.73.0.json +216 -0
- package/wire-changes/answers/mods-kernel@7.72.0.json +7 -0
- package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
- package/wire-changes/answers/primitives@7.72.0.json +6 -0
- package/wire-changes/answers/primitives@7.73.0.json +12 -0
- package/wire-changes/answers/wiki-gate@7.72.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
- package/wire-changes/core-stores-sql@7.72.0.json +215 -0
- package/wire-changes/core-stores-sql@7.73.0.json +326 -0
- package/wire-changes/core@7.72.0.json +2426 -0
- package/wire-changes/core@7.73.0.json +6480 -0
- package/wire-changes/mods-kernel@7.72.0.json +147 -0
- package/wire-changes/mods-kernel@7.73.0.json +147 -0
- package/wire-changes/primitives@7.72.0.json +143 -0
- package/wire-changes/primitives@7.73.0.json +227 -0
- package/wire-changes/wiki-gate@7.72.0.json +145 -0
- package/wire-changes/wiki-gate@7.73.0.json +145 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { canonicalRootsOnce, isAbsence, observeEnvironment } from "./shell-read-environment.js";
|
|
2
|
-
import { anchorSpelling, belowOwnProcessLink, isAbsoluteForFamily, normalizeAbsPathLexically, ownProcessSpelling, pathFamilyOf, withinAnyRoot } from "./safety.js";
|
|
2
|
+
import { anchorSpelling, belowOwnProcessLink, isAbsoluteForFamily, isBareOwnDescriptorLink, normalizeAbsPathLexically, ownProcessSpelling, pathFamilyOf, withinAnyRoot } from "./safety.js";
|
|
3
3
|
import { landingsOf, noteClimb, readingsAt, withClimbedPatterns, withClimbedViews, withFloorClimbs } from "./shell-climb.js";
|
|
4
4
|
import { boundaryIsTheSandbox } from "../../core/remote-env.js";
|
|
5
5
|
import { resolveOperandSpellings, tildeNamesAnAccount } from "./bash-readonly-classifier.js";
|
|
@@ -160,11 +160,20 @@ function lexicalReadsOf(candidate, boundary, placed) {
|
|
|
160
160
|
}
|
|
161
161
|
function writtenByText(plan, boundary) {
|
|
162
162
|
const targets = new Set();
|
|
163
|
-
const
|
|
163
|
+
const runs = [];
|
|
164
|
+
const writes = [];
|
|
165
|
+
let concurrent = false;
|
|
164
166
|
const speculativeSeen = new Set();
|
|
165
167
|
let unplaced = false;
|
|
166
168
|
const walk = (p) => {
|
|
167
169
|
for (const s of p.segments) {
|
|
170
|
+
for (const n of s.nested)
|
|
171
|
+
walk(n);
|
|
172
|
+
const wrote = [];
|
|
173
|
+
runs.push(s);
|
|
174
|
+
writes.push(wrote);
|
|
175
|
+
if (p.shape.backgrounded || s.connector === "|")
|
|
176
|
+
concurrent = true;
|
|
168
177
|
for (const c of s.reads) {
|
|
169
178
|
if (c.speculative === undefined || c.expands !== false || c.bases === "unmodelled")
|
|
170
179
|
continue;
|
|
@@ -190,16 +199,19 @@ function writtenByText(plan, boundary) {
|
|
|
190
199
|
else {
|
|
191
200
|
const t = normalizeAbsPathLexically(r.target);
|
|
192
201
|
targets.add(t);
|
|
193
|
-
|
|
202
|
+
wrote.push(t);
|
|
194
203
|
}
|
|
195
204
|
}
|
|
196
205
|
}
|
|
197
|
-
for (const n of s.nested)
|
|
198
|
-
walk(n);
|
|
199
206
|
}
|
|
200
207
|
};
|
|
201
208
|
walk(plan);
|
|
202
|
-
return { targets, unplaced,
|
|
209
|
+
return { targets, unplaced, runs, writes, concurrent };
|
|
210
|
+
}
|
|
211
|
+
export function writtenOnLineBefore(writes, at, concurrent, place) {
|
|
212
|
+
const fold = (p) => p.normalize("NFC").toLowerCase();
|
|
213
|
+
const here = fold(place);
|
|
214
|
+
return writes.some((paths, i) => i !== at && (i < at || concurrent) && paths.some((w) => withinAnyRoot([fold(w)], here) || withinAnyRoot([here], fold(w))));
|
|
203
215
|
}
|
|
204
216
|
function unfollowedBackupReads(j, boundary, cause) {
|
|
205
217
|
const named = sedBackupNames(j.followed.operand.spelled, j.followed.suffix).flatMap((name) => lexicalReadsOf({ ...j.candidate, spelled: name }, boundary));
|
|
@@ -451,12 +463,22 @@ function establishLegOver(seen, readRoots) {
|
|
|
451
463
|
return undefined;
|
|
452
464
|
return { value: joinUnder(parent.value, leaf), exact: parent.exact, ...(parent.missing !== undefined ? { missing: parent.missing } : {}) };
|
|
453
465
|
};
|
|
466
|
+
const takenAsSpelled = (candidate, spelling, spellings, origin) => ({
|
|
467
|
+
candidate,
|
|
468
|
+
established: "lexical",
|
|
469
|
+
target: normalizeAbsPathLexically(spelling),
|
|
470
|
+
spellings,
|
|
471
|
+
...(origin !== undefined ? { origin } : {}),
|
|
472
|
+
});
|
|
454
473
|
const canonicalReadOf = async (candidate, spelling, spellings, established, origin, canonicalKnown, signal, seat = "landing", climbs) => {
|
|
455
|
-
const
|
|
474
|
+
const unplacedOwnLink = belowOwnProcessLink(spelling, candidate.provenance === "traversal_root");
|
|
475
|
+
if (isBareOwnDescriptorLink(spelling) && !unplacedOwnLink)
|
|
476
|
+
return takenAsSpelled(candidate, spelling, spellings, origin);
|
|
477
|
+
const real = canonicalKnown !== undefined ? { value: canonicalKnown, exact: true } : unplacedOwnLink ? { value: spelling, exact: false } : seat === "entry" ? await entryOf(spelling, signal, climbs) : await resolve(spelling, signal, candidate.face === "write", WRITE_LINK_HOPS, climbs);
|
|
456
478
|
if (real === undefined) {
|
|
457
479
|
if (resolverIsAuthoritative)
|
|
458
480
|
return { candidate, established: "unestablishable", spellings, ...(origin !== undefined ? { origin } : {}), cause: `"${spelling}" cannot be resolved to verify where it reads`, unresolved: true };
|
|
459
|
-
return
|
|
481
|
+
return takenAsSpelled(candidate, spelling, spellings, origin);
|
|
460
482
|
}
|
|
461
483
|
if (!real.exact && real.missing !== true) {
|
|
462
484
|
return { candidate, established: "unestablishable", spellings, ...(origin !== undefined ? { origin } : {}), cause: `"${spelling}" cannot be resolved to verify where it reads`, unresolved: true };
|
|
@@ -548,15 +570,13 @@ function establishLegOver(seen, readRoots) {
|
|
|
548
570
|
for (const r of lexicalReadsOf(fact.candidate, boundary)) {
|
|
549
571
|
if (r.established !== "lexical" || r.target === undefined)
|
|
550
572
|
return undefined;
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
if ((t === place || withinAnyRoot([place], t)) && [...by].some((s) => s !== segment))
|
|
554
|
-
return undefined;
|
|
573
|
+
if (writtenOnLineBefore(written.writes, written.runs.indexOf(segment), written.concurrent, normalizeAbsPathLexically(r.target)))
|
|
574
|
+
return undefined;
|
|
555
575
|
const at = fact.seat === "entry" ? await entryOf(r.target, signal) : await resolve(r.target, signal);
|
|
556
576
|
if (at === undefined || (!at.exact && at.missing !== true))
|
|
557
577
|
return undefined;
|
|
558
|
-
const info = at.missing === true && !at.exact ? undefined : await env.fileInfo(at.value, signal);
|
|
559
|
-
const here = info === undefined ? false : info.ok ? info.value.kind === "directory" : isAbsence(info.error.code) ? false : undefined;
|
|
578
|
+
const info = at.missing === true && !at.exact ? undefined : fact.seat === "entry" ? await env.fileInfo(at.value, signal) : await env.listDir(at.value, signal);
|
|
579
|
+
const here = info === undefined ? false : info.ok ? Array.isArray(info.value) || info.value.kind === "directory" : isAbsence(info.error.code) ? false : undefined;
|
|
560
580
|
if (here === undefined || (directory !== undefined && directory !== here))
|
|
561
581
|
return undefined;
|
|
562
582
|
directory = here;
|
|
@@ -27,7 +27,7 @@ import type { ReadCandidate, ShellReadPlan, ShellReadSegment } from "./shell-rea
|
|
|
27
27
|
import type { Incomplete, ObservedFilesystem } from "./shell-read-environment.js";
|
|
28
28
|
import type { WriteSeat } from "./shell-read-write-targets.js";
|
|
29
29
|
import { type ContainmentFace } from "./containment-face.js";
|
|
30
|
-
import { type JudgedPathRow } from "./read-deny.js";
|
|
30
|
+
import { type JudgedPathRow, type ReadDenyFinding, type ReadDenyRootAnswer } from "./read-deny.js";
|
|
31
31
|
import type { AssertAllKeysHandled } from "../../core/ask-origin.js";
|
|
32
32
|
/** WHAT the judge found about a command — a closed set, registered in `docs/CLOSED-SETS.md`. */
|
|
33
33
|
export declare const SHELL_READ_FINDINGS: readonly ["deny_hit", "outside_roots", "unestablishable", "declined", "identity_changed", "unanswered", "target_unavailable", "none"];
|
|
@@ -241,6 +241,17 @@ export interface ShellReadBoundary extends BashReadonlyRootBoundary {
|
|
|
241
241
|
/** Does the row `writeDenyMatch` named (its rule) guard the READ face too — a `Read(…)` rule on the write face
|
|
242
242
|
* ({@link import("./read-deny.js").WriteDenyMatcher.guardsReads})? Read once per hit, so the refusal says which family refused. */
|
|
243
243
|
readonly writeDenyGuardsReads?: (pattern: string) => boolean;
|
|
244
|
+
/** The write table's rows named by or below a subtree removal/rename target (`WriteDenyMatcher.rowUnderRoot`). */
|
|
245
|
+
readonly writeDenyUnder?: (resolvedPath: string) => ReadDenyRootAnswer;
|
|
246
|
+
/** The write table's unanchored rows (`WriteDenyMatcher.unanchoredRows`, never empty here) and the first of them whose leading
|
|
247
|
+
* name one directory entry name matches (`WriteDenyMatcher.rowLedByName`): what the station searches a recursive removal's
|
|
248
|
+
* subtree for, under its own bound ({@link import("./shell-read-check.js").SUBTREE_SEARCH_MS}). PRESENT-IFF such a row. */
|
|
249
|
+
readonly writeDenyNamed?: {
|
|
250
|
+
readonly rows: readonly string[];
|
|
251
|
+
readonly ledBy: (entryName: string) => string | null;
|
|
252
|
+
};
|
|
253
|
+
/** The write table's rows AT or BELOW a path (`WriteDenyMatcher.rowAtOrBelow`): read by `writesPlaced` via {@link denyRowAtOrBelow}. */
|
|
254
|
+
readonly writeDenyAtOrBelow?: (resolvedPath: string) => string | null;
|
|
244
255
|
/** The read table's rows AT or BELOW a path (`readDenySeat`'s `denyAtOrBelow`, read-deny.ts): read by the station's
|
|
245
256
|
* `writesPlaced` fact only, through {@link denyRowAtOrBelow}. */
|
|
246
257
|
readonly denyAtOrBelow?: (resolvedPath: string) => string | null;
|
|
@@ -355,6 +366,7 @@ export interface ReadFinding {
|
|
|
355
366
|
readonly face?: "write";
|
|
356
367
|
readonly readRow?: true;
|
|
357
368
|
readonly under?: true;
|
|
369
|
+
readonly lookup?: ReadDenyFinding["lookup"];
|
|
358
370
|
};
|
|
359
371
|
/** A `deny_hit` on no row: the read's target is a process-private /proc file (`isProcSensitiveFile`, safety.ts — the set the
|
|
360
372
|
* file read tools refuse), or a tree walk's root holds such files (`holdsProcSensitiveFile`); the view it was matched on. */
|
|
@@ -64,19 +64,32 @@ export function judgeRead(read, boundary) {
|
|
|
64
64
|
if (pattern !== null)
|
|
65
65
|
return { read, kind: "deny_hit", deny: { pattern, matchedView: folded, ...(writeTarget ? { face: "write", ...(boundary.writeDenyGuardsReads?.(pattern) === true ? { readRow: true } : {}) } : {}) }, containment: writeTarget ? writeContainmentOf(read, boundary) : containmentOf(read, boundary) };
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
const checksUnder = writeTarget ? read.candidate.subtree !== undefined && read.written !== undefined : read.candidate.provenance === "traversal_root";
|
|
68
|
+
const denyUnder = writeTarget ? boundary.writeDenyUnder : boundary.denyUnder;
|
|
69
|
+
if (checksUnder && denyUnder !== undefined) {
|
|
68
70
|
let unplaced;
|
|
69
71
|
for (const view of [...(read.target !== undefined ? [read.target] : []), ...read.spellings, ...(read.hops ?? [])]) {
|
|
70
72
|
const folded = normalizeAbsPathLexically(view);
|
|
71
|
-
const under =
|
|
72
|
-
if (typeof under === "string")
|
|
73
|
-
return {
|
|
73
|
+
const under = denyUnder(folded);
|
|
74
|
+
if (typeof under === "string") {
|
|
75
|
+
return {
|
|
76
|
+
read,
|
|
77
|
+
kind: "deny_hit",
|
|
78
|
+
deny: {
|
|
79
|
+
pattern: under,
|
|
80
|
+
matchedView: folded,
|
|
81
|
+
under: true,
|
|
82
|
+
...(writeTarget ? { face: "write", ...(boundary.writeDenyGuardsReads?.(under) === true ? { readRow: true } : {}) } : {}),
|
|
83
|
+
},
|
|
84
|
+
containment: writeTarget ? writeContainmentOf(read, boundary) : containmentOf(read, boundary),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
74
87
|
if (under !== null && typeof under === "object")
|
|
75
88
|
unplaced ??= under.unplaced;
|
|
76
89
|
}
|
|
77
90
|
if (unplaced !== undefined) {
|
|
78
91
|
const cause = `the home-anchored deny row "${unplaced}" cannot be placed (no home directory is known for this environment), so "${read.target ?? read.candidate.spelled}" may hold it`;
|
|
79
|
-
return { read: { ...read, cause }, kind: "unanswered", denyRowUnasked: true, containment: containmentOf(read, boundary) };
|
|
92
|
+
return { read: { ...read, cause }, kind: "unanswered", denyRowUnasked: true, containment: writeTarget ? writeContainmentOf(read, boundary) : containmentOf(read, boundary) };
|
|
80
93
|
}
|
|
81
94
|
}
|
|
82
95
|
}
|
|
@@ -138,14 +151,20 @@ function personAllowAdmits(read, boundary) {
|
|
|
138
151
|
return hit !== undefined && hit.unreadable === undefined;
|
|
139
152
|
}
|
|
140
153
|
export function denyRowAtOrBelow(read, boundary, carriesContent) {
|
|
141
|
-
|
|
154
|
+
const views = [...(read.target !== undefined ? [read.target] : []), ...read.spellings];
|
|
155
|
+
if (boundary.writeDenyAtOrBelow !== undefined) {
|
|
156
|
+
if (views.some((view) => boundary.writeDenyAtOrBelow(normalizeAbsPathLexically(view)) !== null))
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
else if (boundary.writeDenyMatch !== undefined) {
|
|
142
160
|
return true;
|
|
161
|
+
}
|
|
143
162
|
if (!carriesContent)
|
|
144
163
|
return false;
|
|
145
164
|
const atOrBelow = boundary.denyAtOrBelow;
|
|
146
165
|
if (atOrBelow === undefined)
|
|
147
166
|
return false;
|
|
148
|
-
return
|
|
167
|
+
return views.some((view) => atOrBelow(normalizeAbsPathLexically(view)) !== null);
|
|
149
168
|
}
|
|
150
169
|
export function denyFloorShadowsOf(candidates) {
|
|
151
170
|
return candidates.flatMap((c) => (c.floorSpelled === undefined ? [] : [{ spelled: c.floorSpelled, raw: c.raw, provenance: c.provenance, expands: globInWord(readOfText(c.raw).word) ? "glob" : false, bases: [], denyOnly: true, ...(c.face !== undefined ? { face: c.face } : {}), ...(c.face === "write" && c.expands === "unresolvable" && !/[$`]/.test(c.floorSpelled) ? { twin: true } : {}) }]));
|
|
@@ -101,6 +101,11 @@ export interface ReadCandidate {
|
|
|
101
101
|
/** A WRITE target (a `>`-family redirection, a `sed` `w` file, a file-writing command's operand): established like a
|
|
102
102
|
* read, judged on the WRITE face — the write deny rows, then the write roots where written — never as a read. */
|
|
103
103
|
readonly face?: "write";
|
|
104
|
+
/** On a write target: the command takes the entire subtree at this path with it — `removed` (`rm -r`, `find -delete`'s
|
|
105
|
+
* starting points) or `moved` (an `mv` source) — so a write-facing deny row whose location lies beneath it refuses the
|
|
106
|
+
* operation ({@link ShellReadBoundary.writeDenyUnder}); below a `removed` one an unanchored row is also searched for by
|
|
107
|
+
* name ({@link ShellReadBoundary.writeDenyNamed}). A moved subtree keeps its names, so an unanchored row still meets them. */
|
|
108
|
+
readonly subtree?: "removed" | "moved";
|
|
104
109
|
/** A reading the station takes where no row says the program opens the word — a word of a program with no row, a
|
|
105
110
|
* role only another implementation reads — so the filesystem decides it: `containment` = the spelling always meets
|
|
106
111
|
* the deny rows and is a containment candidate only where it exists; `whole` = a whole word (`NAME=value`, an option
|
|
@@ -51,7 +51,7 @@ function writeOwnersOf(segment) {
|
|
|
51
51
|
function writeTargetsOf(segment) {
|
|
52
52
|
const out = [];
|
|
53
53
|
const writeOnly = new Set();
|
|
54
|
-
const write = (c, seats, written, child, onlyIf, through) => void out.push({ candidate: { ...c, face: "write", ...(through === true ? { through } : {}) }, ...(seats !== undefined ? { seats } : {}), ...(written !== undefined ? { written } : {}), ...(child === true ? { child } : {}), ...(onlyIf !== undefined ? { onlyIf } : {}) });
|
|
54
|
+
const write = (c, seats, written, child, onlyIf, through, subtree) => void out.push({ candidate: { ...c, face: "write", ...(through === true ? { through } : {}), ...(subtree !== undefined ? { subtree } : {}) }, ...(seats !== undefined ? { seats } : {}), ...(written !== undefined ? { written } : {}), ...(child === true ? { child } : {}), ...(onlyIf !== undefined ? { onlyIf } : {}) });
|
|
55
55
|
for (const r of segment.redirects)
|
|
56
56
|
if (r.direction === "out" && r.target !== undefined)
|
|
57
57
|
write(r.target, undefined, undefined, undefined, undefined, true);
|
|
@@ -63,7 +63,8 @@ function writeTargetsOf(segment) {
|
|
|
63
63
|
const all = writeReadings(row, args);
|
|
64
64
|
const selected = implementationsOf(row).flatMap((view) => selectedOptions(view, args, "one-implementation"));
|
|
65
65
|
const moved = [...new Set(selected.flatMap((o) => o.writesAt ?? []))];
|
|
66
|
-
|
|
66
|
+
const recursiveRemove = row.key === "rm" && selected.some((o) => o.selects === "traversal");
|
|
67
|
+
return { row, words, program, all, readings: all.filter((r) => r.written.length > 0 || (r.unexplained && r.operandRole !== undefined)), override: moved.length > 0 ? moved : undefined, beyondOperands: selected.some((o) => o.effect === "writes" || o.effect === "executes"), recursiveRemove };
|
|
67
68
|
});
|
|
68
69
|
const edited = new Map();
|
|
69
70
|
for (const c of segment.reads) {
|
|
@@ -99,7 +100,8 @@ function writeTargetsOf(segment) {
|
|
|
99
100
|
const seats = stated ? [...new Set(roles.flatMap((role) => o.override ?? role.seats ?? ["landing"]))] : undefined;
|
|
100
101
|
const written = unexplained || roles.some((role) => role.writtenAt === undefined) ? undefined : [...new Set(roles.flatMap((role) => role.writtenAt ?? []))];
|
|
101
102
|
const speculative = readings < o.all.length && roles.every((role) => role.effect === "edit-in-place") ? { candidate: c, holds: "present" } : undefined;
|
|
102
|
-
|
|
103
|
+
const subtree = o.recursiveRemove ? "removed" : o.row.key === "mv" && (unexplained || o.all.some((r) => r.copy !== undefined && r.copy.sources.some((idx) => at.has(idx)))) ? "moved" : undefined;
|
|
104
|
+
write(c, seats, written, undefined, speculative, !unexplained && writesThrough(roles, o.row, o.words) ? true : undefined, subtree);
|
|
103
105
|
if (roles.some((role) => role.effect === "edit-in-place") && c.expands === false)
|
|
104
106
|
edited.set(o, [...(edited.get(o) ?? []), { candidate: c, ...(speculative !== undefined ? { onlyIf: speculative } : {}) }]);
|
|
105
107
|
}
|
|
@@ -107,12 +109,12 @@ function writeTargetsOf(segment) {
|
|
|
107
109
|
writeOnly.add(c);
|
|
108
110
|
}
|
|
109
111
|
for (const o of owners) {
|
|
110
|
-
for (const
|
|
111
|
-
write(
|
|
112
|
+
for (const { candidate, onlyIf } of copyDestinationChildren(segment, o.row, o.words, o.all))
|
|
113
|
+
write(candidate, ["landing", "entry"], undefined, true, onlyIf);
|
|
112
114
|
out.push(...backupTargetsOf(edited.get(o) ?? [], o.readings, o.override));
|
|
113
115
|
}
|
|
114
116
|
for (const c of walkRemovalTargetsOf(segment))
|
|
115
|
-
write(c, ["landing", "entry"]);
|
|
117
|
+
write(c, ["landing", "entry"], undefined, undefined, undefined, undefined, "removed");
|
|
116
118
|
const readWords = new Set();
|
|
117
119
|
for (const o of owners) {
|
|
118
120
|
if (!o.program)
|
|
@@ -140,6 +142,11 @@ function copyDestinationChildren(segment, row, words, readings) {
|
|
|
140
142
|
const candidateOf = (raw) => segment.reads.find((c) => c.raw === raw && WORD_PROVENANCES.has(c.provenance));
|
|
141
143
|
const start = segment.programStart;
|
|
142
144
|
const children = new Map();
|
|
145
|
+
const keep = (key, candidate, onlyIf) => {
|
|
146
|
+
const prev = children.get(key);
|
|
147
|
+
if (prev === undefined || (prev.onlyIf !== undefined && onlyIf === undefined))
|
|
148
|
+
children.set(key, onlyIf !== undefined ? { candidate, onlyIf } : { candidate });
|
|
149
|
+
};
|
|
143
150
|
for (const r of readings) {
|
|
144
151
|
if (r.copy === undefined)
|
|
145
152
|
continue;
|
|
@@ -152,18 +159,19 @@ function copyDestinationChildren(segment, row, words, readings) {
|
|
|
152
159
|
const destRole = r.written.find((w) => w.at === destination?.at)?.role;
|
|
153
160
|
if (destCandidate !== undefined && destRole !== undefined && passesUnasked({ ...destCandidate, face: "write", ...(writesThrough([destRole], row, words) ? { through: true } : {}) }))
|
|
154
161
|
continue;
|
|
162
|
+
const destDirFact = destination !== undefined && destCandidate !== undefined ? { candidate: destCandidate, holds: "directory" } : undefined;
|
|
155
163
|
for (const at of sources) {
|
|
156
164
|
const src = words[at];
|
|
157
165
|
const source = candidateOf(src.raw);
|
|
158
166
|
if (source !== undefined && source.expands !== false) {
|
|
159
167
|
if (destination !== undefined)
|
|
160
168
|
continue;
|
|
161
|
-
|
|
169
|
+
keep(`\0${source.raw}`, source);
|
|
162
170
|
}
|
|
163
171
|
const child = `${dest.spelled.replace(/\/+$/, "")}/${src.spelled.replace(/\/+$/, "").split("/").pop() ?? ""}`;
|
|
164
|
-
if (child.endsWith("/")
|
|
172
|
+
if (child.endsWith("/"))
|
|
165
173
|
continue;
|
|
166
|
-
|
|
174
|
+
keep(child, destCandidate !== undefined && source !== undefined ? renamed(destCandidate, child) : { spelled: child, raw: src.raw, provenance: "unlisted_word", expands: "unresolvable", bases: [] }, destDirFact);
|
|
167
175
|
}
|
|
168
176
|
}
|
|
169
177
|
return [...children.values()];
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/** One stored row as the store's owner hands it to a move. Only these members are read; the rest of the row is the owner's and comes back untouched. */
|
|
2
|
+
export interface SchedulerStoredRow {
|
|
3
|
+
/** The key the row is filed under now. */
|
|
4
|
+
readonly scope: unknown;
|
|
5
|
+
/** The row's stored `ScheduledIntent.lifetime` (absent when the store kept none). */
|
|
6
|
+
readonly lifetime?: unknown;
|
|
7
|
+
/** The row's stored `ScheduledIntent.mode` (absent when the store kept none). */
|
|
8
|
+
readonly mode?: unknown;
|
|
9
|
+
/** The row's stored label. */
|
|
10
|
+
readonly label?: unknown;
|
|
11
|
+
/** The session the row's firings go to (the `SchedulerContext.sessionId` it was scheduled with): the owner of a session-lane row's key. */
|
|
12
|
+
readonly sessionId?: unknown;
|
|
13
|
+
/** The owner's own word on the row's lane (`"session"` / `"durable"`), for a row whose stored members do not name it. Read by the forward move only. */
|
|
14
|
+
readonly lane?: unknown;
|
|
15
|
+
}
|
|
16
|
+
/** Why a move hands a row back unmoved — the closed set of {@link SchedulerStoreMove.refused}'s `code`. */
|
|
17
|
+
export type SchedulerRowRefusalCode =
|
|
18
|
+
/** Its key is not a non-empty string (forward) or not a lane key (rollback), or a `lifetime` / `mode` / `lane` is outside the seam's words. */
|
|
19
|
+
"row_invalid"
|
|
20
|
+
/** Neither its stored members nor a stated `lane` name its lane: no `lifetime: "session"`, no `mode`, and the wakeup's label — a session
|
|
21
|
+
* wakeup on a store that kept no `mode`, or a job that was given that label. */
|
|
22
|
+
| "lane_unknown"
|
|
23
|
+
/** The stated `lane` is not the lane its stored members name. */
|
|
24
|
+
| "lane_contradicted"
|
|
25
|
+
/** A session-lane row whose firing destination (`sessionId`) is not a non-empty string: it has no owner to key. */
|
|
26
|
+
| "destination_unknown"
|
|
27
|
+
/** Rollback: a session-lane row and a durable-lane row of one owner would share one bare key, where an older release lists and stops
|
|
28
|
+
* them as one lane's rows. */
|
|
29
|
+
| "bare_key_shared"
|
|
30
|
+
/** Forward: rows filed under different bare keys would share one lane key (two explicit session scopes over one session id — two
|
|
31
|
+
* tenants' `A/42` and `B/42` — where the lane key is the session id alone): the move does not merge them. */
|
|
32
|
+
| "lane_key_shared";
|
|
33
|
+
/** What a move answers: the rows it placed, each with the key to file it under, in input order; and the rows it did not, each with why. */
|
|
34
|
+
export interface SchedulerStoreMove<R extends SchedulerStoredRow> {
|
|
35
|
+
readonly moved: ReadonlyArray<{
|
|
36
|
+
readonly row: R;
|
|
37
|
+
readonly scope: string;
|
|
38
|
+
}>;
|
|
39
|
+
readonly refused: ReadonlyArray<{
|
|
40
|
+
readonly row: R;
|
|
41
|
+
readonly code: SchedulerRowRefusalCode;
|
|
42
|
+
readonly reason: string;
|
|
43
|
+
}>;
|
|
44
|
+
}
|
|
45
|
+
/** A whole store, as its owner hands it to a move: its rows and its own key declaration (the `scopeKeys` it declares today). */
|
|
46
|
+
export interface SchedulerStoreRows<R extends SchedulerStoredRow> {
|
|
47
|
+
readonly scopeKeys?: unknown;
|
|
48
|
+
readonly rows: readonly R[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Pure forward placement: each row filed under bare keys (a release before 7.72.0: a key was its owner alone) gets one lane key or one
|
|
52
|
+
* refusal — `session:<sessionId>` for a row of the session lane (keyed by the session it fires into: an older factory took an explicit
|
|
53
|
+
* session scope, so the bare key need not be the session), `durable:<bare key>` for a row of the durable lane. A row's lane is read off its
|
|
54
|
+
* stored `lifetime` and `mode` as scheduling picks it (`lifetime: "session"` or `mode: "session-wakeup"` ⇒ session); a row with no `mode`,
|
|
55
|
+
* a `lifetime` absent or `"durable"` and the wakeup's label is refused `lane_unknown` unless the owner states its `lane`. A bare key is never
|
|
56
|
+
* judged by its head. Rows of different bare keys that would land on one lane key are not merged: each is refused `lane_key_shared` (only
|
|
57
|
+
* the rows of this call are compared).
|
|
58
|
+
*
|
|
59
|
+
* Pure and write-free: call it once to move a store (writing `moved` and `scopeKeys: "lane"` in one write once `refused` is empty), or on
|
|
60
|
+
* every read in a backend that keeps bare keys stored and answers lane keys at its port (that backend's duties are written at
|
|
61
|
+
* `SchedulerCapability.schedulerCapabilities.scopeKeys`). `store.scopeKeys` is the stored rows' form (absent or `"bare"`; `"lane"` is refused
|
|
62
|
+
* whole, `config.invalid_argument`).
|
|
63
|
+
*/
|
|
64
|
+
export declare function migrateSchedulerStore<R extends SchedulerStoredRow>(store: SchedulerStoreRows<R>): SchedulerStoreMove<R>;
|
|
65
|
+
/**
|
|
66
|
+
* The rollback: every row of a store that declares lane keys with its bare key (the lane name and its `:` taken off), for an older release.
|
|
67
|
+
* Two lanes' rows that would share one bare key — a session whose id is some isolation scope's name — are both refused `bare_key_shared`:
|
|
68
|
+
* an older release reads them as one lane's rows, so one owner's stop or delete reaches the other's. Settle them (remove one, or keep
|
|
69
|
+
* the newer release) before rolling back. A row whose key is not a lane key is refused `row_invalid`.
|
|
70
|
+
*
|
|
71
|
+
* `store.scopeKeys` must be `"lane"` (anything else is refused whole, `config.invalid_argument`). Write `moved` together with the
|
|
72
|
+
* declaration `scopeKeys: "bare"`, and only when `refused` is empty.
|
|
73
|
+
*/
|
|
74
|
+
export declare function rollbackSchedulerStore<R extends SchedulerStoredRow>(store: SchedulerStoreRows<R>): SchedulerStoreMove<R>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { codedRefusal } from "../core/thrown-value.js";
|
|
2
|
+
import { describeRejectedValue } from "../core/tool-search-setting.js";
|
|
3
|
+
import { isLaneKey, laneKeyOf, laneOfIntent, WAKEUP_LABEL } from "./scheduler-tools.js";
|
|
4
|
+
const LIFETIMES = [undefined, "durable", "session"];
|
|
5
|
+
const MODES = [undefined, "task", "session-wakeup"];
|
|
6
|
+
const LANES = [undefined, "session", "durable"];
|
|
7
|
+
function rowsOf(store, direction, wanted, want) {
|
|
8
|
+
const held = store;
|
|
9
|
+
if (typeof held !== "object" || held === null || !Array.isArray(held.rows)) {
|
|
10
|
+
throw codedRefusal("config.invalid_argument", `the scheduler store handed to the ${direction} is ${describeRejectedValue(held)}, not { scopeKeys?, rows: [...] } — the ${direction} reads the whole store at once.`);
|
|
11
|
+
}
|
|
12
|
+
const keys = held.scopeKeys;
|
|
13
|
+
if (!wanted(keys))
|
|
14
|
+
throw codedRefusal("config.invalid_argument", `the scheduler store declares scopeKeys ${describeRejectedValue(keys)}; the ${direction} runs on a store that declares ${want} — it runs once, and a key's head does not say which form it is.`);
|
|
15
|
+
return held.rows;
|
|
16
|
+
}
|
|
17
|
+
function storedLaneOf(row) {
|
|
18
|
+
if (!LIFETIMES.includes(row.lifetime))
|
|
19
|
+
return { fault: `its lifetime is ${describeRejectedValue(row.lifetime)}, not "durable", "session" or absent` };
|
|
20
|
+
if (!MODES.includes(row.mode))
|
|
21
|
+
return { fault: `its mode is ${describeRejectedValue(row.mode)}, not "task", "session-wakeup" or absent` };
|
|
22
|
+
const lane = laneOfIntent(row);
|
|
23
|
+
return lane === "durable" && row.mode === undefined && row.label === WAKEUP_LABEL ? "unknown" : lane;
|
|
24
|
+
}
|
|
25
|
+
export function migrateSchedulerStore(store) {
|
|
26
|
+
const rows = rowsOf(store, "move", (keys) => keys === undefined || keys === "bare", 'none, or "bare"');
|
|
27
|
+
const placed = [];
|
|
28
|
+
const refused = [];
|
|
29
|
+
const refuse = (row, code, reason) => void refused.push({ row, code, reason });
|
|
30
|
+
for (const row of rows) {
|
|
31
|
+
const key = row?.scope;
|
|
32
|
+
if (typeof key !== "string" || key === "") {
|
|
33
|
+
refuse(row, "row_invalid", `the row's key is ${describeRejectedValue(key)}, not a non-empty string — there is no owner to file it under.`);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const stored = storedLaneOf(row);
|
|
37
|
+
if (typeof stored === "object") {
|
|
38
|
+
refuse(row, "row_invalid", `${stored.fault} — its lane cannot be read.`);
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (!LANES.includes(row.lane)) {
|
|
42
|
+
refuse(row, "row_invalid", `its stated lane is ${describeRejectedValue(row.lane)}, not "session", "durable" or absent.`);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const stated = row.lane;
|
|
46
|
+
if (stated !== undefined && stored !== "unknown" && stated !== stored) {
|
|
47
|
+
refuse(row, "lane_contradicted", `its stated lane is "${stated}", but its stored lifetime and mode file it on the ${stored} lane.`);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const lane = stated ?? stored;
|
|
51
|
+
if (lane === "unknown") {
|
|
52
|
+
refuse(row, "lane_unknown", `it carries ${row.lifetime === undefined ? "no lifetime" : `lifetime "${String(row.lifetime)}"`} and no mode, and the wakeup's label "${WAKEUP_LABEL}" — a row both lanes may have written: a session wakeup on a store that kept no mode, or a job given that label. State its lane.`);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (lane === "durable") {
|
|
56
|
+
placed.push({ row, scope: laneKeyOf("durable", key), from: key });
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const destination = row.sessionId;
|
|
60
|
+
if (typeof destination !== "string" || destination === "") {
|
|
61
|
+
refuse(row, "destination_unknown", `it is a session-lane row whose session (sessionId) is ${describeRejectedValue(destination)}, not a non-empty string — the session it fires into is the owner of its key.`);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
placed.push({ row, scope: laneKeyOf("session", destination), from: key });
|
|
65
|
+
}
|
|
66
|
+
const moved = unshared(placed, refused, (shared, froms) => ({
|
|
67
|
+
code: "lane_key_shared",
|
|
68
|
+
reason: `its lane key ${JSON.stringify(shared)} would be shared by rows filed under ${froms.map((k) => JSON.stringify(k)).join(" and ")}: the move does not merge two owners' rows into one lane.`,
|
|
69
|
+
}));
|
|
70
|
+
return { moved, refused };
|
|
71
|
+
}
|
|
72
|
+
function unshared(placed, refused, why) {
|
|
73
|
+
const fromsOf = new Map();
|
|
74
|
+
for (const p of placed)
|
|
75
|
+
fromsOf.set(p.scope, (fromsOf.get(p.scope) ?? new Set()).add(p.from));
|
|
76
|
+
const moved = [];
|
|
77
|
+
for (const p of placed) {
|
|
78
|
+
const froms = fromsOf.get(p.scope);
|
|
79
|
+
if (froms.size === 1)
|
|
80
|
+
moved.push({ row: p.row, scope: p.scope });
|
|
81
|
+
else
|
|
82
|
+
refused.push({ row: p.row, ...why(p.scope, [...froms]) });
|
|
83
|
+
}
|
|
84
|
+
return moved;
|
|
85
|
+
}
|
|
86
|
+
export function rollbackSchedulerStore(store) {
|
|
87
|
+
const rows = rowsOf(store, "rollback", (keys) => keys === "lane", '"lane"');
|
|
88
|
+
const placed = [];
|
|
89
|
+
const refused = [];
|
|
90
|
+
for (const row of rows) {
|
|
91
|
+
const key = row?.scope;
|
|
92
|
+
const lane = ["session", "durable"].find((l) => isLaneKey(l, key));
|
|
93
|
+
if (lane === undefined)
|
|
94
|
+
refused.push({ row, code: "row_invalid", reason: `the row's key is ${describeRejectedValue(key)}, not a lane's name, \`:\` and a non-empty owner.` });
|
|
95
|
+
else
|
|
96
|
+
placed.push({ row, scope: key.slice(lane.length + 1), from: key });
|
|
97
|
+
}
|
|
98
|
+
const moved = unshared(placed, refused, (_shared, froms) => ({
|
|
99
|
+
code: "bare_key_shared",
|
|
100
|
+
reason: `its bare key is shared by ${froms.map((k) => JSON.stringify(k)).join(" and ")}: an older release lists and stops them as one lane's rows.`,
|
|
101
|
+
}));
|
|
102
|
+
return { moved, refused };
|
|
103
|
+
}
|
|
@@ -19,24 +19,23 @@
|
|
|
19
19
|
* `createHandsToolkit` —— 与 present_plan/AskUserQuestion 同:这些工具都在 prepare-task 单独挂,那里有 spec.principal)。
|
|
20
20
|
*/
|
|
21
21
|
import type { AgentTool, ExecutionEnv, Result } from "../internal/harness-types.js";
|
|
22
|
-
import { SchedulerError, type SchedulerContext, type ScheduledTaskId, type ScheduledTaskSummary } from "../core/scheduler.js";
|
|
23
|
-
import { type
|
|
22
|
+
import { SchedulerError, type SchedulerReading, type SchedulerContext, type ScheduledTaskId, type ScheduledTaskSummary } from "../core/scheduler.js";
|
|
23
|
+
import { type EngineNotice } from "../core/engine-notice.js";
|
|
24
24
|
export declare const SCHEDULE_WAKEUP_TOOL_NAME = "ScheduleWakeup";
|
|
25
25
|
/** CronCreate-based autonomous-loop 哨兵(CC `Ldt`)。loop runtime(部署侧)在 fire 时解析回 autonomous-loop 指令。 */
|
|
26
26
|
export declare const AUTONOMOUS_LOOP_SENTINEL = "<<autonomous-loop>>";
|
|
27
27
|
/** ScheduleWakeup(dynamic-pacing)哨兵(CC `ePe`)——ScheduleWakeup 一律用 `-dynamic` 变体。 */
|
|
28
28
|
export declare const AUTONOMOUS_LOOP_DYNAMIC_SENTINEL = "<<autonomous-loop-dynamic>>";
|
|
29
|
+
/** wakeup intent 的保留 label:老 backend(list 不回 mode)时 stop 过滤的兜底键;店的迁移据它认出判不清车道的行。 */
|
|
30
|
+
export declare const WAKEUP_LABEL = "loop-wakeup";
|
|
29
31
|
/** Runner-held 上下文 + run-stop 出口,工具工厂闭包捕获(模型触不到)。 */
|
|
30
32
|
export interface SchedulerToolContext {
|
|
31
|
-
/**
|
|
32
|
-
* **会话腿**的越界隔离键(Runner 填 sessionId ?? isolation scope ?? taskId)。durable 腿不用这条链——它的键由
|
|
33
|
-
* {@link durableScopeOf} 从 isolation scope 独立铸(ruled 2026-08-03,见该函数注释)。
|
|
34
|
-
*/
|
|
35
|
-
scope: string;
|
|
36
|
-
/** 任务的人(`TaskSpec.principal`),原样交给宿主 capability;缺 `isolationScope` 时也是 durable 腿的键。 */
|
|
33
|
+
/** 任务的人(`TaskSpec.principal`),原样交给宿主 capability;缺 `isolationScope` 时也是 durable lane 的主人。 */
|
|
37
34
|
principal?: string;
|
|
38
|
-
/** 任务的 isolation scope(`TaskSpec.isolationScope
|
|
35
|
+
/** 任务的 isolation scope(`TaskSpec.isolationScope`):在场时是 durable lane 的主人(同一人的另一 scope 看不见这条 job)。 */
|
|
39
36
|
isolationScope?: string;
|
|
37
|
+
/** The session the run belongs to: the owner of the session lane (`session:<sessionId>`). Absent = the run has no session lane — the
|
|
38
|
+
* readers read the durable lane alone, and the two tools that schedule do not mount. */
|
|
40
39
|
sessionId?: string;
|
|
41
40
|
taskConfig?: unknown;
|
|
42
41
|
/** The user's zone as the engine judged it ({@link SchedulerContext.timeZone}); rides every context handed to the backend. */
|
|
@@ -45,26 +44,32 @@ export interface SchedulerToolContext {
|
|
|
45
44
|
* 保留(human-suspend saga 等共用同一 runner 原语;prepare-task 仍注入)——当前 scheduler 三件不消费。 */
|
|
46
45
|
requestStopAfterTurn?: () => void;
|
|
47
46
|
}
|
|
48
|
-
/** The
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export declare function
|
|
54
|
-
|
|
55
|
-
readonly taskId?: string | undefined;
|
|
56
|
-
}): string;
|
|
57
|
-
/** The two lanes of one run, each as the context the scheduler backend isolates by. */
|
|
47
|
+
/** The two lanes, the closed set a scheduler key starts with. */
|
|
48
|
+
export type LaneName = "session" | "durable";
|
|
49
|
+
/** The one spelling of a scheduler key: the lane's name, `:`, the owner. */
|
|
50
|
+
export declare function laneKeyOf(lane: LaneName, owner: string): string;
|
|
51
|
+
/** Whether `scope` is a key of `lane`: the lane's name, `:` and at least one more character. */
|
|
52
|
+
export declare function isLaneKey(lane: LaneName, scope: unknown): boolean;
|
|
53
|
+
/** The lanes of one run, each as the context the scheduler backend isolates by. Which lane an entry is on is {@link laneOfIntent}'s answer. */
|
|
58
54
|
export interface SchedulerLanes {
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
/** The entries bound to this session — a session-lifetime job, or a session wakeup (it ends with the session only on a backend that vouches for
|
|
56
|
+
* the session lifetime) — keyed `session:<session id>`. Absent for a run with no session. */
|
|
57
|
+
readonly session?: SchedulerContext;
|
|
58
|
+
/** Every other entry of the run's isolation scope, keyed `durable:<isolation scope>` (else `durable:default`): visible from every session of that scope. */
|
|
62
59
|
readonly durable: SchedulerContext;
|
|
63
60
|
}
|
|
64
|
-
/** The lanes of the run whose factory context is `ctx`: the session lane keyed by `ctx.
|
|
65
|
-
*
|
|
66
|
-
*
|
|
61
|
+
/** The lanes of the run whose factory context is `ctx`: the session lane keyed by `ctx.sessionId` when it has one, the durable lane by the
|
|
62
|
+
* isolation scope (else `default`). Derive `ctx` from a verified session / run — see the note above. A lane whose key does not come out
|
|
63
|
+
* of its lane's form (an empty or non-string session id) is refused. */
|
|
67
64
|
export declare function schedulerLanesOf(ctx: SchedulerToolContext): SchedulerLanes;
|
|
65
|
+
/** The lane an intent is filed on: the session lane for a job that ends with its session (`lifetime: "session"`) or a session wakeup
|
|
66
|
+
* (`mode: "session-wakeup"`), the durable lane for every other. Read off those two members only, never the label (a label is the
|
|
67
|
+
* caller's word: CronCreate may write the wakeup's label too). Scheduling picks a lane with it, and the store's move
|
|
68
|
+
* (`migrateSchedulerStore`) reads a stored row's lane with it. */
|
|
69
|
+
export declare function laneOfIntent(intent: {
|
|
70
|
+
readonly lifetime?: unknown;
|
|
71
|
+
readonly mode?: unknown;
|
|
72
|
+
}): LaneName;
|
|
68
73
|
/**
|
|
69
74
|
* Every entry of both lanes: the session lane's rows, then the durable lane's rows the first did not already list (a backend that does
|
|
70
75
|
* not filter by scope answers both lanes with the same rows; one id prints once). A lane that fails fails the whole read with that lane's
|
|
@@ -73,8 +78,8 @@ export declare function schedulerLanesOf(ctx: SchedulerToolContext): SchedulerLa
|
|
|
73
78
|
*/
|
|
74
79
|
export declare function listScheduled(env: ExecutionEnv, lanes: SchedulerLanes): Promise<Result<ScheduledTaskSummary[], SchedulerError>>;
|
|
75
80
|
/**
|
|
76
|
-
* Cancel one entry by id, on the lane that holds it
|
|
77
|
-
* (both belong to this run, so reading both widens nothing): a backend whose `cancel` answers ok for an id it does not hold would let a
|
|
81
|
+
* Cancel one entry by id, on the lane that holds it (a run with the durable lane alone asks that lane, with no listing). A bare id no longer
|
|
82
|
+
* names its lane, so the holder is found by listing the lanes in order until one holds it (both belong to this run, so reading both widens nothing): a backend whose `cancel` answers ok for an id it does not hold would let a
|
|
78
83
|
* first-lane try swallow the call while the real job on the other lane stays live under a receipt that says it is gone. Only when the
|
|
79
84
|
* listing is unavailable, or the id is not in the snapshot, does it fall back to trying each lane in turn — and then only a `not_found`
|
|
80
85
|
* is a reason to ask the next lane. The result is the backend's own: `not_found` for an id neither lane holds, `unsupported` for an
|
|
@@ -94,6 +99,15 @@ export declare function cutToUnits(text: string, limit: number): string;
|
|
|
94
99
|
*/
|
|
95
100
|
export declare function cronToHuman(expr: string): string;
|
|
96
101
|
/**
|
|
97
|
-
*
|
|
102
|
+
* Tells the operator, once per declared value per notice sink, that the env's scheduler backend offers the seam but does not declare its
|
|
103
|
+
* store holds lane keys — so {@link createSchedulerTools} mounts nothing on it (`config.scheduler_store_unmoved`). Every other reading:
|
|
104
|
+
* silence. `scheduler` is the leg's one reading of the declaration ({@link readSchedulerDeclaration}).
|
|
98
105
|
*/
|
|
99
|
-
export declare function
|
|
106
|
+
export declare function announceSchedulerStoreUnmoved(scheduler: SchedulerReading, onNotice: ((notice: EngineNotice) => void) | undefined): void;
|
|
107
|
+
/**
|
|
108
|
+
* 构建 scheduler 工具(仅当 `env` 暴露 {@link SchedulerCapability}、`supported:true` 且店声明 `scopeKeys: "lane"`;否则返回 `[]`,INERT):有会话 = CronCreate /
|
|
109
|
+
* CronDelete / CronList / ScheduleWakeup 四只,无会话 = CronDelete / CronList 两只(只读写 durable lane)。`scheduler` = 一条腿对声明的那一次读数
|
|
110
|
+
* ({@link readSchedulerDeclaration};缺 = 这里读一次):挂载与工具执行时读的能力位都出自它;CronList / CronDelete 经 {@link listScheduled} /
|
|
111
|
+
* {@link cancelScheduled},那两只读口每次调用再读一次声明(声明在实例寿命内不变)。
|
|
112
|
+
*/
|
|
113
|
+
export declare function createSchedulerTools(env: ExecutionEnv, ctx: SchedulerToolContext, scheduler?: SchedulerReading): AgentTool[];
|