@capybara-hq/kernel 0.1.0-rc.40 → 0.1.0-rc.42
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/bootstrap.json +10 -1
- package/dist/admin/admin.schemas.d.ts +6 -0
- package/dist/admin/org-network.service.d.ts +3 -1
- package/dist/admin/org-network.service.js +10 -2
- package/dist/app.d.ts +4 -0
- package/dist/app.js +2 -0
- package/dist/background/finish.d.ts +9 -1
- package/dist/background/finish.js +57 -4
- package/dist/background/launch.d.ts +23 -0
- package/dist/background/launch.js +55 -1
- package/dist/background/managed-output.d.ts +110 -0
- package/dist/background/managed-output.js +219 -0
- package/dist/background/managed.d.ts +52 -0
- package/dist/background/managed.js +128 -0
- package/dist/background/poll.job.d.ts +35 -1
- package/dist/background/poll.job.js +174 -9
- package/dist/background/render.js +1 -0
- package/dist/background/retire-legacy-tasks.job.d.ts +57 -0
- package/dist/background/retire-legacy-tasks.job.js +149 -0
- package/dist/background/session.d.ts +15 -5
- package/dist/background/session.js +22 -6
- package/dist/background/stop.d.ts +35 -5
- package/dist/background/stop.js +94 -8
- package/dist/background/store.d.ts +110 -3
- package/dist/background/store.js +205 -3
- package/dist/background/tasks.service.d.ts +18 -1
- package/dist/background/tasks.service.js +99 -9
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/channels/cards.js +1 -1
- package/dist/channels/inbound.js +2 -0
- package/dist/channels/phrases.d.ts +4 -0
- package/dist/channels/phrases.js +4 -0
- package/dist/config/load.d.ts +18 -0
- package/dist/config/load.js +39 -1
- package/dist/config/permission-migration.d.ts +26 -0
- package/dist/config/permission-migration.js +64 -0
- package/dist/config/schema.d.ts +1 -1
- package/dist/config/schema.js +11 -10
- package/dist/conversations/conversations.controller.d.ts +1 -1
- package/dist/conversations/conversations.controller.js +1 -1
- package/dist/conversations/conversations.module.js +12 -0
- package/dist/conversations/conversations.service.d.ts +11 -2
- package/dist/conversations/conversations.service.js +97 -27
- package/dist/conversations/event-log.d.ts +1 -1
- package/dist/conversations/event-log.js +10 -2
- package/dist/conversations/events.d.ts +304 -4
- package/dist/conversations/events.js +279 -29
- package/dist/conversations/permission-profile-store.d.ts +50 -0
- package/dist/conversations/permission-profile-store.js +67 -0
- package/dist/conversations/permission-profile-store.module.d.ts +2 -0
- package/dist/conversations/permission-profile-store.module.js +19 -0
- package/dist/conversations/permission-profiles.controller.d.ts +84 -0
- package/dist/conversations/permission-profiles.controller.js +105 -0
- package/dist/conversations/permission-profiles.schemas.d.ts +31 -0
- package/dist/conversations/permission-profiles.schemas.js +23 -0
- package/dist/conversations/permission-profiles.service.d.ts +56 -0
- package/dist/conversations/permission-profiles.service.js +179 -0
- package/dist/db/kernel-schema.d.ts +238 -3
- package/dist/devices/access.js +1 -1
- package/dist/devices/access.module.d.ts +2 -0
- package/dist/devices/access.module.js +19 -0
- package/dist/devices/conversation-devices.d.ts +8 -29
- package/dist/devices/conversation-devices.js +37 -73
- package/dist/devices/device-projects.service.d.ts +26 -28
- package/dist/devices/device-projects.service.js +123 -127
- package/dist/devices/devices.controller.js +3 -1
- package/dist/devices/devices.module.js +11 -9
- package/dist/devices/devices.service.d.ts +116 -8
- package/dist/devices/devices.service.js +252 -20
- package/dist/devices/dto.d.ts +16 -0
- package/dist/devices/dto.js +34 -6
- package/dist/devices/errors.d.ts +8 -0
- package/dist/devices/errors.js +10 -0
- package/dist/devices/project-rules.d.ts +44 -0
- package/dist/devices/project-rules.js +27 -0
- package/dist/devices/working-root.d.ts +6 -0
- package/dist/devices/working-root.js +12 -1
- package/dist/errors.d.ts +31 -0
- package/dist/errors.js +31 -0
- package/dist/evals/reconstruct.d.ts +19 -2
- package/dist/evals/reconstruct.js +40 -2
- package/dist/evals/recorded-permission-context.d.ts +77 -0
- package/dist/evals/recorded-permission-context.js +151 -0
- package/dist/evals/recorded-tools.d.ts +10 -1
- package/dist/evals/recorded-tools.js +27 -3
- package/dist/evals/run-replay.d.ts +8 -2
- package/dist/evals/run-replay.js +18 -2
- package/dist/evals/trajectory.d.ts +1 -1
- package/dist/evals/worker.d.ts +10 -1
- package/dist/evals/worker.js +23 -14
- package/dist/http/api.module.js +2 -0
- package/dist/identity/accounts.d.ts +14 -1
- package/dist/identity/accounts.js +61 -5
- package/dist/identity/identity.module.js +2 -0
- package/dist/identity/settings.d.ts +28 -12
- package/dist/identity/settings.js +89 -33
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/infra/cli/kernel-cli.module.d.ts +2 -2
- package/dist/infra/cli/kernel-cli.module.js +5 -2
- package/dist/infra/cli/permission-cutover.d.ts +59 -0
- package/dist/infra/cli/permission-cutover.js +107 -0
- package/dist/infra/config/kernel-config.service.d.ts +2 -2
- package/dist/infra/config/kernel-config.service.js +31 -11
- package/dist/infra/database/startup-activation-transaction.d.ts +36 -0
- package/dist/infra/database/startup-activation-transaction.js +242 -0
- package/dist/infra/database/transaction-host.d.ts +47 -0
- package/dist/infra/database/transaction-host.js +119 -0
- package/dist/infra/database/xact-lock.d.ts +1 -0
- package/dist/infra/database/xact-lock.js +6 -0
- package/dist/infra/outbox/registry.d.ts +39 -0
- package/dist/infra/outbox/registry.js +18 -0
- package/dist/kernel.module.js +2 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
- package/dist/lifecycle/kernel-lifecycle.js +55 -28
- package/dist/local-devices/device-auth.js +1 -1
- package/dist/local-devices/device-policy.service.d.ts +35 -5
- package/dist/local-devices/device-policy.service.js +188 -13
- package/dist/local-devices/instance-bindings.d.ts +82 -0
- package/dist/local-devices/instance-bindings.js +304 -0
- package/dist/local-devices/keys.d.ts +5 -0
- package/dist/local-devices/keys.js +5 -0
- package/dist/local-devices/local-device-gateway.d.ts +19 -4
- package/dist/local-devices/local-device-gateway.js +185 -17
- package/dist/local-devices/local-device-provider.d.ts +42 -7
- package/dist/local-devices/local-device-provider.js +185 -10
- package/dist/local-devices/local-devices.module.d.ts +17 -2
- package/dist/local-devices/local-devices.module.js +49 -8
- package/dist/local-devices/machines.d.ts +35 -12
- package/dist/local-devices/machines.js +203 -8
- package/dist/local-devices/network-grants.js +3 -3
- package/dist/local-devices/network-grants.module.d.ts +2 -0
- package/dist/local-devices/network-grants.module.js +14 -0
- package/dist/local-devices/owner-report.d.ts +79 -0
- package/dist/local-devices/owner-report.js +155 -0
- package/dist/local-devices/owner-reports.d.ts +48 -0
- package/dist/local-devices/owner-reports.js +190 -0
- package/dist/local-devices/policy-summary.d.ts +24 -1
- package/dist/local-devices/policy-summary.js +48 -0
- package/dist/local-devices/relay.d.ts +82 -6
- package/dist/local-devices/relay.js +187 -16
- package/dist/local-devices/targets.d.ts +16 -1
- package/dist/local-devices/targets.js +35 -2
- package/dist/orgs/cloud-network-setting.d.ts +33 -0
- package/dist/orgs/cloud-network-setting.js +47 -0
- package/dist/orgs/offboarding.d.ts +3 -1
- package/dist/orgs/offboarding.js +8 -2
- package/dist/orgs/org-lock.d.ts +10 -4
- package/dist/orgs/org-lock.js +10 -4
- package/dist/orgs/orgs.service.d.ts +3 -1
- package/dist/orgs/orgs.service.js +8 -2
- package/dist/orgs/settings.controller.d.ts +4 -1
- package/dist/orgs/settings.controller.js +3 -3
- package/dist/orgs/settings.service.d.ts +48 -56
- package/dist/orgs/settings.service.js +144 -101
- package/dist/overrides.d.ts +6 -1
- package/dist/overrides.js +2 -0
- package/dist/platform/exclusions.js +20 -0
- package/dist/platform/ops/admin.ops.js +14 -11
- package/dist/platform/ops/agent-skills.ops.js +2 -0
- package/dist/platform/ops/devices.ops.js +10 -2
- package/dist/platform/ops/org-settings.ops.js +6 -6
- package/dist/platform/ops/orgs.ops.js +1 -0
- package/dist/roles/worker.module.js +4 -0
- package/dist/runtime/context/build.d.ts +3 -1
- package/dist/runtime/context/build.js +19 -3
- package/dist/runtime/context/compaction.js +5 -0
- package/dist/runtime/context/device-paths.d.ts +9 -2
- package/dist/runtime/context/device-paths.js +20 -0
- package/dist/runtime/context/permission-profile.d.ts +46 -0
- package/dist/runtime/context/permission-profile.js +194 -0
- package/dist/runtime/maintenance.d.ts +7 -1
- package/dist/runtime/maintenance.js +43 -15
- package/dist/runtime/model-call.d.ts +32 -0
- package/dist/runtime/model-call.js +67 -0
- package/dist/runtime/permission-context-errors.d.ts +39 -0
- package/dist/runtime/permission-context-errors.js +67 -0
- package/dist/runtime/permission-context.service.d.ts +60 -0
- package/dist/runtime/permission-context.service.js +286 -0
- package/dist/runtime/project/knowledge.d.ts +7 -2
- package/dist/runtime/project/knowledge.js +5 -2
- package/dist/runtime/project/knowledge.service.d.ts +17 -2
- package/dist/runtime/project/knowledge.service.js +76 -12
- package/dist/runtime/run-execution.d.ts +4 -1
- package/dist/runtime/run-execution.js +14 -5
- package/dist/runtime/run-steps.d.ts +11 -3
- package/dist/runtime/run-steps.js +27 -4
- package/dist/runtime/runtime.module.js +11 -0
- package/dist/sandbox/attachments-path.d.ts +15 -0
- package/dist/sandbox/attachments-path.js +15 -0
- package/dist/sandbox/cloud-permission-snapshot.d.ts +159 -0
- package/dist/sandbox/cloud-permission-snapshot.js +407 -0
- package/dist/sandbox/cloud-permission-snapshot.module.d.ts +8 -0
- package/dist/sandbox/cloud-permission-snapshot.module.js +34 -0
- package/dist/sandbox/held-operations.d.ts +39 -0
- package/dist/sandbox/held-operations.js +119 -0
- package/dist/sandbox/jobs.d.ts +14 -3
- package/dist/sandbox/jobs.js +20 -2
- package/dist/sandbox/kernel-read.d.ts +55 -0
- package/dist/sandbox/kernel-read.js +57 -0
- package/dist/sandbox/legacy-retirement.d.ts +336 -0
- package/dist/sandbox/legacy-retirement.js +1063 -0
- package/dist/sandbox/legacy-retirement.module.d.ts +8 -0
- package/dist/sandbox/legacy-retirement.module.js +25 -0
- package/dist/sandbox/managed-device-context.d.ts +94 -0
- package/dist/sandbox/managed-device-context.js +308 -0
- package/dist/sandbox/managed-device-context.module.d.ts +6 -0
- package/dist/sandbox/managed-device-context.module.js +33 -0
- package/dist/sandbox/modes.d.ts +56 -8
- package/dist/sandbox/modes.js +92 -8
- package/dist/sandbox/operation-authority-types.d.ts +8 -0
- package/dist/sandbox/operation-authority-types.js +32 -0
- package/dist/sandbox/operation-authority.d.ts +145 -0
- package/dist/sandbox/operation-authority.js +783 -0
- package/dist/sandbox/operation-authority.module.d.ts +2 -0
- package/dist/sandbox/operation-authority.module.js +29 -0
- package/dist/sandbox/operation-intents.d.ts +206 -0
- package/dist/sandbox/operation-intents.js +1252 -0
- package/dist/sandbox/operation-intents.module.d.ts +2 -0
- package/dist/sandbox/operation-intents.module.js +21 -0
- package/dist/sandbox/operation-payloads.d.ts +33 -0
- package/dist/sandbox/operation-payloads.js +332 -0
- package/dist/sandbox/operation-reconcile.job.d.ts +49 -0
- package/dist/sandbox/operation-reconcile.job.js +247 -0
- package/dist/sandbox/permission-authority-epochs.d.ts +18 -0
- package/dist/sandbox/permission-authority-epochs.js +83 -0
- package/dist/sandbox/permission-authority-lock.d.ts +38 -0
- package/dist/sandbox/permission-authority-lock.js +147 -0
- package/dist/sandbox/permission-authority.module.d.ts +9 -0
- package/dist/sandbox/permission-authority.module.js +55 -0
- package/dist/sandbox/permission-availability.d.ts +18 -0
- package/dist/sandbox/permission-availability.js +19 -0
- package/dist/sandbox/permission-call-grants.d.ts +34 -0
- package/dist/sandbox/permission-call-grants.js +349 -0
- package/dist/sandbox/permission-call-grants.module.d.ts +2 -0
- package/dist/sandbox/permission-call-grants.module.js +21 -0
- package/dist/sandbox/permission-call-types.d.ts +82 -0
- package/dist/sandbox/permission-call-types.js +1 -0
- package/dist/sandbox/permission-ceiling-writes.d.ts +47 -0
- package/dist/sandbox/permission-ceiling-writes.js +223 -0
- package/dist/sandbox/permission-config-publication.d.ts +76 -0
- package/dist/sandbox/permission-config-publication.js +339 -0
- package/dist/sandbox/permission-context-types.d.ts +64 -0
- package/dist/sandbox/permission-context-types.js +24 -0
- package/dist/sandbox/permission-facts.d.ts +206 -0
- package/dist/sandbox/permission-facts.js +627 -0
- package/dist/sandbox/permission-facts.module.d.ts +2 -0
- package/dist/sandbox/permission-facts.module.js +20 -0
- package/dist/sandbox/permission-instance-writes.d.ts +90 -0
- package/dist/sandbox/permission-instance-writes.js +305 -0
- package/dist/sandbox/permission-runtime-reports.d.ts +83 -0
- package/dist/sandbox/permission-runtime-reports.js +354 -0
- package/dist/sandbox/permission-transitions.d.ts +31 -0
- package/dist/sandbox/permission-transitions.js +155 -0
- package/dist/sandbox/platform-full-access.d.ts +128 -0
- package/dist/sandbox/platform-full-access.js +210 -0
- package/dist/sandbox/providers.d.ts +22 -0
- package/dist/sandbox/providers.js +10 -2
- package/dist/sandbox/providers.module.d.ts +2 -0
- package/dist/sandbox/providers.module.js +19 -0
- package/dist/sandbox/request-not-sent.d.ts +13 -0
- package/dist/sandbox/request-not-sent.js +13 -0
- package/dist/sandbox/review/classifier.d.ts +2 -0
- package/dist/sandbox/review/classifier.js +8 -0
- package/dist/sandbox/review/permission-candidate.d.ts +12 -0
- package/dist/sandbox/review/permission-candidate.js +129 -0
- package/dist/sandbox/review/review.service.d.ts +4 -1
- package/dist/sandbox/review/review.service.js +19 -5
- package/dist/sandbox/sandbox-file-reader.d.ts +18 -1
- package/dist/sandbox/sandbox-file-reader.js +51 -7
- package/dist/sandbox/sandbox.module.js +26 -6
- package/dist/sandbox/sandbox.service.d.ts +230 -34
- package/dist/sandbox/sandbox.service.js +1368 -199
- package/dist/sandbox/unreachable.js +17 -3
- package/dist/sandbox/use-context.d.ts +17 -0
- package/dist/sandbox/use-context.js +1 -0
- package/dist/skills/invoke.d.ts +27 -4
- package/dist/skills/invoke.js +72 -7
- package/dist/tools/approvals.controller.d.ts +1 -0
- package/dist/tools/approvals.schemas.d.ts +1 -0
- package/dist/tools/approvals.schemas.js +3 -1
- package/dist/tools/approvals.service.d.ts +23 -10
- package/dist/tools/approvals.service.js +104 -26
- package/dist/tools/builtins/builtin-tools.d.ts +16 -2
- package/dist/tools/builtins/builtin-tools.js +38 -10
- package/dist/tools/builtins/sandbox/bash.d.ts +25 -1
- package/dist/tools/builtins/sandbox/bash.js +201 -5
- package/dist/tools/builtins/sandbox/common.d.ts +92 -20
- package/dist/tools/builtins/sandbox/common.js +201 -17
- package/dist/tools/builtins/sandbox/deliver.js +2 -2
- package/dist/tools/builtins/sandbox/edit.js +2 -2
- package/dist/tools/builtins/sandbox/fetch-attachment.js +11 -4
- package/dist/tools/builtins/sandbox/glob.js +2 -2
- package/dist/tools/builtins/sandbox/grep.js +2 -2
- package/dist/tools/builtins/sandbox/read.js +2 -2
- package/dist/tools/builtins/sandbox/task-list.js +7 -1
- package/dist/tools/builtins/sandbox/task-output.d.ts +1 -1
- package/dist/tools/builtins/sandbox/task-output.js +172 -0
- package/dist/tools/builtins/sandbox/task-stop.js +25 -3
- package/dist/tools/builtins/sandbox/write.js +2 -2
- package/dist/tools/builtins/skill-load.js +9 -6
- package/dist/tools/device-op-resolver.d.ts +1 -1
- package/dist/tools/device-op-resolver.js +13 -3
- package/dist/tools/permission-approval-jobs.d.ts +18 -0
- package/dist/tools/permission-approval-jobs.js +92 -0
- package/dist/tools/pipeline.d.ts +17 -2
- package/dist/tools/pipeline.js +300 -19
- package/dist/tools/registry.d.ts +9 -0
- package/dist/tools/tools.module.js +12 -0
- package/package.json +4 -3
- package/src/migrations/0146_permission_authority_epochs.sql +6 -0
- package/src/migrations/0147_conversation_permission_profiles.sql +4 -0
- package/src/migrations/0148_first_message_request_hash.sql +2 -0
- package/src/migrations/0149_sandbox_operation_intents.sql +66 -0
- package/src/migrations/0150_permission_call_grants_and_approvals.sql +36 -0
- package/src/migrations/0151_starting_execution_grants.sql +8 -0
- package/src/migrations/0152_background_launch_identity.sql +66 -0
- package/src/migrations/0153_background_cancel_requester.sql +13 -0
- package/src/migrations/0154_cloud_owner_ceiling.sql +14 -0
- package/src/migrations/0155_device_instance_generations.sql +30 -0
- package/src/migrations/0156_device_owner_report.sql +7 -0
- package/src/migrations/0157_legacy_retirement.sql +116 -0
- package/src/migrations/0158_legacy_freeze_enumerated.sql +5 -0
- package/src/migrations/0159_retirement_exact_cancel.sql +9 -0
- package/dist/sandbox/platform-auto-mode.d.ts +0 -63
- package/dist/sandbox/platform-auto-mode.js +0 -63
|
@@ -8,7 +8,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { OnWorkerEvent, WorkerHost } from "@nestjs/bullmq";
|
|
11
|
-
import { Inject, Injectable, Module } from "@nestjs/common";
|
|
11
|
+
import { Inject, Injectable, Module, Optional } from "@nestjs/common";
|
|
12
|
+
import { BackgroundModule } from "../background/background.module.js";
|
|
12
13
|
import { BG_WAKE_JOB } from "../background/wake-rules.js";
|
|
13
14
|
import { OWNED_PLUGIN_CLEANUP_JOB } from "../catalog/job-ids.js";
|
|
14
15
|
import { OwnedPluginCleanup, OwnedPluginCleanupModule } from "../catalog/owned-plugin-cleanup.js";
|
|
@@ -22,7 +23,11 @@ import { DEVICE_OP_RESOLVE_JOB, } from "../local-devices/policy-op-jobs.js";
|
|
|
22
23
|
import { DIRECTORY_SYNC_JOB, DirectorySync } from "../orgs/directory-sync.js";
|
|
23
24
|
import { Offboarding, RUN_STOP_JOB } from "../orgs/offboarding.js";
|
|
24
25
|
import { OrgsModule } from "../orgs/orgs.module.js";
|
|
26
|
+
import { CloudPermissionSnapshots } from "../sandbox/cloud-permission-snapshot.js";
|
|
25
27
|
import { runSandboxDestroyFor, runSandboxResetFiles, SANDBOX_DESTROY_FOR_JOB, SANDBOX_RESET_FILES_JOB, } from "../sandbox/jobs.js";
|
|
28
|
+
import { OPERATION_RECONCILE, OPERATION_REVOKE } from "../sandbox/operation-intents.js";
|
|
29
|
+
import { SandboxOperationReconcileJob } from "../sandbox/operation-reconcile.job.js";
|
|
30
|
+
import { PERMISSION_APPROVAL_RECHECK } from "../sandbox/permission-transitions.js";
|
|
26
31
|
import { SandboxModule } from "../sandbox/sandbox.module.js";
|
|
27
32
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
28
33
|
import { ScheduledTaskFireModule, ScheduledTaskFirer } from "../schedules/fire.js";
|
|
@@ -30,6 +35,7 @@ import { SCHED_FIRE_JOB, SCHED_SETTLE_JOB, } from "../schedules/job-ids.js";
|
|
|
30
35
|
import { DeviceOpResolver } from "../tools/device-op-resolver.js";
|
|
31
36
|
import { ToolDrift } from "../tools/drift.js";
|
|
32
37
|
import { DRIFT_CONNECTOR_JOB } from "../tools/job-ids.js";
|
|
38
|
+
import { PermissionApprovalJobs, } from "../tools/permission-approval-jobs.js";
|
|
33
39
|
import { ToolsModule } from "../tools/tools.module.js";
|
|
34
40
|
import { MAINTENANCE_QUEUE_NAME } from "./maintenance-queue.js";
|
|
35
41
|
import { RunDeletion, STOP_DELETED_ORG_JOB } from "./run-deletion.js";
|
|
@@ -55,6 +61,7 @@ export const MAINTENANCE_CONCURRENCY = 5;
|
|
|
55
61
|
* name fails the job (BullMQ retries it; in a rolling deploy a newer replica knows it). The producers are the domains' own (same names, ids and options).
|
|
56
62
|
*/
|
|
57
63
|
let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
64
|
+
permissionApprovals;
|
|
58
65
|
waits;
|
|
59
66
|
sandbox;
|
|
60
67
|
drift;
|
|
@@ -67,8 +74,11 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
|
67
74
|
deviceOps;
|
|
68
75
|
scheduled;
|
|
69
76
|
log;
|
|
70
|
-
|
|
77
|
+
operations;
|
|
78
|
+
snapshots;
|
|
79
|
+
constructor(permissionApprovals, waits, sandbox, drift, directory, deletion, offboarding, runs, ownedCleanup, scheduledTasks, deviceOps, scheduled, log, operations, snapshots) {
|
|
71
80
|
super();
|
|
81
|
+
this.permissionApprovals = permissionApprovals;
|
|
72
82
|
this.waits = waits;
|
|
73
83
|
this.sandbox = sandbox;
|
|
74
84
|
this.drift = drift;
|
|
@@ -81,6 +91,8 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
|
81
91
|
this.deviceOps = deviceOps;
|
|
82
92
|
this.scheduled = scheduled;
|
|
83
93
|
this.log = log;
|
|
94
|
+
this.operations = operations;
|
|
95
|
+
this.snapshots = snapshots;
|
|
84
96
|
}
|
|
85
97
|
process(job, token) {
|
|
86
98
|
return runJob(MAINTENANCE_QUEUE_NAME, job, () => this.dispatch(job, token));
|
|
@@ -91,6 +103,15 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
|
91
103
|
}
|
|
92
104
|
async dispatch(job, token) {
|
|
93
105
|
switch (job.name) {
|
|
106
|
+
case PERMISSION_APPROVAL_RECHECK:
|
|
107
|
+
await this.permissionApprovals.recheck(job.data);
|
|
108
|
+
return;
|
|
109
|
+
case OPERATION_RECONCILE:
|
|
110
|
+
await this.operations.reconcile(job.data.operationId);
|
|
111
|
+
return;
|
|
112
|
+
case OPERATION_REVOKE:
|
|
113
|
+
await this.operations.revoke(job.data.operationId);
|
|
114
|
+
return;
|
|
94
115
|
case STOP_DELETED_ORG_JOB:
|
|
95
116
|
await this.deletion.stopOrg(job.data);
|
|
96
117
|
return;
|
|
@@ -101,7 +122,7 @@ let MaintenanceProcessor = class MaintenanceProcessor extends WorkerHost {
|
|
|
101
122
|
await runSandboxDestroyFor(this.sandbox, this.log, job);
|
|
102
123
|
return;
|
|
103
124
|
case SANDBOX_RESET_FILES_JOB:
|
|
104
|
-
await runSandboxResetFiles(this.sandbox, job);
|
|
125
|
+
await runSandboxResetFiles(this.sandbox, job, this.snapshots);
|
|
105
126
|
return;
|
|
106
127
|
case DRIFT_CONNECTOR_JOB: {
|
|
107
128
|
const { orgId, connectorId, trigger } = job.data;
|
|
@@ -187,18 +208,22 @@ __decorate([
|
|
|
187
208
|
], MaintenanceProcessor.prototype, "error", null);
|
|
188
209
|
MaintenanceProcessor = __decorate([
|
|
189
210
|
Injectable(),
|
|
190
|
-
__param(0, Inject(
|
|
191
|
-
__param(1, Inject(
|
|
192
|
-
__param(2, Inject(
|
|
193
|
-
__param(3, Inject(
|
|
194
|
-
__param(4, Inject(
|
|
195
|
-
__param(5, Inject(
|
|
196
|
-
__param(6, Inject(
|
|
197
|
-
__param(7, Inject(
|
|
198
|
-
__param(8, Inject(
|
|
199
|
-
__param(9, Inject(
|
|
200
|
-
__param(10, Inject(
|
|
201
|
-
__param(11, Inject(
|
|
211
|
+
__param(0, Inject(PermissionApprovalJobs)),
|
|
212
|
+
__param(1, Inject(Waits)),
|
|
213
|
+
__param(2, Inject(SandboxService)),
|
|
214
|
+
__param(3, Inject(ToolDrift)),
|
|
215
|
+
__param(4, Inject(DirectorySync)),
|
|
216
|
+
__param(5, Inject(RunDeletion)),
|
|
217
|
+
__param(6, Inject(Offboarding)),
|
|
218
|
+
__param(7, Inject(RunQueue)),
|
|
219
|
+
__param(8, Inject(OwnedPluginCleanup)),
|
|
220
|
+
__param(9, Inject(ScheduledTaskFirer)),
|
|
221
|
+
__param(10, Inject(DeviceOpResolver)),
|
|
222
|
+
__param(11, Inject(ScheduledRuns)),
|
|
223
|
+
__param(12, Inject(KERNEL_LOGGER)),
|
|
224
|
+
__param(13, Inject(SandboxOperationReconcileJob)),
|
|
225
|
+
__param(14, Optional()),
|
|
226
|
+
__param(14, Inject(CloudPermissionSnapshots))
|
|
202
227
|
], MaintenanceProcessor);
|
|
203
228
|
export { MaintenanceProcessor };
|
|
204
229
|
/**
|
|
@@ -213,6 +238,8 @@ MaintenanceModule = __decorate([
|
|
|
213
238
|
imports: [
|
|
214
239
|
// the periodic jobs' bodies (a periodic job's name enqueued here runs it once)
|
|
215
240
|
KernelScheduleModule,
|
|
241
|
+
// the exact stop a revoked background start owes (SandboxOperationReconcileJob)
|
|
242
|
+
BackgroundModule,
|
|
216
243
|
RuntimeModule,
|
|
217
244
|
SandboxModule,
|
|
218
245
|
ToolsModule,
|
|
@@ -224,6 +251,7 @@ MaintenanceModule = __decorate([
|
|
|
224
251
|
QueueModule.registerQueue(MAINTENANCE_QUEUE_NAME),
|
|
225
252
|
],
|
|
226
253
|
providers: [
|
|
254
|
+
SandboxOperationReconcileJob,
|
|
227
255
|
configuredProcessor(MaintenanceProcessor, MAINTENANCE_QUEUE_NAME, {
|
|
228
256
|
concurrency: MAINTENANCE_CONCURRENCY,
|
|
229
257
|
}),
|
|
@@ -13,6 +13,7 @@ import { type FitPlan } from "./context/fit.js";
|
|
|
13
13
|
import { type ConversationKindForHooks, type HookRunner } from "./hook-calls.js";
|
|
14
14
|
import type { SubagentParent } from "./loop.js";
|
|
15
15
|
import { MediaCache } from "./media-cache.js";
|
|
16
|
+
import { type PermissionContextFailureKind } from "./permission-context-errors.js";
|
|
16
17
|
import { type BoundProvider, type ProviderRegistry } from "./providers.js";
|
|
17
18
|
import type { StepLog } from "./step-log.js";
|
|
18
19
|
/** 单轮收尾的尾部提醒(模型可见,英文;spec 6 轮次额度收尾)。 */
|
|
@@ -90,6 +91,26 @@ export interface ModelStepDeps {
|
|
|
90
91
|
* `conversationKind: "chat"` on the step input.
|
|
91
92
|
*/
|
|
92
93
|
hooks?: HookRunner;
|
|
94
|
+
/**
|
|
95
|
+
* The request boundary of the recorded permission context (permission context replay spec B2):
|
|
96
|
+
* before each agent-history request construction, record (live) or feed (full-run replay) the
|
|
97
|
+
* permission context, then rebuild from the complete log. Called at every request construction
|
|
98
|
+
* of the attempt ladder (a retry, a fallback, the rebuild after a forced compaction, wrap-up);
|
|
99
|
+
* absent, no call and no reread (old requests build byte for byte). Live runs get the recorder
|
|
100
|
+
* only through the paired activation gate (`RunSteps`); full-run replays strip any live one and
|
|
101
|
+
* install only the recorded feeder (`evals/recorded-permission-context.ts`).
|
|
102
|
+
*/
|
|
103
|
+
permissionContext?: PermissionContextPort;
|
|
104
|
+
}
|
|
105
|
+
/** What the request boundary passes to {@link PermissionContextPort.beforeRequest}. */
|
|
106
|
+
export type PermissionContextRequestInput = Pick<ModelStepInput, "orgId" | "conversationId" | "runId" | "step" | "signal"> & {
|
|
107
|
+
/** The run's actor; a step without one fails before the callback (no request is sent). */
|
|
108
|
+
accountId: string;
|
|
109
|
+
attempt: number;
|
|
110
|
+
};
|
|
111
|
+
/** {@link ModelStepDeps.permissionContext}: one call per request construction (spec B2). */
|
|
112
|
+
export interface PermissionContextPort {
|
|
113
|
+
beforeRequest(input: PermissionContextRequestInput): Promise<void>;
|
|
93
114
|
}
|
|
94
115
|
/** 构建请求用到的附件来源。 */
|
|
95
116
|
export interface MediaSourceDeps {
|
|
@@ -176,6 +197,17 @@ export declare class RunError extends Error {
|
|
|
176
197
|
readonly code: string;
|
|
177
198
|
constructor(code: string, message: string);
|
|
178
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* A failure of the permission context boundary (the callback or its complete-log refresh) before
|
|
202
|
+
* any request is sent (spec B2): never a provider error, never retried or sent to a fallback; the
|
|
203
|
+
* attempt ladder turns it into its named {@link RunError} before classifying anything.
|
|
204
|
+
*/
|
|
205
|
+
export declare class PermissionContextBeforeRequestError extends Error {
|
|
206
|
+
readonly kind: PermissionContextFailureKind;
|
|
207
|
+
readonly name = "PermissionContextBeforeRequestError";
|
|
208
|
+
constructor(kind: PermissionContextFailureKind);
|
|
209
|
+
toRunError(): RunError;
|
|
210
|
+
}
|
|
179
211
|
/** 幂等键。`usage` 与 `assistant_message` 同批写入,带键保证重放时不重复记账。 */
|
|
180
212
|
/** 某步 assistant_message 的幂等键(tools 节点据此找到本步的工具调用)。 */
|
|
181
213
|
export declare const assistantIdemKey: (runId: string, step: number) => string;
|
|
@@ -14,7 +14,9 @@ import { calibrate, estimateTokens } from "./context/tokens.js";
|
|
|
14
14
|
import { toolSetChange } from "./context/tool-changes.js";
|
|
15
15
|
import { fireObserve, hookDeniedAudit, hookDeniedEvent, hookRequestOf, hookScope, recordHookDenial, } from "./hook-calls.js";
|
|
16
16
|
import { MediaCache } from "./media-cache.js";
|
|
17
|
+
import { PERMISSION_CONTEXT_RUN_ERRORS, permissionContextFailureKind, permissionContextKindOfCode, } from "./permission-context-errors.js";
|
|
17
18
|
import { ProviderListError } from "./providers.js";
|
|
19
|
+
import { ExecutionRevoked } from "./run-execution.js";
|
|
18
20
|
import { budgetRunOf, subagentBudgetUsedUp } from "./subagents/limits.js";
|
|
19
21
|
/** 单轮收尾的尾部提醒(模型可见,英文;spec 6 轮次额度收尾)。 */
|
|
20
22
|
export const WRAP_UP_REMINDER = "Step limit reached. Do not call tools. Summarize what you found and what remains for the user.";
|
|
@@ -94,6 +96,59 @@ export class RunError extends Error {
|
|
|
94
96
|
this.name = "RunError";
|
|
95
97
|
}
|
|
96
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* A failure of the permission context boundary (the callback or its complete-log refresh) before
|
|
101
|
+
* any request is sent (spec B2): never a provider error, never retried or sent to a fallback; the
|
|
102
|
+
* attempt ladder turns it into its named {@link RunError} before classifying anything.
|
|
103
|
+
*/
|
|
104
|
+
export class PermissionContextBeforeRequestError extends Error {
|
|
105
|
+
kind;
|
|
106
|
+
name = "PermissionContextBeforeRequestError";
|
|
107
|
+
constructor(kind) {
|
|
108
|
+
super(PERMISSION_CONTEXT_RUN_ERRORS[kind].message);
|
|
109
|
+
this.kind = kind;
|
|
110
|
+
}
|
|
111
|
+
toRunError() {
|
|
112
|
+
const v = PERMISSION_CONTEXT_RUN_ERRORS[this.kind];
|
|
113
|
+
return new RunError(v.code, v.message);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The request boundary of one construction (spec B2): only when `deps.permissionContext` exists,
|
|
118
|
+
* awaits its `beforeRequest` and returns the complete ordered log read once after it; undefined
|
|
119
|
+
* without one (no call, no reread). A revoked execution keeps its identical `ExecutionRevoked`, an
|
|
120
|
+
* abort its own error (the ladder turns it into `StepAborted`); every other failure of the
|
|
121
|
+
* callback or the refresh is a {@link PermissionContextBeforeRequestError}.
|
|
122
|
+
*/
|
|
123
|
+
async function permissionContextBoundary(deps, input, attempt) {
|
|
124
|
+
const port = deps.permissionContext;
|
|
125
|
+
if (!port)
|
|
126
|
+
return undefined;
|
|
127
|
+
try {
|
|
128
|
+
if (input.accountId === undefined)
|
|
129
|
+
throw new PermissionContextBeforeRequestError("actor");
|
|
130
|
+
await port.beforeRequest({
|
|
131
|
+
orgId: input.orgId,
|
|
132
|
+
conversationId: input.conversationId,
|
|
133
|
+
runId: input.runId,
|
|
134
|
+
accountId: input.accountId,
|
|
135
|
+
step: input.step,
|
|
136
|
+
signal: input.signal,
|
|
137
|
+
attempt,
|
|
138
|
+
});
|
|
139
|
+
return await readAllEvents(deps.eventLog, input.conversationId);
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
if (error instanceof ExecutionRevoked || error instanceof PermissionContextBeforeRequestError)
|
|
143
|
+
throw error;
|
|
144
|
+
if (input.signal.aborted)
|
|
145
|
+
throw error;
|
|
146
|
+
const kind = error instanceof RunError
|
|
147
|
+
? (permissionContextKindOfCode(error.code) ?? "invalid")
|
|
148
|
+
: permissionContextFailureKind(error);
|
|
149
|
+
throw new PermissionContextBeforeRequestError(kind);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
97
152
|
/** 幂等键。`usage` 与 `assistant_message` 同批写入,带键保证重放时不重复记账。 */
|
|
98
153
|
/** 某步 assistant_message 的幂等键(tools 节点据此找到本步的工具调用)。 */
|
|
99
154
|
export const assistantIdemKey = (runId, step) => `assistant:${runId}:${step}`;
|
|
@@ -1202,6 +1257,11 @@ async function ladder(deps, input, events, runtime, compaction, tools, wrapUpRea
|
|
|
1202
1257
|
// (§4.3 point 5): one forced compaction with this rung's model, the squeezed fit, then
|
|
1203
1258
|
// `run.context_too_large` before any call.
|
|
1204
1259
|
const fit = async () => {
|
|
1260
|
+
// the permission context boundary of this construction (spec B2): record (or feed) the
|
|
1261
|
+
// context, then build from the complete log read once after it; absent, `evs` stays
|
|
1262
|
+
const refreshed = await permissionContextBoundary(deps, input, attempt);
|
|
1263
|
+
if (refreshed !== undefined)
|
|
1264
|
+
evs = refreshed;
|
|
1205
1265
|
await loadMedia(deps, input, evs, info, tools);
|
|
1206
1266
|
const built = buildRequest(deps, evs, input, info, params.value, runtime, tools, wrapUp);
|
|
1207
1267
|
const { request, estimate } = built;
|
|
@@ -1355,10 +1415,17 @@ async function ladder(deps, input, events, runtime, compaction, tools, wrapUpRea
|
|
|
1355
1415
|
return { outcome, ref: rung.ref };
|
|
1356
1416
|
}
|
|
1357
1417
|
catch (err) {
|
|
1418
|
+
// a revoked or replaced execution reaches the worker as the identical object, before the
|
|
1419
|
+
// abort and any classification (it must never write a stale terminal event)
|
|
1420
|
+
if (err instanceof ExecutionRevoked)
|
|
1421
|
+
throw err;
|
|
1358
1422
|
if (err instanceof StepAborted)
|
|
1359
1423
|
throw err;
|
|
1360
1424
|
if (signal.aborted)
|
|
1361
1425
|
throw new StepAborted();
|
|
1426
|
+
// the permission context boundary sent nothing: its named run error, no provider fallback
|
|
1427
|
+
if (err instanceof PermissionContextBeforeRequestError)
|
|
1428
|
+
throw err.toRunError();
|
|
1362
1429
|
// a hook denial is final (not retried, not reclassified)
|
|
1363
1430
|
if (err instanceof RunError)
|
|
1364
1431
|
throw err;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** The named no-send failures of a permission context read or append (spec B2 table). */
|
|
2
|
+
export declare const PERMISSION_CONTEXT_RUN_ERRORS: {
|
|
3
|
+
readonly stale: {
|
|
4
|
+
readonly code: "run.permission_context_stale";
|
|
5
|
+
readonly message: "Permission configuration changed. Wait for configuration activation, then retry this run.";
|
|
6
|
+
};
|
|
7
|
+
readonly changed: {
|
|
8
|
+
readonly code: "run.permission_context_changed";
|
|
9
|
+
readonly message: "The device binding changed while preparing this request. Retry the run after the binding settles.";
|
|
10
|
+
};
|
|
11
|
+
readonly unavailable: {
|
|
12
|
+
readonly code: "run.permission_context_unavailable";
|
|
13
|
+
readonly message: "Permission context could not be read or recorded. Retry this run when storage is available.";
|
|
14
|
+
};
|
|
15
|
+
readonly invalid: {
|
|
16
|
+
readonly code: "run.permission_context_invalid";
|
|
17
|
+
readonly message: "Permission context is invalid. Ask an administrator to inspect the run before retrying.";
|
|
18
|
+
};
|
|
19
|
+
readonly actor: {
|
|
20
|
+
readonly code: "run.permission_context_actor_unavailable";
|
|
21
|
+
readonly message: "This run's actor is no longer authorized. Start a new run with an authorized account.";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
/** One named no-send failure of the request boundary. */
|
|
25
|
+
export type PermissionContextFailureKind = keyof typeof PERMISSION_CONTEXT_RUN_ERRORS;
|
|
26
|
+
/** The replica has not applied the current permission configuration (checked under the locks). */
|
|
27
|
+
export declare class PublicationStale extends Error {
|
|
28
|
+
readonly name = "PublicationStale";
|
|
29
|
+
}
|
|
30
|
+
/** Whether `error` is a storage failure (database unreachable or aborting), not bad data. */
|
|
31
|
+
export declare function isStorageError(error: unknown): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The named kind of a permission context read, append or complete-log refresh failure. The caller
|
|
34
|
+
* has already kept an `ExecutionRevoked`, an abort and a named `RunError` (see
|
|
35
|
+
* {@link permissionContextKindOfCode}); everything else is one of these, never a provider error.
|
|
36
|
+
*/
|
|
37
|
+
export declare function permissionContextFailureKind(error: unknown): PermissionContextFailureKind;
|
|
38
|
+
/** The kind of a named run error code, or undefined for any other code. */
|
|
39
|
+
export declare function permissionContextKindOfCode(code: string): PermissionContextFailureKind | undefined;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { SandboxScopeDeniedError } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { ApiError } from "../errors.js";
|
|
3
|
+
import { PermissionContextSubjectChanged } from "../sandbox/permission-context-types.js";
|
|
4
|
+
/** The named no-send failures of a permission context read or append (spec B2 table). */
|
|
5
|
+
export const PERMISSION_CONTEXT_RUN_ERRORS = {
|
|
6
|
+
stale: {
|
|
7
|
+
code: "run.permission_context_stale",
|
|
8
|
+
message: "Permission configuration changed. Wait for configuration activation, then retry this run.",
|
|
9
|
+
},
|
|
10
|
+
changed: {
|
|
11
|
+
code: "run.permission_context_changed",
|
|
12
|
+
message: "The device binding changed while preparing this request. Retry the run after the binding settles.",
|
|
13
|
+
},
|
|
14
|
+
unavailable: {
|
|
15
|
+
code: "run.permission_context_unavailable",
|
|
16
|
+
message: "Permission context could not be read or recorded. Retry this run when storage is available.",
|
|
17
|
+
},
|
|
18
|
+
invalid: {
|
|
19
|
+
code: "run.permission_context_invalid",
|
|
20
|
+
message: "Permission context is invalid. Ask an administrator to inspect the run before retrying.",
|
|
21
|
+
},
|
|
22
|
+
actor: {
|
|
23
|
+
code: "run.permission_context_actor_unavailable",
|
|
24
|
+
message: "This run's actor is no longer authorized. Start a new run with an authorized account.",
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
/** The replica has not applied the current permission configuration (checked under the locks). */
|
|
28
|
+
export class PublicationStale extends Error {
|
|
29
|
+
name = "PublicationStale";
|
|
30
|
+
}
|
|
31
|
+
/** SQLSTATE classes of a database that is unreachable, overloaded or aborting, not of bad data. */
|
|
32
|
+
const STORAGE_SQLSTATE = /^(08|40|53|57|58|XX)[0-9A-Z]{3}$/;
|
|
33
|
+
const STORAGE_NODE = new Set(["ECONNREFUSED", "ECONNRESET", "ETIMEDOUT", "EPIPE", "ENOTFOUND"]);
|
|
34
|
+
/** Whether `error` is a storage failure (database unreachable or aborting), not bad data. */
|
|
35
|
+
export function isStorageError(error) {
|
|
36
|
+
if (!(error instanceof Error))
|
|
37
|
+
return false;
|
|
38
|
+
const code = error.code;
|
|
39
|
+
if (typeof code === "string" && (STORAGE_SQLSTATE.test(code) || STORAGE_NODE.has(code)))
|
|
40
|
+
return true;
|
|
41
|
+
return /Connection terminated|timeout exceeded when trying to connect/i.test(error.message);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The named kind of a permission context read, append or complete-log refresh failure. The caller
|
|
45
|
+
* has already kept an `ExecutionRevoked`, an abort and a named `RunError` (see
|
|
46
|
+
* {@link permissionContextKindOfCode}); everything else is one of these, never a provider error.
|
|
47
|
+
*/
|
|
48
|
+
export function permissionContextFailureKind(error) {
|
|
49
|
+
if (error instanceof PublicationStale || error instanceof SandboxScopeDeniedError)
|
|
50
|
+
return "stale";
|
|
51
|
+
if (error instanceof PermissionContextSubjectChanged)
|
|
52
|
+
return "changed";
|
|
53
|
+
if (error instanceof ApiError &&
|
|
54
|
+
["conversation.not_found", "forbidden", "org.not_found"].includes(error.code))
|
|
55
|
+
return "actor";
|
|
56
|
+
if (isStorageError(error))
|
|
57
|
+
return "unavailable";
|
|
58
|
+
// RecordedPermissionContextError and any unexpected failure
|
|
59
|
+
return "invalid";
|
|
60
|
+
}
|
|
61
|
+
/** The kind of a named run error code, or undefined for any other code. */
|
|
62
|
+
export function permissionContextKindOfCode(code) {
|
|
63
|
+
for (const [kind, v] of Object.entries(PERMISSION_CONTEXT_RUN_ERRORS))
|
|
64
|
+
if (v.code === code)
|
|
65
|
+
return kind;
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { EventLog } from "../conversations/event-log.js";
|
|
2
|
+
import { PermissionProfileStore } from "../conversations/permission-profile-store.js";
|
|
3
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
4
|
+
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
5
|
+
import type { KernelLogger } from "../log.js";
|
|
6
|
+
import { SandboxOperationAuthority } from "../sandbox/operation-authority.js";
|
|
7
|
+
import { PermissionAuthorityLock } from "../sandbox/permission-authority-lock.js";
|
|
8
|
+
import { PermissionConfigPublication } from "../sandbox/permission-config-publication.js";
|
|
9
|
+
import { type PermissionContextSubject } from "../sandbox/permission-context-types.js";
|
|
10
|
+
import { PERMISSION_CONTEXT_RUN_ERRORS } from "./permission-context-errors.js";
|
|
11
|
+
export { PERMISSION_CONTEXT_RUN_ERRORS };
|
|
12
|
+
/**
|
|
13
|
+
* Maps a failure of a permission context read or append (and of the complete-log refresh after it)
|
|
14
|
+
* to what the run sees, before any request is sent: a revoked or replaced execution keeps its
|
|
15
|
+
* identical `ExecutionRevoked` object, an abort keeps its reason, a `RunError` passes, and every
|
|
16
|
+
* other failure becomes one of the named run errors. A recorded `permission_context` (or marked
|
|
17
|
+
* path) the strict v1 schema rejects is `run.permission_context_invalid`, never a provider error
|
|
18
|
+
* and never rendered as historical text.
|
|
19
|
+
*/
|
|
20
|
+
export declare function permissionContextFailure(error: unknown, signal?: AbortSignal): unknown;
|
|
21
|
+
/**
|
|
22
|
+
* The live recorder of the model-facing permission context (spec "Live facts and writer
|
|
23
|
+
* contract"). For one request construction it discovers the conversation's root and device
|
|
24
|
+
* without locks, then opens exactly one transaction whose fence prelude takes the complete
|
|
25
|
+
* authority subject (platform, org, device when selected, root) before the inherited run fence
|
|
26
|
+
* (org, root, calling conversation, execution id). Inside it re-validates the claim, the run and
|
|
27
|
+
* the discovered subject, reads the authority projection shared with admission, compares it with
|
|
28
|
+
* the latest recorded `permission_context` of the calling conversation and appends a new snapshot
|
|
29
|
+
* only when the payload differs (A to B to A appends three). One changed subject is rediscovered
|
|
30
|
+
* outside the transaction; a second fails the run. An abort, a replaced claim or a deleted
|
|
31
|
+
* conversation appends nothing. The bus hint follows the commit.
|
|
32
|
+
*
|
|
33
|
+
* Dormant: nothing in production calls it until the request boundary and the managed tool path
|
|
34
|
+
* activate together (Gate 9.4 with Task 8 phase 8.6).
|
|
35
|
+
*/
|
|
36
|
+
export declare class PermissionContextRecorder {
|
|
37
|
+
private readonly db;
|
|
38
|
+
readonly txHost: TransactionHost;
|
|
39
|
+
private readonly events;
|
|
40
|
+
private readonly authority;
|
|
41
|
+
private readonly locks;
|
|
42
|
+
private readonly publication;
|
|
43
|
+
private readonly profiles;
|
|
44
|
+
private readonly log;
|
|
45
|
+
constructor(db: KernelDb, txHost: TransactionHost, events: Pick<EventLog, "appendIn" | "notify">, authority: Pick<SandboxOperationAuthority, "readContextLocked">, locks: Pick<PermissionAuthorityLock, "acquire">, publication: Pick<PermissionConfigPublication, "assertCurrent">, profiles: Pick<PermissionProfileStore, "readRoot">, log: Pick<KernelLogger, "warn">);
|
|
46
|
+
/**
|
|
47
|
+
* Records the current permission context into the calling conversation's log, or nothing when
|
|
48
|
+
* the latest recorded snapshot already equals it. Requires the real execution claim of this run
|
|
49
|
+
* (`RunExecution.withClaim`) and no open transaction.
|
|
50
|
+
*/
|
|
51
|
+
record(input: PermissionContextSubject, signal: AbortSignal): Promise<void>;
|
|
52
|
+
/** The complete authority subject, read without locks; validated again under them. */
|
|
53
|
+
private discover;
|
|
54
|
+
private refuseReplayRoot;
|
|
55
|
+
/**
|
|
56
|
+
* The one transaction of a record attempt: its fence already holds the complete authority
|
|
57
|
+
* subject and the inherited run fence. Returns the appended seq, or null when deduplicated.
|
|
58
|
+
*/
|
|
59
|
+
private appendLocked;
|
|
60
|
+
}
|