@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
|
@@ -5,7 +5,7 @@ import { countLines, retireRead, witnessesAfterDelivery } from "../../tools/fs/f
|
|
|
5
5
|
import { expandHomeTilde, isAbsoluteForFamily, lexicalViewOf, pathFamilyOf, sha256, startsWithDriveLetter, withinAnyRoot } from "../../tools/fs/safety.js";
|
|
6
6
|
import { relativeUnderRoot } from "../sensitive-path-policy.js";
|
|
7
7
|
import { ORG_ADJUDICATION_TIMEOUT_MS } from "../permission-rule-org.js";
|
|
8
|
-
import { isInstructionLaneEntry, mintInstructionFrames } from "../user-attachment.js";
|
|
8
|
+
import { instructionFrameOwnerOf, isInstructionLaneEntry, mintInstructionFrames } from "../user-attachment.js";
|
|
9
9
|
import { deliverEngineNotice } from "../engine-notice.js";
|
|
10
10
|
import { agentIdOf } from "../leg-identity.js";
|
|
11
11
|
import { describeRejectedValue } from "../tool-search-setting.js";
|
|
@@ -399,6 +399,8 @@ export function createNestedMemoryLane(seat) {
|
|
|
399
399
|
queue.unshift(...back);
|
|
400
400
|
};
|
|
401
401
|
let primed;
|
|
402
|
+
const firstLoadIncluded = new Map();
|
|
403
|
+
const firstLoadWithheld = new Map();
|
|
402
404
|
const hostTexts = decl.hostRules.map((t) => {
|
|
403
405
|
const shown = processInstructionText(normalizeFileText(t.text), decl.includes);
|
|
404
406
|
return { ...t, shown, owner: OWNER_OF_LEVEL[t.level], anchored: hands !== undefined && isAbsoluteHostPath(t.name), conditional: t.rule && shown.globs !== undefined };
|
|
@@ -426,6 +428,12 @@ export function createNestedMemoryLane(seat) {
|
|
|
426
428
|
const leg = seat.leg();
|
|
427
429
|
if (leg === undefined || seat.signal.aborted)
|
|
428
430
|
return [];
|
|
431
|
+
const forManifest = ask.forManifest === true;
|
|
432
|
+
const recordIncluded = (item, key) => {
|
|
433
|
+
if (forManifest && item.from !== undefined && !firstLoadIncluded.has(key)) {
|
|
434
|
+
firstLoadIncluded.set(key, Object.freeze({ path: key, includedBy: item.from.key, spelled: item.from.spelled }));
|
|
435
|
+
}
|
|
436
|
+
};
|
|
429
437
|
const accesses = new Set();
|
|
430
438
|
const current = new Map();
|
|
431
439
|
const firstLoad = seen === undefined;
|
|
@@ -490,15 +498,29 @@ export function createNestedMemoryLane(seat) {
|
|
|
490
498
|
fresh.push(d);
|
|
491
499
|
say();
|
|
492
500
|
};
|
|
493
|
-
const withheld = (item, reason, past, target
|
|
494
|
-
if (
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
501
|
+
const withheld = (item, reason, past, target, blockedAfterApproval) => {
|
|
502
|
+
if (forManifest && (item.rule === "any" || item.from !== undefined || reason === "too_many_texts" || reason === "unanchored")) {
|
|
503
|
+
const wKey = `${item.path}\u0000${reason}\u0000${target ?? ""}\u0000${item.from?.key ?? ""}\u0000${item.from?.spelled ?? ""}`;
|
|
504
|
+
if (!firstLoadWithheld.has(wKey)) {
|
|
505
|
+
firstLoadWithheld.set(wKey, Object.freeze({
|
|
506
|
+
path: item.path,
|
|
507
|
+
reason,
|
|
508
|
+
...(target !== undefined ? { target } : {}),
|
|
509
|
+
...(item.from !== undefined ? { includedBy: item.from.key, spelled: item.from.spelled } : {}),
|
|
510
|
+
...(blockedAfterApproval !== undefined ? { blockedAfterApproval } : {}),
|
|
511
|
+
}));
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
once(INSTRUCTIONS_WITHHELD, item.path, target === undefined ? reason : `${reason}\n${target}`, () => {
|
|
515
|
+
if (delegated)
|
|
516
|
+
return;
|
|
517
|
+
const path = item.path;
|
|
518
|
+
const r = rootLevelOf(path);
|
|
519
|
+
const what = past !== undefined ? `An instruction text the deployment supplied, the first of ${past} past the ${NESTED_MEMORY_MAX_HOST_RULES} a task carries,` : item.from !== undefined ? `An instruction file that ${item.from.key} includes (\`@${item.from.spelled}\`)` : `An instruction file of ${r === 0 ? "the task root" : r > 0 ? "an additional working directory" : "a directory the model accessed"}`;
|
|
520
|
+
const via = item.from !== undefined ? { includedBy: item.from.key, spelled: item.from.spelled } : {};
|
|
521
|
+
deliverEngineNotice(seat.deps.onNotice, { code: INSTRUCTIONS_WITHHELD, message: `${what} was not loaded: ${path} (${WITHHELD_TEXT[reason]}). ${WITHHELD_WAY_OUT[reason]}`, detail: { path, reason, sessionId: leg.sessionId, runId: leg.runId, ...via, ...(target !== undefined ? { target } : {}) } });
|
|
522
|
+
});
|
|
523
|
+
};
|
|
502
524
|
const tellOperator = (lane, path, why, sentence) => once(lane, path, why, () => {
|
|
503
525
|
try {
|
|
504
526
|
seat.deps.onError?.(new Error(sentence), { phase: "degraded", sessionId: leg.sessionId, classification: "attachment-read" });
|
|
@@ -510,10 +532,10 @@ export function createNestedMemoryLane(seat) {
|
|
|
510
532
|
const unlimited = (path) => tellOperator("nested_memory_rule_paths", path, "no_limit", `instruction rule ${path} names \`paths:\` but it reads as no limit (nothing listed, only \`**\`, or a form the engine does not recognise), so the rule applies to every file; to limit it, list the globs (\`paths:\` then \`- src/**\` lines, or \`paths: [src/**, lib/**]\`); if every file is meant, remove the key`);
|
|
511
533
|
const spansLines = (path) => tellOperator("nested_memory_rule_paths", path, "spans_lines", `instruction rule ${path} gives \`paths:\` as one text over several lines, which reads as a single glob that matches no file, so the rule is never loaded; for several globs list them (\`paths:\` then \`- src/**\` lines) or write them on one line separated by commas (\`paths: src/**, lib/**\`)`);
|
|
512
534
|
const outside = new Map();
|
|
513
|
-
const refusedOutside = (item, wide, key, target) => {
|
|
535
|
+
const refusedOutside = (item, wide, key, target, targetOk = false) => {
|
|
514
536
|
const held = outside.get(item.path);
|
|
515
537
|
const edge = !foundByLane(item) || item.approved === true;
|
|
516
|
-
const told = held === undefined || (edge && !held.edge) ? { item, edge, key: key ?? item.path, target } : held;
|
|
538
|
+
const told = held === undefined || (edge && !held.edge) ? { item, edge, key: key ?? item.path, target, targetOk } : held;
|
|
517
539
|
outside.set(item.path, { ...told, wide: wide || held?.wide === true });
|
|
518
540
|
};
|
|
519
541
|
const reads = [];
|
|
@@ -589,8 +611,8 @@ export function createNestedMemoryLane(seat) {
|
|
|
589
611
|
if (info.value.kind === "directory")
|
|
590
612
|
return [];
|
|
591
613
|
const heldToItsRoots = async (key) => foundByLane(item) && item.approved !== true && !(await approvedByRequest(key));
|
|
592
|
-
const outsideItsRoot = (key, judged) => {
|
|
593
|
-
refusedOutside(item, false, key, judged);
|
|
614
|
+
const outsideItsRoot = (key, judged, targetOk) => {
|
|
615
|
+
refusedOutside(item, false, key, judged, targetOk);
|
|
594
616
|
return member !== undefined ? [member] : [];
|
|
595
617
|
};
|
|
596
618
|
const target = await hands.reader.resolveTarget(item.path, { signal: seat.signal });
|
|
@@ -600,13 +622,13 @@ export function createNestedMemoryLane(seat) {
|
|
|
600
622
|
withheld(item, "rule_denied");
|
|
601
623
|
else if (card === "path_not_in_root") {
|
|
602
624
|
const judged = judgedKeyOf(target);
|
|
603
|
-
return (await heldToItsRoots(judged)) ? outsideItsRoot(undefined, judged) : (refusedOutside(item, true), []);
|
|
625
|
+
return (await heldToItsRoots(judged)) ? outsideItsRoot(undefined, judged, false) : (refusedOutside(item, true), []);
|
|
604
626
|
}
|
|
605
627
|
return [];
|
|
606
628
|
}
|
|
607
629
|
const key = target.key;
|
|
608
630
|
if (!insideItsRoots(item.root, key) && (await heldToItsRoots(key)))
|
|
609
|
-
return outsideItsRoot(key, key);
|
|
631
|
+
return outsideItsRoot(key, key, true);
|
|
610
632
|
if (visited.has(key) || inFlight.has(key))
|
|
611
633
|
return [];
|
|
612
634
|
const stat = info.value.kind === "symlink" ? await hands.env.fileInfo(key, seat.signal).catch(() => undefined) : info;
|
|
@@ -616,6 +638,7 @@ export function createNestedMemoryLane(seat) {
|
|
|
616
638
|
const entry = state.get(key);
|
|
617
639
|
if (entry !== undefined && entry.lastReadAt === mtime && (!decl.includes || includesBy.has(key))) {
|
|
618
640
|
visited.add(key);
|
|
641
|
+
recordIncluded(item, key);
|
|
619
642
|
return includesAt(includesBy.get(key) ?? [], item, key);
|
|
620
643
|
}
|
|
621
644
|
p.count++;
|
|
@@ -624,7 +647,7 @@ export function createNestedMemoryLane(seat) {
|
|
|
624
647
|
try {
|
|
625
648
|
const verdict = await hands.judge({ file_path: item.path, ...(face !== undefined ? { face } : {}) }, NESTED_MEMORY_PROBE_FACE, { deadlineAt });
|
|
626
649
|
if (verdict.verdict !== "no_objection") {
|
|
627
|
-
withheld(item, verdict
|
|
650
|
+
withheld(item, readJudgeBlockOf(verdict));
|
|
628
651
|
return [];
|
|
629
652
|
}
|
|
630
653
|
if (verdict.judged !== undefined && verdict.judged !== key) {
|
|
@@ -664,8 +687,10 @@ export function createNestedMemoryLane(seat) {
|
|
|
664
687
|
const more = includesAt(targets, item, key);
|
|
665
688
|
if (pending.has(key))
|
|
666
689
|
return more;
|
|
667
|
-
if (entry !== undefined && entry.hash === hash)
|
|
690
|
+
if (entry !== undefined && entry.hash === hash) {
|
|
691
|
+
recordIncluded(item, key);
|
|
668
692
|
return more;
|
|
693
|
+
}
|
|
669
694
|
if (shown.content.trim() === "") {
|
|
670
695
|
if (entry !== undefined && isInstructionLaneEntry(entry))
|
|
671
696
|
withdraw(key, item);
|
|
@@ -681,6 +706,7 @@ export function createNestedMemoryLane(seat) {
|
|
|
681
706
|
const read = {
|
|
682
707
|
supply: "path",
|
|
683
708
|
owner: item.owner ?? "repository",
|
|
709
|
+
...(item.from !== undefined ? { included: true } : {}),
|
|
684
710
|
layer,
|
|
685
711
|
label: key,
|
|
686
712
|
text: cut.text,
|
|
@@ -697,6 +723,7 @@ export function createNestedMemoryLane(seat) {
|
|
|
697
723
|
},
|
|
698
724
|
};
|
|
699
725
|
reads.push({ read, item, key });
|
|
726
|
+
recordIncluded(item, key);
|
|
700
727
|
return more;
|
|
701
728
|
};
|
|
702
729
|
const includeTargetsOf = (paths, from) => {
|
|
@@ -813,7 +840,7 @@ export function createNestedMemoryLane(seat) {
|
|
|
813
840
|
withheld({ path: spelled, from: { key: t.name, spelled } }, "unanchored");
|
|
814
841
|
const cut = cutInstructionText(t.shown.content, cap, cpt);
|
|
815
842
|
const layer = t.conditional ? "nested" : "root";
|
|
816
|
-
if (last?.text !== cut.text || last.layer !== layer)
|
|
843
|
+
if (last?.text !== cut.text || last.layer !== layer || (last.owner !== undefined && last.owner !== t.owner))
|
|
817
844
|
hostRead(t.name, layer, t.owner, cut);
|
|
818
845
|
}
|
|
819
846
|
for (const [name, last] of shownNow)
|
|
@@ -822,9 +849,27 @@ export function createNestedMemoryLane(seat) {
|
|
|
822
849
|
}
|
|
823
850
|
queueOwed(hostIncludes.filter(claim), true);
|
|
824
851
|
await drain();
|
|
825
|
-
for (const r of outside.values())
|
|
826
|
-
if (
|
|
827
|
-
|
|
852
|
+
for (const r of outside.values()) {
|
|
853
|
+
if (visited.has(r.key) || (inFlight.has(r.key) && !withdrawing.has(r.key)) || queued.has(itemId(r.item)))
|
|
854
|
+
continue;
|
|
855
|
+
let blockedAfterApproval;
|
|
856
|
+
if (!r.wide && forManifest && hands !== undefined) {
|
|
857
|
+
if (!r.targetOk)
|
|
858
|
+
blockedAfterApproval = "outside_roots";
|
|
859
|
+
else {
|
|
860
|
+
try {
|
|
861
|
+
const face = hands.readFace();
|
|
862
|
+
const verdict = await hands.judge({ file_path: r.item.path, ...(face !== undefined ? { face } : {}) }, NESTED_MEMORY_PROBE_FACE, { deadlineAt });
|
|
863
|
+
blockedAfterApproval = readJudgeBlockOf(verdict);
|
|
864
|
+
}
|
|
865
|
+
catch (err) {
|
|
866
|
+
unread(r.item.path, thrownText(err));
|
|
867
|
+
blockedAfterApproval = "admission_unknown";
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
withheld(r.item, r.wide ? "outside_roots" : "outside_its_root", undefined, r.wide ? undefined : r.target, blockedAfterApproval);
|
|
872
|
+
}
|
|
828
873
|
const includeReads = reads.splice(0);
|
|
829
874
|
reads.push(...rootLayer, ...includeReads, ...familyReads, ...nestedLayer);
|
|
830
875
|
if (fresh.length > 0) {
|
|
@@ -868,7 +913,7 @@ export function createNestedMemoryLane(seat) {
|
|
|
868
913
|
if (primed !== undefined)
|
|
869
914
|
return;
|
|
870
915
|
const echo = { fn: undefined };
|
|
871
|
-
primed = { reads: await collect({}, echo), echo };
|
|
916
|
+
primed = { reads: await collect({ forManifest: true }, echo), echo };
|
|
872
917
|
},
|
|
873
918
|
async load(ask) {
|
|
874
919
|
const held = primed;
|
|
@@ -902,8 +947,10 @@ export function createNestedMemoryLane(seat) {
|
|
|
902
947
|
return reads.length === 0 ? [] : fitLoad(reads, leg).minted.frames;
|
|
903
948
|
},
|
|
904
949
|
selected() {
|
|
905
|
-
|
|
906
|
-
|
|
950
|
+
const withheldList = [...firstLoadWithheld.values()];
|
|
951
|
+
if (hands === undefined) {
|
|
952
|
+
return withheldList.length > 0 ? Object.freeze({ selected: Object.freeze([]), withheld: Object.freeze(withheldList) }) : undefined;
|
|
953
|
+
}
|
|
907
954
|
const keys = roots.map(() => new Set());
|
|
908
955
|
for (const key of [...state.keys(), ...inFlight]) {
|
|
909
956
|
const r = withdrawing.has(key) ? -1 : rootLevelOf(key);
|
|
@@ -919,19 +966,31 @@ export function createNestedMemoryLane(seat) {
|
|
|
919
966
|
return Object.freeze([...keys[r]].map((k) => relIn(r, k)).sort((a, b) => rank(a) - rank(b) || (a < b ? -1 : a > b ? 1 : 0)));
|
|
920
967
|
};
|
|
921
968
|
const additional = roots.slice(1).map((x, i) => Object.freeze({ directory: x.directory, selected: of(i + 1) }));
|
|
922
|
-
|
|
969
|
+
const included = [...firstLoadIncluded.entries()].filter(([k]) => !withdrawing.has(k) && (state.has(k) || inFlight.has(k))).map(([, v]) => v);
|
|
970
|
+
return Object.freeze({
|
|
971
|
+
selected: of(0),
|
|
972
|
+
...(decl.additionalDirectories ? { additionalDirectories: Object.freeze(additional) } : {}),
|
|
973
|
+
...(included.length > 0 ? { included: Object.freeze(included) } : {}),
|
|
974
|
+
...(withheldList.length > 0 ? { withheld: Object.freeze(withheldList) } : {}),
|
|
975
|
+
});
|
|
923
976
|
},
|
|
924
977
|
isMember,
|
|
925
978
|
};
|
|
926
979
|
}
|
|
927
|
-
|
|
980
|
+
function readJudgeBlockOf(verdict) {
|
|
981
|
+
return verdict.verdict === "no_objection" ? undefined : verdict.verdict === "deny" ? "rule_denied" : verdict.verdict === "ask" ? "approval_required" : "admission_unknown";
|
|
982
|
+
}
|
|
983
|
+
export async function primeInstructionReading(lane, report) {
|
|
928
984
|
try {
|
|
929
985
|
await lane.prime();
|
|
930
986
|
}
|
|
931
987
|
catch (err) {
|
|
932
988
|
report(asThrownError(err));
|
|
933
989
|
}
|
|
934
|
-
|
|
990
|
+
return lane.selected();
|
|
991
|
+
}
|
|
992
|
+
export async function primeInstructionLane(lane, manifest, report) {
|
|
993
|
+
const selected = await primeInstructionReading(lane, report);
|
|
935
994
|
if (selected !== undefined)
|
|
936
995
|
manifest.instructions = selected;
|
|
937
996
|
}
|
|
@@ -941,8 +1000,10 @@ function lastHostTexts(messages) {
|
|
|
941
1000
|
const a = userAttachmentOf(m);
|
|
942
1001
|
if (a === undefined || a.supply !== "content_text" || (a.origin !== "nested_memory" && a.origin !== "project_instructions"))
|
|
943
1002
|
continue;
|
|
944
|
-
const
|
|
945
|
-
|
|
1003
|
+
const content = m.content;
|
|
1004
|
+
const blocks = content.slice(a.dataBlocks.start, a.dataBlocks.end);
|
|
1005
|
+
const opening = content[0]?.type === "text" ? (content[0].text ?? "") : "";
|
|
1006
|
+
out.set(a.label, { text: a.withdraws !== undefined ? undefined : blocks.map((b) => (b.type === "text" ? (b.text ?? "") : "")).join(""), layer: a.origin === "project_instructions" ? "root" : "nested", owner: instructionFrameOwnerOf(opening) });
|
|
946
1007
|
}
|
|
947
1008
|
return out;
|
|
948
1009
|
}
|
|
@@ -59,8 +59,9 @@ import { type PathRuleBases } from "../permission-rule-model.js";
|
|
|
59
59
|
import { type BoundPathRule, type HeadLeads } from "../path-rule-binding.js";
|
|
60
60
|
import { type RuleStoreFault } from "../rule-store-fault.js";
|
|
61
61
|
import type { RunnerDeps } from "../runner-deps.js";
|
|
62
|
-
import { type JudgedPathRow, type PathRuleDenyRow, type ReadDenyBuiltinConfig, type ReadDenyEntry, type ReadDenySeat, type WriteDenyMatcher } from "../../tools/fs/read-deny.js";
|
|
62
|
+
import { type JudgedPathRow, type PathRuleDenyRow, type ReadDenyBuiltinConfig, type ReadDenyEntry, type ReadDenyRootAnswer, type ReadDenySeat, type WriteDenyMatcher } from "../../tools/fs/read-deny.js";
|
|
63
63
|
import { type HomeViewSource, type PlacedReadDenyMatcher } from "../../tools/fs/read-deny-home.js";
|
|
64
|
+
import { type ReadStationMember } from "../../tools/fs/file-read-check.js";
|
|
64
65
|
import { type ShellReadCheck } from "../../tools/fs/shell-read-check.js";
|
|
65
66
|
import type { ReadAskRow } from "../../tools/fs/shell-read-judge.js";
|
|
66
67
|
import { type SessionPermissionRules } from "../session-policy-store.js";
|
|
@@ -208,8 +209,9 @@ export interface PersonPathRows {
|
|
|
208
209
|
* asking the store nothing new, the prepare read for the first request, and the newest read asked since the previous
|
|
209
210
|
* request that the store has left unanswered past its bound. Bounded ({@link PERSON_READ_BOUND_MS}); never rejects. */
|
|
210
211
|
forRequest(): Promise<PersonRowsRead>;
|
|
211
|
-
/** Settles once the tables a reader takes are compiled
|
|
212
|
-
*
|
|
212
|
+
/** Settles once the tables a reader takes are compiled and the scopes of the bad rows of the read they stand on are judged (or
|
|
213
|
+
* their judgment ran out of time): a pinned call's own; any other reader's (no id, or a call holding no pin), the unit's newest —
|
|
214
|
+
* through every change that lands meanwhile, within {@link PATH_TABLES_READY_BOUND_MS} —
|
|
213
215
|
* or at `signal` or the run's cut ({@link PersonPathRowsConfig.signal}). Never rejects: a reader whose wait was cut
|
|
214
216
|
* checks its own signal and refuses; tables still compiling, or that could not be compiled, refuse at the read
|
|
215
217
|
* ({@link PathTablesFacade.forCall}). */
|
|
@@ -304,6 +306,12 @@ export declare function readRootsOver(seats: {
|
|
|
304
306
|
type WriteDenySeat = {
|
|
305
307
|
readonly writeDenyMatch?: (p: string) => string | null;
|
|
306
308
|
readonly writeDenyGuardsReads?: (pattern: string) => boolean;
|
|
309
|
+
readonly writeDenyUnder?: (p: string) => ReadDenyRootAnswer;
|
|
310
|
+
readonly writeDenyAtOrBelow?: (p: string) => string | null;
|
|
311
|
+
readonly writeDenyNamed?: {
|
|
312
|
+
readonly rows: readonly string[];
|
|
313
|
+
readonly ledBy: (entryName: string) => string | null;
|
|
314
|
+
};
|
|
307
315
|
};
|
|
308
316
|
export declare function denySeatsOf(t: PathTables): {
|
|
309
317
|
readonly read: ReadDenySeat;
|
|
@@ -319,10 +327,7 @@ export declare function denySeatsOf(t: PathTables): {
|
|
|
319
327
|
* read in is vouched for, as it would have been. (A partition of those rows that could not be read reaches the station on
|
|
320
328
|
* the boundary it judges with — {@link PersonPathRows.unreadFor} — where it vouches for nothing.)
|
|
321
329
|
*/
|
|
322
|
-
export declare function onPinnedRead(rows: PersonPathRows, stations: ReadonlyArray<
|
|
323
|
-
readonly check: ShellReadCheck;
|
|
324
|
-
readonly tools: ReadonlySet<string>;
|
|
325
|
-
}>): ShellReadCheck | undefined;
|
|
330
|
+
export declare function onPinnedRead(rows: PersonPathRows, stations: ReadonlyArray<ReadStationMember>): ShellReadCheck | undefined;
|
|
326
331
|
/**
|
|
327
332
|
* One read station judged ahead of the gate's fold — where an inherited station settles an ancestor's question about a call
|
|
328
333
|
* before the call reaches the station's own seat: the run's newest tables, once they are ready, and no read taken (a call's
|
|
@@ -362,19 +367,17 @@ export declare function personPathRowsOfTask(t: {
|
|
|
362
367
|
/**
|
|
363
368
|
* The run's ONE notice of stored rule rows (`config.entries_not_applied`, kind `stored_rule_row`; before 7.70.0 the code
|
|
364
369
|
* `permission.rule_row_dropped`; audience user): the person's store served rows that take no part in the
|
|
365
|
-
* checks (`EffectivePermissionRules.droppedRows`) —
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
* read
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
*
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
* `element` (`partition`, `index`, what was `read`); `count` is every row of both, `identity` their whole set. The trace keeps every
|
|
377
|
-
* read's line.
|
|
370
|
+
* checks (`EffectivePermissionRules.droppedRows`) — project-scoped rows whose scope root is not a complete absolute path, allow rows
|
|
371
|
+
* not written the way a rule is stored or a part of which could not be read, and (for host-supplied views only) `element` entries —
|
|
372
|
+
* or rows it could not read whole (`EffectivePermissionRules.unreadableRows`, either personal partition's): deny/ask rows whose
|
|
373
|
+
* identity read (they apply as written), deny/ask rows whose identity did not read (strictest reading), and rows whose behavior word
|
|
374
|
+
* could not be read (`member: "behavior"`, strictest reading, without claiming `behavior: "ask"` on the notice entry); minted by
|
|
375
|
+
* whichever read met them first, once per run. The sentence names no path and one clause per kind of row present
|
|
376
|
+
* ({@link DROPPED_ROW_SENTENCE}, then {@link UNREADABLE_ROW_SENTENCE}); the rows ride the detail's `entries` (the left-out rows first,
|
|
377
|
+
* `entriesNotAppliedDetail`): `entry` is the rule text as the store served it, through the one reading ({@link noticeRuleText}) every
|
|
378
|
+
* kind's `entry` uses, `reason` the row's word, `scopeRoot` on a scope row neutralized and bounded, `member` on a row a part of which
|
|
379
|
+
* could not be read, `behavior` on a deny or ask row whose behavior word read, and `element` on a host-supplied element entry; `count`
|
|
380
|
+
* is every row of both, `identity` their whole set. The trace keeps every read's line.
|
|
378
381
|
*/
|
|
379
382
|
export declare function ruleRowsDroppedNotice(onNotice: RunnerDeps["onNotice"], ids: {
|
|
380
383
|
readonly sessionId: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ownerStoreOf, ruleSourceOf } from "../permission-rule-provider.js";
|
|
2
2
|
import { holdsRuleWriter, sameRuleIdentity } from "../permission-rule-store.js";
|
|
3
|
-
import { identityUnread, reachesEveryCall, unreadableRowFaultsOf } from "./unreadable-person-rows.js";
|
|
3
|
+
import { identityUnread, reachesEveryCall, unreadableRowFaultsOf, unreadableRowsInScope } from "./unreadable-person-rows.js";
|
|
4
4
|
import { readPrincipal } from "../principal-name.js";
|
|
5
5
|
import { ORG_ADJUDICATION_TIMEOUT_MS, orgResolutionHeld, orgRowsStandOverFace } from "../permission-rule-org.js";
|
|
6
6
|
import { canonicalize } from "../canonical-json.js";
|
|
@@ -16,7 +16,7 @@ import { deliverEngineNotice } from "../engine-notice.js";
|
|
|
16
16
|
import { entriesNotAppliedDetail } from "../entries-not-applied.js";
|
|
17
17
|
import { compileReadDeny, compileWriteDeny, readDenySeat, rowsWhereTheyLead } from "../../tools/fs/read-deny.js";
|
|
18
18
|
import { carryHomeViews, placeReadDenyAtHome, readDenyOver } from "../../tools/fs/read-deny-home.js";
|
|
19
|
-
import { composeReadChecks } from "../../tools/fs/file-read-check.js";
|
|
19
|
+
import { composeReadChecks, readStationsHold } from "../../tools/fs/file-read-check.js";
|
|
20
20
|
import { readStationMemberOf } from "../../tools/fs/shell-read-check.js";
|
|
21
21
|
import { compileSessionRuleBucket, readSessionRulesShape, unreadableDenyEntries } from "../session-policy-store.js";
|
|
22
22
|
import { readRuleEntry, wholeToolEntryOf } from "../allow-entry.js";
|
|
@@ -112,15 +112,41 @@ export function createPersonPathRows(cfg) {
|
|
|
112
112
|
if (changed && compile !== undefined)
|
|
113
113
|
refreshUnitTables();
|
|
114
114
|
};
|
|
115
|
+
const hasDroppedIn = (p, view) => p === "durable" && (view.droppedRows ?? []).some((d) => d.reason === "scope_root_not_absolute");
|
|
115
116
|
const readRows = (p, view, before) => {
|
|
116
117
|
const rows = view.rules.filter((r) => partitionOf(r.source) === p);
|
|
117
|
-
if (!unreadableOf(p, view).some(identityUnread))
|
|
118
|
+
if (!unreadableOf(p, view).some(identityUnread) && !hasDroppedIn(p, view))
|
|
118
119
|
return rows;
|
|
119
|
-
|
|
120
|
+
const removed = view.removed ?? [];
|
|
121
|
+
return [...rows, ...(before?.rows ?? []).filter((w) => tightening(w) && !rows.some((r) => sameRuleIdentity(r, w)) && !removed.some((t) => sameRuleIdentity(t, w)))];
|
|
120
122
|
};
|
|
121
123
|
const lawed = (p, read) => read !== undefined ? read : (unit[p].ok?.rows ?? []).filter(tightening);
|
|
122
124
|
const lawedUnreadable = (p, view) => (view !== undefined ? unreadableOf(p, view) : (unit[p].ok?.unreadable ?? []));
|
|
123
|
-
const
|
|
125
|
+
const outOfScope = new WeakSet();
|
|
126
|
+
const scopesPending = new Set();
|
|
127
|
+
const scopesOf = new WeakMap();
|
|
128
|
+
const judgeScopes = (view) => {
|
|
129
|
+
if (scopesOf.has(view))
|
|
130
|
+
return scopesOf.get(view);
|
|
131
|
+
const project = holdsPersonRows ? (view.unreadableRows ?? []).filter((u) => identityUnread(u) && u.scope?.kind === "project") : [];
|
|
132
|
+
let judged;
|
|
133
|
+
if (project.length > 0) {
|
|
134
|
+
const inScope = projectScopeIdentity(project.map((u) => ({ scope: u.scope })), cfg.rootCanonical, cfg.leads).then((scopeIdentity) => new Set(unreadableRowsInScope(project, READ_RULE_TOOL, { cwd: cfg.root, sessionId: cfg.sessionId, ...(scopeIdentity !== undefined ? { scopeIdentity } : {}) })));
|
|
135
|
+
const settled = withGateTimeout(inScope, PATH_TABLES_READY_BOUND_MS, cfg.signal, "personRowScopes").then((rows) => {
|
|
136
|
+
for (const u of project)
|
|
137
|
+
if (!rows.has(u))
|
|
138
|
+
outOfScope.add(u);
|
|
139
|
+
}, () => undefined);
|
|
140
|
+
judged = settled;
|
|
141
|
+
scopesPending.add(settled);
|
|
142
|
+
void settled.then(() => scopesPending.delete(settled));
|
|
143
|
+
}
|
|
144
|
+
scopesOf.set(view, judged);
|
|
145
|
+
return judged;
|
|
146
|
+
};
|
|
147
|
+
const readScopes = new WeakMap();
|
|
148
|
+
const reachesEveryJudgment = (u) => reachesEveryCall(u) && !outOfScope.has(u);
|
|
149
|
+
const latestUnread = () => holdsPersonRows && partitions.some((p) => unit[p].failedSeq > (unit[p].ok?.seq ?? 0) || (unit[p].ok?.unreadable ?? []).some(reachesEveryJudgment));
|
|
124
150
|
const unitLatestRules = () => partitions.flatMap((p) => {
|
|
125
151
|
const cell = unit[p];
|
|
126
152
|
return lawed(p, cell.ok !== undefined && cell.failedSeq <= cell.ok.seq ? cell.ok.rows : undefined);
|
|
@@ -146,12 +172,25 @@ export function createPersonPathRows(cfg) {
|
|
|
146
172
|
cfg.onRowsDropped(view.droppedRows, view.unreadableRows);
|
|
147
173
|
if (holdsPersonRows && view.unreadable !== undefined)
|
|
148
174
|
announce(at, view.unreadable, faultsOfView(view));
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
175
|
+
const tellUnread = () => {
|
|
176
|
+
const unreadRows = holdsPersonRows ? (view.unreadableRows ?? []).filter((u) => identityUnread(u) && !outOfScope.has(u)) : [];
|
|
177
|
+
if (unreadRows.length > 0)
|
|
178
|
+
cfg.onUnread(at, unreadableRowFaultsOf(unreadRows), unreadRows.length);
|
|
179
|
+
};
|
|
180
|
+
const scoped = judgeScopes(view);
|
|
181
|
+
if (scoped === undefined)
|
|
182
|
+
tellUnread();
|
|
183
|
+
else
|
|
184
|
+
void scoped.then(tellUnread);
|
|
152
185
|
land(outcomeOf(view));
|
|
153
186
|
}, answer);
|
|
154
|
-
const read = withGateTimeout(raw, PERSON_READ_BOUND_MS, cfg.signal, "personRules").then((view) =>
|
|
187
|
+
const read = withGateTimeout(raw, PERSON_READ_BOUND_MS, cfg.signal, "personRules").then((view) => {
|
|
188
|
+
const out = readOf(outcomeOf(view));
|
|
189
|
+
const scoped = judgeScopes(view);
|
|
190
|
+
if (scoped !== undefined)
|
|
191
|
+
readScopes.set(out, scoped);
|
|
192
|
+
return out;
|
|
193
|
+
}, (err) => {
|
|
155
194
|
const failure = gateWaitFailureOf(err);
|
|
156
195
|
const cut = failure === "aborted";
|
|
157
196
|
const faults = [{ sources: sourcesOf(partitions), reason: failure === "timeout" ? "no_answer" : ruleStoreFaultReasonOf(err) }];
|
|
@@ -305,6 +344,9 @@ export function createPersonPathRows(cfg) {
|
|
|
305
344
|
return;
|
|
306
345
|
await withGateTimeout(cell.settled, left, signal, "pathTablesReady").catch(() => undefined);
|
|
307
346
|
}
|
|
347
|
+
const left = deadline - Date.now();
|
|
348
|
+
if (scopesPending.size > 0 && left > 0)
|
|
349
|
+
await withGateTimeout(Promise.all([...scopesPending]), left, signal, "personRowScopes").catch(() => undefined);
|
|
308
350
|
};
|
|
309
351
|
const pinOf = (toolCallId) => {
|
|
310
352
|
const p = toolCallId === undefined ? undefined : pins.get(toolCallId);
|
|
@@ -315,7 +357,7 @@ export function createPersonPathRows(cfg) {
|
|
|
315
357
|
};
|
|
316
358
|
const enter = (toolCallId, attempt, judged) => {
|
|
317
359
|
const rows = readOnce("call").then((read) => (entry.read = read));
|
|
318
|
-
const entry = { attempt, rows, tables: holdsPersonRows ? rows.then((read) => settleTables(entry, read)) : Promise.resolve(), ...(holdsPersonRows ? {} : { settled: {} }), ...(judged !== undefined ? { judged: { value: judged } } : {}) };
|
|
360
|
+
const entry = { attempt, rows, tables: holdsPersonRows ? rows.then((read) => Promise.all([settleTables(entry, read), readScopes.get(read)]).then(() => undefined)) : Promise.resolve(), ...(holdsPersonRows ? {} : { settled: {} }), ...(judged !== undefined ? { judged: { value: judged } } : {}) };
|
|
319
361
|
pins.set(toolCallId, entry);
|
|
320
362
|
return entry;
|
|
321
363
|
};
|
|
@@ -380,7 +422,7 @@ export function createPersonPathRows(cfg) {
|
|
|
380
422
|
holds: (toolCallId) => cfg.occurrences?.get(toolCallId) !== undefined,
|
|
381
423
|
unreadFor: (toolCallId) => {
|
|
382
424
|
const read = pinOf(toolCallId)?.read;
|
|
383
|
-
return read !== undefined ? holdsPersonRows && (read.unreadable !== undefined || (read.unreadableRows ?? []).some(
|
|
425
|
+
return read !== undefined ? holdsPersonRows && (read.unreadable !== undefined || (read.unreadableRows ?? []).some(reachesEveryJudgment)) : latestUnread();
|
|
384
426
|
},
|
|
385
427
|
attachTables: async (make) => {
|
|
386
428
|
compile = make;
|
|
@@ -402,12 +444,21 @@ export function createPersonPathRows(cfg) {
|
|
|
402
444
|
});
|
|
403
445
|
const writeDeny = {
|
|
404
446
|
face: "write",
|
|
447
|
+
get hasRows() {
|
|
448
|
+
return tablesFor(undefined).writeDeny.hasRows;
|
|
449
|
+
},
|
|
405
450
|
get ruleRows() {
|
|
406
451
|
return tablesFor(undefined).writeDeny.ruleRows;
|
|
407
452
|
},
|
|
408
453
|
matchPath: (path) => judging().writeDeny.matchPath(path),
|
|
409
454
|
matchTarget: (canonicalKey, lexicalView, opts) => judging().writeDeny.matchTarget(canonicalKey, lexicalView, opts),
|
|
410
455
|
guardsReads: (pattern) => judging().writeDeny.guardsReads?.(pattern) === true,
|
|
456
|
+
rowUnderRoot: (scope) => judging().writeDeny.rowUnderRoot?.(scope) ?? null,
|
|
457
|
+
rowAtOrBelow: (path) => judging().writeDeny.rowAtOrBelow?.(path) ?? null,
|
|
458
|
+
get unanchoredRows() {
|
|
459
|
+
return tablesFor(undefined).writeDeny.unanchoredRows ?? [];
|
|
460
|
+
},
|
|
461
|
+
rowLedByName: (name) => judging().writeDeny.rowLedByName?.(name) ?? null,
|
|
411
462
|
homeViews: readDeny.homeViews,
|
|
412
463
|
forCall: (id) => tablesFor(id).writeDeny,
|
|
413
464
|
};
|
|
@@ -439,7 +490,7 @@ export function pathTablesCompile(seats) {
|
|
|
439
490
|
const allow = person.readFaceRows?.allow ?? [];
|
|
440
491
|
const asks = [...seats.legReadAskRows.map((r) => ({ ...r, policy: true })), ...(person.readFaceRows?.ask ?? [])];
|
|
441
492
|
const readFaceRows = allow.length > 0 || asks.length > 0 ? { allow, ask: rowsWhereTheyLead(asks, await seats.leads.resolve(asks)) } : undefined;
|
|
442
|
-
return { readDeny: placed.matcher, writeDeny: carryHomeViews(compileWriteDeny(
|
|
493
|
+
return { readDeny: placed.matcher, writeDeny: carryHomeViews(compileWriteDeny(placed.matcher), placed.matcher.homeViews), readDirectories: [...new Set(await seats.canonicalize(person.readDirectories))], ...(readFaceRows !== undefined ? { readFaceRows } : {}), ruleRows: rows };
|
|
443
494
|
};
|
|
444
495
|
}
|
|
445
496
|
export function boundaryRowsOver(rows, personDirectories) {
|
|
@@ -463,9 +514,21 @@ const SEATS = new WeakMap();
|
|
|
463
514
|
export function denySeatsOf(t) {
|
|
464
515
|
let seats = SEATS.get(t);
|
|
465
516
|
if (seats === undefined) {
|
|
517
|
+
const unanchored = t.writeDeny.unanchoredRows ?? [];
|
|
466
518
|
seats = {
|
|
467
519
|
read: readDenySeat(t.readDeny),
|
|
468
|
-
write: t.writeDeny.
|
|
520
|
+
write: t.writeDeny.hasRows
|
|
521
|
+
? {
|
|
522
|
+
writeDenyMatch: (p) => t.writeDeny.matchPath(p)?.pattern ?? null,
|
|
523
|
+
writeDenyGuardsReads: (pattern) => t.writeDeny.guardsReads?.(pattern) === true,
|
|
524
|
+
writeDenyUnder: (p) => {
|
|
525
|
+
const hit = t.writeDeny.rowUnderRoot?.(p) ?? null;
|
|
526
|
+
return hit === null ? null : hit.unplaced === true ? { unplaced: hit.pattern } : hit.pattern;
|
|
527
|
+
},
|
|
528
|
+
writeDenyAtOrBelow: (p) => t.writeDeny.rowAtOrBelow !== undefined ? (t.writeDeny.rowAtOrBelow(p)?.pattern ?? null) : (t.writeDeny.ruleRows[0]?.rule ?? null),
|
|
529
|
+
...(unanchored.length > 0 ? { writeDenyNamed: { rows: unanchored, ledBy: (name) => t.writeDeny.rowLedByName?.(name) ?? null } } : {}),
|
|
530
|
+
}
|
|
531
|
+
: {},
|
|
469
532
|
};
|
|
470
533
|
SEATS.set(t, seats);
|
|
471
534
|
}
|
|
@@ -476,11 +539,10 @@ export function onPinnedRead(rows, stations) {
|
|
|
476
539
|
const check = composeReadChecks(stations);
|
|
477
540
|
if (check === undefined || !rows.holdsPersonRows)
|
|
478
541
|
return check;
|
|
479
|
-
const members = new Set(stations.flatMap((s) => [...s.tools]));
|
|
480
542
|
return {
|
|
481
543
|
judge(call, args, cwd, signal, callOpts) {
|
|
482
544
|
const id = callOpts.toolCallId;
|
|
483
|
-
if (
|
|
545
|
+
if (!readStationsHold(stations, call))
|
|
484
546
|
return check.judge(call, args, cwd, signal, callOpts);
|
|
485
547
|
const ready = id !== undefined && rows.holds(id) ? rows.pin(id, args).then(() => rows.tablesReady(id)) : rows.tablesReady(undefined, signal);
|
|
486
548
|
return ready.then(() => check.judge(call, args, cwd, signal, callOpts) ?? VOUCHED);
|
|
@@ -557,7 +619,8 @@ const DROPPED_ROW_SENTENCE = {
|
|
|
557
619
|
};
|
|
558
620
|
const UNREADABLE_ROW_SENTENCE = {
|
|
559
621
|
as_read: (n) => `${n} of your deny or ask rule rows came from the store with a part missing or not in plain form (the rule's text, its tool, match or path, the record of when it was added, or its scope), so ${n === 1 ? "it applies" : "they apply"} as written in every permission mode — a missing text read from the tool, match and path stored with ${n === 1 ? "it" : "them"}; where the tool, match or path is the part, all three read from ${n === 1 ? "its" : "their"} text, so ${n === 1 ? "it reaches" : "they reach"} what the rule's text says; where the scope is the part, everywhere (a row of this session's rules: in this session). Have the store send the whole row, or remove ${n === 1 ? "it" : "them"} from the store and add the rule again.`,
|
|
560
|
-
strictest: (n) => `${n} of your deny or ask rule rows could not be read (the store sent neither a rule text this version reads nor the tool, match or path it names as plain data), so ${n === 1 ? "it is" : "they are"} not ignored: no allow rule of yours clears a call ${n === 1 ? "it" : "they"} may reach — ${n === 1 ? "its tool's" : "their tools'"} calls, or every call for a Read or Edit deny rule (the file, shell and search checks read those too) or when the tool cannot be read — while your other deny and ask rules still refuse and ask. Under the permission modes that ask, such a call is put to you; auto mode's classifier and bypass mode answer it without asking. Have the store send plain values, or remove ${n === 1 ? "it" : "them"}
|
|
622
|
+
strictest: (n) => `${n} of your deny or ask rule rows could not be read (the store sent neither a rule text this version reads nor the tool, match or path it names as plain data), so ${n === 1 ? "it is" : "they are"} not ignored: no allow rule of yours clears a call ${n === 1 ? "it" : "they"} may reach — ${n === 1 ? "its tool's" : "their tools'"} calls, or every call for a Read or Edit deny rule (the file, shell and search checks read those too) or when the tool cannot be read — while your other deny and ask rules still refuse and ask. Under the permission modes that ask, such a call is put to you; auto mode's classifier and bypass mode answer it without asking. Have the store send plain values, or repair or remove ${n === 1 ? "it" : "them"} in the store.`,
|
|
623
|
+
behavior: (n) => `${n} of your stored rule rows could not be read because ${n === 1 ? "its" : "their"} behavior word could not be read (missing, not a text, or outside deny, ask and allow), so ${n === 1 ? "it is" : "they are"} not ignored: no allow rule of yours clears a call ${n === 1 ? "it" : "they"} may reach — ${n === 1 ? "its tool's" : "their tools'"} calls, or every call for Read or Edit or when the tool cannot be read — while your other deny and ask rules still refuse and ask; under the permission modes that ask, such a call is put to you (auto mode's classifier and bypass mode answer it without asking) — repair or remove ${n === 1 ? "it" : "them"} in the store.`,
|
|
561
624
|
};
|
|
562
625
|
export function ruleRowsDroppedNotice(onNotice, ids) {
|
|
563
626
|
let sent = false;
|
|
@@ -573,7 +636,8 @@ export function ruleRowsDroppedNotice(onNotice, ids) {
|
|
|
573
636
|
}),
|
|
574
637
|
...[
|
|
575
638
|
[(unreadable ?? []).filter((r) => !identityUnread(r)).length, UNREADABLE_ROW_SENTENCE.as_read],
|
|
576
|
-
[(unreadable ?? []).filter(identityUnread).length, UNREADABLE_ROW_SENTENCE.strictest],
|
|
639
|
+
[(unreadable ?? []).filter((r) => identityUnread(r) && r.member !== "behavior").length, UNREADABLE_ROW_SENTENCE.strictest],
|
|
640
|
+
[(unreadable ?? []).filter((r) => identityUnread(r) && r.member === "behavior").length, UNREADABLE_ROW_SENTENCE.behavior],
|
|
577
641
|
].flatMap(([n, say]) => (n > 0 ? [say(n)] : [])),
|
|
578
642
|
];
|
|
579
643
|
deliverEngineNotice(onNotice, {
|
|
@@ -584,7 +648,7 @@ export function ruleRowsDroppedNotice(onNotice, ids) {
|
|
|
584
648
|
entry: noticeRuleText(r.rule),
|
|
585
649
|
reason: r.reason,
|
|
586
650
|
...(r.reason === "scope_root_not_absolute" ? { scopeRoot: inlineUntrusted(r.scopeRoot, 200) } : {}),
|
|
587
|
-
...("behavior" in r ? { behavior: r.behavior } : {}),
|
|
651
|
+
...("behavior" in r && r.member !== "behavior" ? { behavior: r.behavior } : {}),
|
|
588
652
|
...("member" in r && r.member !== undefined ? { member: r.member } : {}),
|
|
589
653
|
...("element" in r && r.element !== undefined ? { element: { partition: r.element.partition, index: r.element.index, read: inlineUntrusted(r.element.read, 200) } } : {}),
|
|
590
654
|
}))),
|
|
@@ -43,6 +43,7 @@ import { RosterBuilder } from "../tool-roster.js";
|
|
|
43
43
|
import type { ParentSpecSeat } from "../parent-spec-seat.js";
|
|
44
44
|
import type { ApprovalParkNotResumable } from "../park-resumability.js";
|
|
45
45
|
import { type RosterSpec } from "./caller-roster.js";
|
|
46
|
+
import { type JudgedReadsSeat } from "../../tools/fs/judged-reads.js";
|
|
46
47
|
export interface PrepareCapsAndWorkflowInput {
|
|
47
48
|
/** borrowed-readonly — the REBOUND spec, whole: the roster map reads `tools`; the mounts read `enableBlockedReport`,
|
|
48
49
|
* `enablePlanMode`, `interactiveTools`; the caps/compliance stations read `principal`, `selfOrchestration`,
|
|
@@ -111,6 +112,9 @@ export interface PrepareCapsAndWorkflowInput {
|
|
|
111
112
|
inheritedGateForChildren: () => InheritedGate;
|
|
112
113
|
/** borrowed-readonly — the caller-tool ctx enrichment the roster map wraps every raw ToolSpec with. */
|
|
113
114
|
enrichSpecToolCtx: (ctx: ToolExecuteContext) => ToolExecuteContext;
|
|
115
|
+
/** ownership-ref — the leg's judged-read port seat, filled by the driver after the hands phase: a caller tool that declares a read
|
|
116
|
+
* target reads `ctx.judgedReads` through it at call time. */
|
|
117
|
+
judgedReadsSeat: JudgedReadsSeat;
|
|
114
118
|
/** borrowed-readonly — the large-result wrapper every roster entry passes through (per-tool policy honored inside). */
|
|
115
119
|
maybeOffload: (tool: AgentTool, perTool?: {
|
|
116
120
|
offload?: boolean;
|