@phyzess/pappra 0.1.0-beta.13 → 0.1.0-beta.18
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/README.md +134 -15
- package/assets/integrations/skills/pappra/SKILL.md +28 -7
- package/assets/integrations/skills/pappra/references/collaboration.md +633 -0
- package/assets/integrations/skills/pappra/references/environment.md +360 -0
- package/assets/integrations/skills/pappra/references/hosts.md +20 -0
- package/assets/integrations/skills/pappra/references/operations.md +36 -5
- package/dist/adapters/pi/recovery-extension.d.ts +65 -0
- package/dist/adapters/pi/recovery-extension.js +238 -0
- package/dist/adapters/pi/session-transition-extension.d.ts +30 -0
- package/dist/adapters/pi/session-transition-extension.js +265 -0
- package/dist/app/automatic-handoff-events.d.ts +26 -0
- package/dist/app/automatic-handoff-events.js +134 -0
- package/dist/app/bounded-file.d.ts +2 -0
- package/dist/app/bounded-file.js +2 -0
- package/dist/app/capability-evidence/claude.d.ts +37 -0
- package/dist/app/capability-evidence/claude.js +206 -0
- package/dist/app/capability-evidence/codex.d.ts +35 -0
- package/dist/app/capability-evidence/codex.js +193 -0
- package/dist/app/capability-evidence/index.d.ts +33 -0
- package/dist/app/capability-evidence/index.js +117 -0
- package/dist/app/capability-evidence/pi.d.ts +73 -0
- package/dist/app/capability-evidence/pi.js +669 -0
- package/dist/app/capability-evidence/shared.d.ts +69 -0
- package/dist/app/capability-evidence/shared.js +195 -0
- package/dist/app/collab-auto-handoff.d.ts +55 -0
- package/dist/app/collab-auto-handoff.js +384 -0
- package/dist/app/collab-bindings.d.ts +57 -0
- package/dist/app/collab-bindings.js +1006 -0
- package/dist/app/collab-bootstrap-transport.d.ts +163 -0
- package/dist/app/collab-bootstrap-transport.js +769 -0
- package/dist/app/collab-bootstrap.d.ts +137 -0
- package/dist/app/collab-bootstrap.js +3455 -0
- package/dist/app/collab-handoff.d.ts +12 -0
- package/dist/app/collab-handoff.js +511 -0
- package/dist/app/collab-messages.d.ts +2 -0
- package/dist/app/collab-messages.js +2 -0
- package/dist/app/collab-notify.d.ts +156 -0
- package/dist/app/collab-notify.js +1208 -0
- package/dist/app/collab-preflight.d.ts +34 -0
- package/dist/app/collab-preflight.js +96 -0
- package/dist/app/collab-recovery-executor.d.ts +161 -0
- package/dist/app/collab-recovery-executor.js +1153 -0
- package/dist/app/collab-recovery-projection.d.ts +103 -0
- package/dist/app/collab-recovery-projection.js +659 -0
- package/dist/app/collab-recovery.d.ts +25 -0
- package/dist/app/collab-recovery.js +429 -0
- package/dist/app/collab-resources.d.ts +16 -0
- package/dist/app/collab-resources.js +278 -0
- package/dist/app/collab-role-events.d.ts +22 -0
- package/dist/app/collab-role-events.js +329 -0
- package/dist/app/collab-role-orchestration.d.ts +53 -0
- package/dist/app/collab-role-orchestration.js +601 -0
- package/dist/app/collab-role-plan.d.ts +81 -0
- package/dist/app/collab-role-plan.js +504 -0
- package/dist/app/collab-role-repair.d.ts +109 -0
- package/dist/app/collab-role-repair.js +821 -0
- package/dist/app/collab-rollover.d.ts +263 -0
- package/dist/app/collab-rollover.js +1112 -0
- package/dist/app/collab-route.d.ts +64 -0
- package/dist/app/collab-route.js +240 -0
- package/dist/app/collab-session-transition.d.ts +221 -0
- package/dist/app/collab-session-transition.js +3334 -0
- package/dist/app/collab-state.d.ts +7 -0
- package/dist/app/collab-state.js +162 -0
- package/dist/app/collab-task-store.d.ts +22 -0
- package/dist/app/collab-task-store.js +204 -0
- package/dist/app/collab-work-execution.d.ts +127 -0
- package/dist/app/collab-work-execution.js +1027 -0
- package/dist/app/collab-work-plan.d.ts +87 -0
- package/dist/app/collab-work-plan.js +437 -0
- package/dist/app/collaboration.d.ts +8 -2
- package/dist/app/collaboration.js +101 -12
- package/dist/app/doctor.js +108 -5
- package/dist/app/host-mcp.js +34 -8
- package/dist/app/host-probe.js +4 -4
- package/dist/app/init.d.ts +58 -4
- package/dist/app/init.js +768 -155
- package/dist/app/managed-pi-bootstrap-admission.d.ts +14 -0
- package/dist/app/managed-pi-bootstrap-admission.js +104 -0
- package/dist/app/managed-pi-bootstrap-refresh.d.ts +10 -0
- package/dist/app/managed-pi-bootstrap-refresh.js +78 -0
- package/dist/app/managed-pi-delivery.d.ts +8 -0
- package/dist/app/managed-pi-delivery.js +110 -0
- package/dist/app/managed-pi-handoff-receiver.d.ts +15 -0
- package/dist/app/managed-pi-handoff-receiver.js +263 -0
- package/dist/app/managed-pi-handoff-reference.d.ts +3 -0
- package/dist/app/managed-pi-handoff-reference.js +60 -0
- package/dist/app/managed-pi-herdr.d.ts +21 -0
- package/dist/app/managed-pi-herdr.js +185 -0
- package/dist/app/managed-pi-initial-admission.d.ts +28 -0
- package/dist/app/managed-pi-initial-admission.js +416 -0
- package/dist/app/managed-pi-initial-launch.d.ts +5 -0
- package/dist/app/managed-pi-initial-launch.js +61 -0
- package/dist/app/managed-pi-native-observation.d.ts +36 -0
- package/dist/app/managed-pi-native-observation.js +191 -0
- package/dist/app/managed-pi-readiness.d.ts +29 -0
- package/dist/app/managed-pi-readiness.js +288 -0
- package/dist/app/managed-pi-repair-stop.d.ts +21 -0
- package/dist/app/managed-pi-repair-stop.js +371 -0
- package/dist/app/managed-pi-resume-admission.d.ts +32 -0
- package/dist/app/managed-pi-resume-admission.js +618 -0
- package/dist/app/managed-pi-retirement.d.ts +28 -0
- package/dist/app/managed-pi-retirement.js +112 -0
- package/dist/app/managed-pi-sdk-control.d.ts +7 -0
- package/dist/app/managed-pi-sdk-control.js +169 -0
- package/dist/app/managed-pi-sdk-runtime.d.ts +3 -0
- package/dist/app/managed-pi-sdk-runtime.js +483 -0
- package/dist/app/managed-pi-source-admission.d.ts +14 -0
- package/dist/app/managed-pi-source-admission.js +323 -0
- package/dist/app/managed-pi-transition-host.d.ts +36 -0
- package/dist/app/managed-pi-transition-host.js +292 -0
- package/dist/app/managed-pi.d.ts +54 -0
- package/dist/app/managed-pi.js +248 -0
- package/dist/app/shell-readiness.d.ts +66 -0
- package/dist/app/shell-readiness.js +368 -0
- package/dist/app/task-pin.d.ts +2 -23
- package/dist/app/task-pin.js +2 -113
- package/dist/cli/commands/collaboration-binding.d.ts +13 -0
- package/dist/cli/commands/collaboration-binding.js +118 -0
- package/dist/cli/commands/collaboration-bootstrap.d.ts +10 -0
- package/dist/cli/commands/collaboration-bootstrap.js +84 -0
- package/dist/cli/commands/collaboration-capabilities.d.ts +13 -0
- package/dist/cli/commands/collaboration-capabilities.js +127 -0
- package/dist/cli/commands/collaboration-handoff.d.ts +13 -0
- package/dist/cli/commands/collaboration-handoff.js +102 -0
- package/dist/cli/commands/collaboration-message.d.ts +17 -0
- package/dist/cli/commands/collaboration-message.js +177 -0
- package/dist/cli/commands/collaboration-plan.d.ts +8 -0
- package/dist/cli/commands/collaboration-plan.js +108 -0
- package/dist/cli/commands/collaboration-preflight.d.ts +10 -0
- package/dist/cli/commands/collaboration-preflight.js +167 -0
- package/dist/cli/commands/collaboration-recovery-run.d.ts +46 -0
- package/dist/cli/commands/collaboration-recovery-run.js +224 -0
- package/dist/cli/commands/collaboration-recovery.d.ts +11 -0
- package/dist/cli/commands/collaboration-recovery.js +104 -0
- package/dist/cli/commands/collaboration-resources.d.ts +11 -0
- package/dist/cli/commands/collaboration-resources.js +96 -0
- package/dist/cli/commands/collaboration-role-plan.d.ts +9 -0
- package/dist/cli/commands/collaboration-role-plan.js +69 -0
- package/dist/cli/commands/collaboration-role-run.d.ts +11 -0
- package/dist/cli/commands/collaboration-role-run.js +128 -0
- package/dist/cli/commands/collaboration-rollover.d.ts +10 -0
- package/dist/cli/commands/collaboration-rollover.js +103 -0
- package/dist/cli/commands/collaboration-state.d.ts +10 -0
- package/dist/cli/commands/collaboration-state.js +96 -0
- package/dist/cli/commands/collaboration-transition.d.ts +10 -0
- package/dist/cli/commands/collaboration-transition.js +75 -0
- package/dist/cli/commands/collaboration-work-run.d.ts +34 -0
- package/dist/cli/commands/collaboration-work-run.js +178 -0
- package/dist/cli/commands/collaboration.d.ts +4 -0
- package/dist/cli/commands/collaboration.js +39 -4
- package/dist/cli/commands/continuity.js +2 -6
- package/dist/cli/commands/docs.d.ts +2 -0
- package/dist/cli/commands/docs.js +89 -15
- package/dist/cli/commands/host.d.ts +7 -1
- package/dist/cli/commands/host.js +122 -7
- package/dist/cli/commands/init.d.ts +20 -3
- package/dist/cli/commands/init.js +897 -232
- package/dist/cli/commands/mcp.d.ts +1 -0
- package/dist/cli/commands/mcp.js +11 -5
- package/dist/cli/commands/repair.d.ts +12 -0
- package/dist/cli/commands/repair.js +41 -0
- package/dist/cli/commands/runtime.d.ts +1 -1
- package/dist/cli/commands/runtime.js +139 -38
- package/dist/cli/commands/session.d.ts +7 -0
- package/dist/cli/commands/session.js +82 -0
- package/dist/cli/commands/task.js +19 -5
- package/dist/cli/run.js +866 -24
- package/dist/code/identity.d.ts +7 -0
- package/dist/code/identity.js +7 -3
- package/dist/code/registration.js +7 -0
- package/dist/code/service.d.ts +9 -0
- package/dist/code/service.js +16 -3
- package/dist/code/text.js +19 -7
- package/dist/collab/admission.d.ts +91 -66
- package/dist/collab/admission.js +21 -6
- package/dist/collab/canonical.d.ts +1 -1
- package/dist/collab/canonical.js +44 -3
- package/dist/collab/envelope.d.ts +2 -2
- package/dist/collab/envelope.js +12 -12
- package/dist/collab/first-work.d.ts +3 -0
- package/dist/collab/first-work.js +15 -0
- package/dist/collab/handoff.d.ts +16 -0
- package/dist/collab/handoff.js +39 -5
- package/dist/collab/index.d.ts +97 -1
- package/dist/collab/index.js +9 -1
- package/dist/collab/messages.js +126 -3
- package/dist/collab/persisted-messages.d.ts +123 -0
- package/dist/collab/persisted-messages.js +496 -0
- package/dist/collab/preflight.d.ts +1 -1
- package/dist/collab/resources.d.ts +13 -3
- package/dist/collab/resources.js +37 -6
- package/dist/collab/rollover.d.ts +311 -0
- package/dist/collab/rollover.js +1024 -0
- package/dist/collab/store.d.ts +1 -0
- package/dist/collab/store.js +1 -4
- package/dist/collab/types.d.ts +2 -354
- package/dist/collab/validation.d.ts +2 -10
- package/dist/collab/validation.js +2 -303
- package/dist/collab/work-plan.d.ts +105 -0
- package/dist/collab/work-plan.js +843 -0
- package/dist/continuity/context.d.ts +11 -2
- package/dist/continuity/context.js +100 -13
- package/dist/continuity/handoff-bundle.d.ts +296 -0
- package/dist/continuity/handoff-bundle.js +477 -0
- package/dist/continuity/index.d.ts +2 -0
- package/dist/continuity/index.js +1 -0
- package/dist/continuity/paths.js +10 -2
- package/dist/continuity/service.js +91 -15
- package/dist/continuity/task-pin.d.ts +24 -0
- package/dist/continuity/task-pin.js +590 -0
- package/dist/doctor.d.ts +1 -0
- package/dist/doctor.js +6 -0
- package/dist/experimental/index.d.ts +13 -0
- package/dist/experimental/index.js +25 -0
- package/dist/experimental/pi.d.ts +4 -0
- package/dist/experimental/pi.js +12 -0
- package/dist/hosts/claude/native.js +1 -1
- package/dist/hosts/codex/native.js +1 -1
- package/dist/hosts/codex/protocol.js +1 -1
- package/dist/hosts/integration/bootstrap-config.d.ts +58 -0
- package/dist/hosts/integration/bootstrap-config.js +254 -0
- package/dist/hosts/integration/bundle-export.d.ts +44 -0
- package/dist/hosts/integration/bundle-export.js +366 -3
- package/dist/hosts/integration/bundle.js +3 -0
- package/dist/hosts/integration/hook.js +36 -9
- package/dist/hosts/integration/pappra-bootstrap-extension.mjs +80 -0
- package/dist/hosts/integration/pappra-extension-runtime.mjs +59 -24631
- package/dist/hosts/integration/pappra-hook.mjs +61 -24749
- package/dist/hosts/integration/pappra-recovery-extension.mjs +259 -0
- package/dist/hosts/integration/pappra-session-transition-extension.mjs +276 -0
- package/dist/hosts/integration/pi-bootstrap-extension.d.ts +36 -0
- package/dist/hosts/integration/pi-bootstrap-extension.js +101 -0
- package/dist/hosts/integration/pi-bootstrap-guard.d.ts +125 -0
- package/dist/hosts/integration/pi-bootstrap-guard.js +438 -0
- package/dist/hosts/integration/pi-bootstrap-runtime.d.ts +63 -0
- package/dist/hosts/integration/pi-bootstrap-runtime.js +223 -0
- package/dist/hosts/integration/pi-native-events.d.ts +112 -0
- package/dist/hosts/integration/pi-native-events.js +348 -0
- package/dist/hosts/integration/pi-rollover-extension.d.ts +166 -0
- package/dist/hosts/integration/pi-rollover-extension.js +431 -0
- package/dist/hosts/integration/recovery-config.d.ts +48 -0
- package/dist/hosts/integration/recovery-config.js +117 -0
- package/dist/hosts/integration/service.d.ts +6 -1
- package/dist/hosts/integration/service.js +485 -35
- package/dist/hosts/integration/support.d.ts +7 -0
- package/dist/hosts/integration/support.js +9 -1
- package/dist/hosts/integration/templates.d.ts +3 -0
- package/dist/hosts/integration/templates.js +26 -3
- package/dist/hosts/pi/managed-host-identity.d.ts +2 -0
- package/dist/hosts/pi/managed-host-identity.js +40 -0
- package/dist/hosts/pi/managed-provider-diagnostics.d.ts +6 -0
- package/dist/hosts/pi/managed-provider-diagnostics.js +184 -0
- package/dist/hosts/pi/managed-sdk-session.d.ts +335 -0
- package/dist/hosts/pi/managed-sdk-session.js +1639 -0
- package/dist/hosts/pi/managed-session-extension.d.ts +20 -0
- package/dist/hosts/pi/managed-session-extension.js +84 -0
- package/dist/hosts/pi/managed-session.d.ts +177 -0
- package/dist/hosts/pi/managed-session.js +1557 -0
- package/dist/hosts/pi/protocol.js +1 -1
- package/dist/hosts/pi/query-result.js +1 -1
- package/dist/hosts/pi/resume-capability.d.ts +41 -0
- package/dist/hosts/pi/resume-capability.js +33 -0
- package/dist/hosts/pi/rpc.d.ts +182 -134
- package/dist/hosts/pi/rpc.js +230 -37
- package/dist/hosts/pilot.d.ts +97 -74
- package/dist/hosts/pilot.js +5 -1
- package/dist/hosts/version.d.ts +3 -0
- package/dist/hosts/version.js +18 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/infra/bounded-file.d.ts +19 -0
- package/dist/infra/bounded-file.js +66 -0
- package/dist/infra/fs.js +10 -2
- package/dist/infra/git.d.ts +29 -0
- package/dist/infra/git.js +45 -9
- package/dist/infra/json-property.d.ts +2 -0
- package/dist/infra/json-property.js +69 -0
- package/dist/infra/json.d.ts +4 -0
- package/dist/infra/json.js +24 -0
- package/dist/infra/owned-process-group.js +1 -1
- package/dist/infra/private-lock.d.ts +16 -0
- package/dist/infra/private-lock.js +148 -0
- package/dist/infra/private-state.d.ts +7 -0
- package/dist/infra/private-state.js +146 -0
- package/dist/infra/process-identity.d.ts +12 -0
- package/dist/infra/process-identity.js +142 -0
- package/dist/infra/validation.d.ts +5 -0
- package/dist/infra/validation.js +15 -0
- package/dist/init.d.ts +1 -0
- package/dist/init.js +6 -0
- package/dist/install/apply.d.ts +9 -1
- package/dist/install/apply.js +176 -12
- package/dist/install/dependencies.d.ts +38 -0
- package/dist/install/dependencies.js +282 -0
- package/dist/install/ownership.js +30 -1
- package/dist/install/references.d.ts +31 -0
- package/dist/install/references.js +208 -0
- package/dist/install/repair.d.ts +37 -0
- package/dist/install/repair.js +798 -0
- package/dist/install/reset-local.d.ts +16 -0
- package/dist/install/reset-local.js +304 -0
- package/dist/install/rollback.d.ts +3 -0
- package/dist/install/rollback.js +9 -3
- package/dist/install/runtime.d.ts +10 -6
- package/dist/install/runtime.js +299 -59
- package/dist/install/source-fingerprint.d.ts +2 -0
- package/dist/install/source-fingerprint.js +103 -0
- package/dist/knowledge/catalog.d.ts +1 -0
- package/dist/knowledge/catalog.js +143 -10
- package/dist/knowledge/journal.js +17 -7
- package/dist/knowledge/paths.js +2 -1
- package/dist/knowledge/refs.js +4 -0
- package/dist/knowledge/register-batch.d.ts +4 -0
- package/dist/knowledge/register-batch.js +225 -0
- package/dist/knowledge/relocate.d.ts +5 -0
- package/dist/knowledge/relocate.js +92 -0
- package/dist/knowledge/scan.js +103 -47
- package/dist/knowledge/service.d.ts +3 -0
- package/dist/knowledge/service.js +33 -1
- package/dist/knowledge/write.d.ts +4 -1
- package/dist/knowledge/write.js +1 -1
- package/dist/mcp/server.d.ts +4 -2
- package/dist/mcp/server.js +87 -136
- package/dist/schemas/collaboration-state-validation.d.ts +6 -0
- package/dist/schemas/collaboration-state-validation.js +342 -0
- package/dist/schemas/collaboration-state.d.ts +436 -0
- package/dist/schemas/collaboration-state.js +1 -0
- package/dist/schemas/collaboration.d.ts +335 -0
- package/dist/schemas/collaboration.js +272 -0
- package/dist/schemas/continuity.d.ts +8 -0
- package/dist/schemas/continuity.js +13 -3
- package/dist/schemas/doctor.d.ts +1 -0
- package/dist/schemas/doctor.js +1 -0
- package/dist/schemas/document.d.ts +61 -0
- package/dist/schemas/document.js +9 -0
- package/dist/schemas/errors.d.ts +1 -0
- package/dist/schemas/errors.js +1 -0
- package/dist/schemas/host.d.ts +24 -0
- package/dist/schemas/host.js +19 -0
- package/dist/schemas/install.d.ts +8 -2
- package/dist/schemas/install.js +11 -1
- package/dist/schemas/managed-pi-execution.d.ts +16 -0
- package/dist/schemas/managed-pi-execution.js +2 -0
- package/dist/schemas/outcome.d.ts +9 -5
- package/dist/workspace/config-file.js +1 -3
- package/dist/workspace/documents.js +12 -2
- package/dist/workspace/repositories.d.ts +7 -0
- package/dist/workspace/repositories.js +14 -5
- package/package.json +35 -35
- package/skills/pappra/SKILL.md +28 -7
- package/skills/pappra/references/collaboration.md +633 -0
- package/skills/pappra/references/environment.md +360 -0
- package/skills/pappra/references/hosts.md +20 -0
- package/skills/pappra/references/operations.md +36 -5
- package/dist/app/collab-from.d.ts +0 -35
- package/dist/app/collab-from.js +0 -84
package/dist/collab/resources.js
CHANGED
|
@@ -267,11 +267,31 @@ function nextResourceEpoch(records, keys) {
|
|
|
267
267
|
}
|
|
268
268
|
return epoch + 1;
|
|
269
269
|
}
|
|
270
|
+
/** Check recorded protocol roles; this is not authentication of a same-user caller. */
|
|
271
|
+
export function checkClaimParticipant(record, holder, subtaskId, attempt) {
|
|
272
|
+
if (record.coordinator?.agent_id === holder.agent_id &&
|
|
273
|
+
record.coordinator.session_id === holder.session_id)
|
|
274
|
+
return { ok: true };
|
|
275
|
+
if (subtaskId === null || attempt === null)
|
|
276
|
+
return { ok: false, reason: 'assigned_holder_required' };
|
|
277
|
+
const assigned = record.attempts.find((item) => item.subtask_id === subtaskId && item.attempt === attempt);
|
|
278
|
+
if (!assigned ||
|
|
279
|
+
assigned.assignee.agent_id !== holder.agent_id ||
|
|
280
|
+
assigned.assignee.session_id !== holder.session_id)
|
|
281
|
+
return { ok: false, reason: 'holder_assignment_mismatch' };
|
|
282
|
+
if (!['assigned', 'accepted', 'running'].includes(assigned.state))
|
|
283
|
+
return { ok: false, reason: 'holder_attempt_not_active' };
|
|
284
|
+
if (record.dispatch_frozen)
|
|
285
|
+
return { ok: false, reason: 'dispatch_frozen' };
|
|
286
|
+
return { ok: true };
|
|
287
|
+
}
|
|
270
288
|
/**
|
|
271
289
|
* Claim resources for one task. The domain lock serialises the decision so two tasks
|
|
272
290
|
* cannot both observe an empty domain and then claim the same path.
|
|
291
|
+
* Trusted internal preparation may claim for an assignee before ASSIGN is recorded;
|
|
292
|
+
* public request adapters must enable requireAssignedHolder.
|
|
273
293
|
*/
|
|
274
|
-
export function claimResources(taskRoot, { resources, access = 'write', holder, waitMs = 5000, clock = Date.now(), includeSharedGit = false, note = null, subtaskId = null, attempt = null, }) {
|
|
294
|
+
export function claimResources(taskRoot, { resources, access = 'write', holder, waitMs = 5000, clock = Date.now(), includeSharedGit = false, note = null, subtaskId = null, attempt = null, requireAssignedHolder = false, }) {
|
|
275
295
|
const record = readRecord(taskRoot);
|
|
276
296
|
if (!record)
|
|
277
297
|
return { ok: false, reason: 'not_initialised' };
|
|
@@ -279,6 +299,11 @@ export function claimResources(taskRoot, { resources, access = 'write', holder,
|
|
|
279
299
|
return { ok: false, reason: 'invalid_access' };
|
|
280
300
|
if (!holder?.agent_id || !holder?.session_id)
|
|
281
301
|
return { ok: false, reason: 'holder_required' };
|
|
302
|
+
if (requireAssignedHolder) {
|
|
303
|
+
const participant = checkClaimParticipant(record, holder, subtaskId, attempt);
|
|
304
|
+
if (!participant.ok)
|
|
305
|
+
return participant;
|
|
306
|
+
}
|
|
282
307
|
const domainRoot = record.domain_root;
|
|
283
308
|
const domainLock = acquireDomainLock(domainRoot, {
|
|
284
309
|
waitMs,
|
|
@@ -339,6 +364,11 @@ export function claimResources(taskRoot, { resources, access = 'write', holder,
|
|
|
339
364
|
waitMs,
|
|
340
365
|
clock,
|
|
341
366
|
apply: (current) => {
|
|
367
|
+
if (requireAssignedHolder) {
|
|
368
|
+
const participant = checkClaimParticipant(current, holder, subtaskId, attempt);
|
|
369
|
+
if (!participant.ok)
|
|
370
|
+
return participant;
|
|
371
|
+
}
|
|
342
372
|
const fresh = scanConflicts([
|
|
343
373
|
current,
|
|
344
374
|
...records.filter((item) => item.task_id !== current.task_id),
|
|
@@ -383,11 +413,13 @@ function claimIdDigest(identity) {
|
|
|
383
413
|
.slice(0, 32);
|
|
384
414
|
}
|
|
385
415
|
export function releaseClaim(taskRoot, { claimId, holder, reason, clock = Date.now(), }) {
|
|
416
|
+
if (!holder?.agent_id || !holder?.session_id)
|
|
417
|
+
return { ok: false, reason: 'holder_required' };
|
|
386
418
|
const record = readRecord(taskRoot);
|
|
387
419
|
if (!record)
|
|
388
420
|
return { ok: false, reason: 'not_initialised' };
|
|
389
421
|
const outcome = transact(taskRoot, {
|
|
390
|
-
actor: holder
|
|
422
|
+
actor: holder.agent_id,
|
|
391
423
|
purpose: 'release',
|
|
392
424
|
clock,
|
|
393
425
|
apply: (current) => {
|
|
@@ -410,9 +442,8 @@ export function releaseClaim(taskRoot, { claimId, holder, reason, clock = Date.n
|
|
|
410
442
|
const claim = matches[0];
|
|
411
443
|
if (claim.released_at)
|
|
412
444
|
return { ok: false, reason: 'already_released' };
|
|
413
|
-
if (holder
|
|
414
|
-
|
|
415
|
-
claim.holder?.session_id !== holder.session_id)) {
|
|
445
|
+
if (claim.holder?.agent_id !== holder.agent_id ||
|
|
446
|
+
claim.holder?.session_id !== holder.session_id) {
|
|
416
447
|
return {
|
|
417
448
|
ok: false,
|
|
418
449
|
reason: 'holder_mismatch',
|
|
@@ -426,7 +457,7 @@ export function releaseClaim(taskRoot, { claimId, holder, reason, clock = Date.n
|
|
|
426
457
|
detail: 'a cancel request does not prove the holder stopped',
|
|
427
458
|
};
|
|
428
459
|
claim.released_at = nowIso(clock);
|
|
429
|
-
claim.released_by = holder
|
|
460
|
+
claim.released_by = holder.agent_id;
|
|
430
461
|
claim.release_reason = reason ?? null;
|
|
431
462
|
return {
|
|
432
463
|
record: current,
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import type { Identity, TaskRecord } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Bounded, record-level writer rollover correlation.
|
|
4
|
+
*
|
|
5
|
+
* This module only reduces the existing task record: handoff state and claims stay
|
|
6
|
+
* authoritative, and no second authority store, filesystem access, native control or
|
|
7
|
+
* continuity import is introduced. An intent pins the immutable inputs of one
|
|
8
|
+
* writer-to-writer transfer, including the confirmed source native identity; confirmation
|
|
9
|
+
* and first-work evidence must be stored, digest-verified protocol messages correlated to
|
|
10
|
+
* that intent. A caller-supplied object is never treated as authenticated native proof.
|
|
11
|
+
*/
|
|
12
|
+
export declare const ROLLOVER_INTENT_SCHEMA = "pappra/collab-rollover-intent/1";
|
|
13
|
+
export declare const ROLLOVER_SUCCESSION_SCHEMA = "pappra/collab-succession/1";
|
|
14
|
+
export interface RolloverClaimReference {
|
|
15
|
+
readonly claim_id: string;
|
|
16
|
+
readonly resource_epoch: number;
|
|
17
|
+
}
|
|
18
|
+
export interface RolloverBundleReference {
|
|
19
|
+
readonly ref: string;
|
|
20
|
+
readonly digest: string;
|
|
21
|
+
}
|
|
22
|
+
/** The native session identity of one writer; never inferred from another pointer. */
|
|
23
|
+
export interface RolloverNativeIdentity {
|
|
24
|
+
readonly agent_id: string | null;
|
|
25
|
+
readonly runner: string | null;
|
|
26
|
+
readonly session_id: string | null;
|
|
27
|
+
readonly run_id: string | null;
|
|
28
|
+
readonly mission_id: string | null;
|
|
29
|
+
}
|
|
30
|
+
export interface RolloverNativeBindingInput extends RolloverNativeIdentity {
|
|
31
|
+
readonly evidence_ref: string;
|
|
32
|
+
readonly observed_at?: string | null;
|
|
33
|
+
}
|
|
34
|
+
export interface RolloverTransferBoundary {
|
|
35
|
+
/** Message-application position at completion; never a sender timestamp. */
|
|
36
|
+
readonly message_count: number;
|
|
37
|
+
readonly state_revision: number;
|
|
38
|
+
readonly at: string;
|
|
39
|
+
}
|
|
40
|
+
/** Explicit quiescence inventory. Unknown or partial completeness never authorizes transfer. */
|
|
41
|
+
export interface RolloverInventory {
|
|
42
|
+
readonly completeness: 'complete' | 'partial' | 'unknown';
|
|
43
|
+
readonly inflight: readonly unknown[];
|
|
44
|
+
readonly pending_approvals: readonly unknown[];
|
|
45
|
+
/** Required: absent message completeness can never be treated as "none". */
|
|
46
|
+
readonly pending_messages?: readonly unknown[];
|
|
47
|
+
/** Captured partial outputs; part of the pinned inventory identity. */
|
|
48
|
+
readonly partial_outputs?: readonly unknown[];
|
|
49
|
+
}
|
|
50
|
+
export interface CreateRolloverIntentInput {
|
|
51
|
+
readonly intent_id: string;
|
|
52
|
+
readonly generation: number;
|
|
53
|
+
readonly handoff_id: string;
|
|
54
|
+
readonly subtask_id: string;
|
|
55
|
+
readonly attempt: number;
|
|
56
|
+
readonly input_revision: string;
|
|
57
|
+
readonly from: Identity;
|
|
58
|
+
readonly to: Identity;
|
|
59
|
+
readonly claims: readonly RolloverClaimReference[];
|
|
60
|
+
readonly bundle: RolloverBundleReference;
|
|
61
|
+
readonly coordinator_epoch: number;
|
|
62
|
+
readonly clock?: number;
|
|
63
|
+
}
|
|
64
|
+
export interface RolloverFailure {
|
|
65
|
+
readonly ok: false;
|
|
66
|
+
readonly reason: string;
|
|
67
|
+
readonly [key: string]: unknown;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Records the immutable intent and opens the underlying writer handoff. An exact replay of
|
|
71
|
+
* the same intent inputs returns the existing intent without another mutation.
|
|
72
|
+
*/
|
|
73
|
+
export declare function createRolloverIntent(record: TaskRecord, input: CreateRolloverIntentInput): RolloverFailure | {
|
|
74
|
+
ok: false;
|
|
75
|
+
reason: string;
|
|
76
|
+
shared_resources?: never;
|
|
77
|
+
other_handoff?: never;
|
|
78
|
+
other_state?: never;
|
|
79
|
+
expected?: never;
|
|
80
|
+
actual?: never;
|
|
81
|
+
claim_id?: never;
|
|
82
|
+
handoff_id?: never;
|
|
83
|
+
state?: never;
|
|
84
|
+
} | {
|
|
85
|
+
ok: false;
|
|
86
|
+
reason: string;
|
|
87
|
+
other_handoff: string;
|
|
88
|
+
other_state: string;
|
|
89
|
+
shared_resources: string[];
|
|
90
|
+
expected?: never;
|
|
91
|
+
actual?: never;
|
|
92
|
+
claim_id?: never;
|
|
93
|
+
handoff_id?: never;
|
|
94
|
+
state?: never;
|
|
95
|
+
} | {
|
|
96
|
+
shared_resources?: never;
|
|
97
|
+
ok: false;
|
|
98
|
+
reason: string;
|
|
99
|
+
other_handoff: string;
|
|
100
|
+
other_state: string;
|
|
101
|
+
expected?: never;
|
|
102
|
+
actual?: never;
|
|
103
|
+
claim_id?: never;
|
|
104
|
+
handoff_id?: never;
|
|
105
|
+
state?: never;
|
|
106
|
+
} | {
|
|
107
|
+
shared_resources?: never;
|
|
108
|
+
other_handoff?: never;
|
|
109
|
+
other_state?: never;
|
|
110
|
+
ok: false;
|
|
111
|
+
reason: string;
|
|
112
|
+
expected: number | null;
|
|
113
|
+
actual: number;
|
|
114
|
+
claim_id?: never;
|
|
115
|
+
handoff_id?: never;
|
|
116
|
+
state?: never;
|
|
117
|
+
} | {
|
|
118
|
+
shared_resources?: never;
|
|
119
|
+
other_handoff?: never;
|
|
120
|
+
other_state?: never;
|
|
121
|
+
expected?: never;
|
|
122
|
+
actual?: never;
|
|
123
|
+
ok: false;
|
|
124
|
+
reason: string;
|
|
125
|
+
claim_id: string;
|
|
126
|
+
handoff_id?: never;
|
|
127
|
+
state?: never;
|
|
128
|
+
} | {
|
|
129
|
+
ok: true;
|
|
130
|
+
intent: import("./types.js").RolloverIntent;
|
|
131
|
+
handoff_state: string | null;
|
|
132
|
+
replayed: boolean;
|
|
133
|
+
};
|
|
134
|
+
/** Read-only projection of one intent, its handoff progress and any recorded succession. */
|
|
135
|
+
export declare function inspectRolloverIntent(record: TaskRecord, intentId: string): RolloverFailure | {
|
|
136
|
+
ok: true;
|
|
137
|
+
intent: import("./types.js").RolloverIntent;
|
|
138
|
+
handoff_state: string | null;
|
|
139
|
+
ownership: string | null;
|
|
140
|
+
assignee: Identity | null;
|
|
141
|
+
claims: {
|
|
142
|
+
claim_id: string;
|
|
143
|
+
expected_resource_epoch: number;
|
|
144
|
+
holder: Identity | null;
|
|
145
|
+
resource_epoch: number | null;
|
|
146
|
+
released_at: string | null;
|
|
147
|
+
}[];
|
|
148
|
+
transfer_boundary: import("./types.js").RolloverTransferBoundary | null;
|
|
149
|
+
succession: import("./types.js").SuccessionEntry | null;
|
|
150
|
+
routing: string;
|
|
151
|
+
native_archive: string;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Records confirmed quiescence and freezes the transfer inventory. An absent or non-complete
|
|
155
|
+
* inventory, unknown stop evidence, a blocked writer and any drift are refused without
|
|
156
|
+
* mutation; an exact replay of a completed step is a no-op.
|
|
157
|
+
*/
|
|
158
|
+
export declare function prepareRolloverTransfer(record: TaskRecord, { intent_id, observation, evidence_ref, inventory, actor, clock, }: {
|
|
159
|
+
intent_id: string;
|
|
160
|
+
observation: string;
|
|
161
|
+
evidence_ref: string | null;
|
|
162
|
+
inventory: RolloverInventory;
|
|
163
|
+
actor?: string;
|
|
164
|
+
clock?: number;
|
|
165
|
+
}): RolloverFailure | {
|
|
166
|
+
ok: false;
|
|
167
|
+
reason: string;
|
|
168
|
+
} | {
|
|
169
|
+
ok: true;
|
|
170
|
+
handoff_state: string;
|
|
171
|
+
replayed: boolean;
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* Confirms the successor only from a stored, digest-verified ACK envelope that carries the
|
|
175
|
+
* pinned input revision, the current coordinator epoch and recipient, the intent/handoff/
|
|
176
|
+
* generation correlation and this attempt's registered assignment as its bootstrap.
|
|
177
|
+
*/
|
|
178
|
+
export declare function confirmRolloverReceiver(record: TaskRecord, { intent_id, message, clock, }: {
|
|
179
|
+
intent_id: string;
|
|
180
|
+
message: unknown;
|
|
181
|
+
clock?: number;
|
|
182
|
+
}): RolloverFailure | {
|
|
183
|
+
state?: never;
|
|
184
|
+
ok: false;
|
|
185
|
+
reason: string;
|
|
186
|
+
from: string;
|
|
187
|
+
to: string;
|
|
188
|
+
expected: string | null | undefined;
|
|
189
|
+
at?: never;
|
|
190
|
+
} | {
|
|
191
|
+
ok: false;
|
|
192
|
+
reason: string;
|
|
193
|
+
type?: never;
|
|
194
|
+
} | {
|
|
195
|
+
ok: false;
|
|
196
|
+
reason: string;
|
|
197
|
+
type: string;
|
|
198
|
+
} | {
|
|
199
|
+
ok: true;
|
|
200
|
+
handoff_state: string;
|
|
201
|
+
replayed: boolean;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Completes the writer transfer: claims move to the successor with a raised resource epoch,
|
|
205
|
+
* the attempt is reassigned and its native identity is rebound explicitly. The coordinator
|
|
206
|
+
* owner epoch is never raised here.
|
|
207
|
+
*/
|
|
208
|
+
export declare function completeRolloverTransfer(record: TaskRecord, { intent_id, successor_native, actor, clock, }: {
|
|
209
|
+
intent_id: string;
|
|
210
|
+
successor_native: RolloverNativeBindingInput;
|
|
211
|
+
actor?: string;
|
|
212
|
+
clock?: number;
|
|
213
|
+
}): RolloverFailure | {
|
|
214
|
+
ok: false;
|
|
215
|
+
reason: string;
|
|
216
|
+
native?: never;
|
|
217
|
+
reconciled_uncertainty?: never;
|
|
218
|
+
} | {
|
|
219
|
+
state?: never;
|
|
220
|
+
ok: false;
|
|
221
|
+
reason: string;
|
|
222
|
+
from: string;
|
|
223
|
+
to: string;
|
|
224
|
+
expected: string | null | undefined;
|
|
225
|
+
at?: never;
|
|
226
|
+
} | {
|
|
227
|
+
expected?: never;
|
|
228
|
+
actual?: never;
|
|
229
|
+
ok: false;
|
|
230
|
+
reason: string;
|
|
231
|
+
drift?: never;
|
|
232
|
+
} | {
|
|
233
|
+
expected?: never;
|
|
234
|
+
actual?: never;
|
|
235
|
+
ok: false;
|
|
236
|
+
reason: string;
|
|
237
|
+
drift: ({
|
|
238
|
+
expected?: never;
|
|
239
|
+
actual?: never;
|
|
240
|
+
from?: never;
|
|
241
|
+
claim_id: string;
|
|
242
|
+
reason: string;
|
|
243
|
+
} | {
|
|
244
|
+
from?: never;
|
|
245
|
+
claim_id: string;
|
|
246
|
+
reason: string;
|
|
247
|
+
expected: number | null | undefined;
|
|
248
|
+
actual: number;
|
|
249
|
+
} | {
|
|
250
|
+
from?: never;
|
|
251
|
+
claim_id: string;
|
|
252
|
+
reason: string;
|
|
253
|
+
expected: Identity | null | undefined;
|
|
254
|
+
actual: Identity;
|
|
255
|
+
} | {
|
|
256
|
+
expected?: never;
|
|
257
|
+
claim_id: string;
|
|
258
|
+
reason: string;
|
|
259
|
+
from: Identity;
|
|
260
|
+
actual: Identity;
|
|
261
|
+
})[];
|
|
262
|
+
} | {
|
|
263
|
+
drift?: never;
|
|
264
|
+
ok: false;
|
|
265
|
+
reason: string;
|
|
266
|
+
expected: number;
|
|
267
|
+
actual: number | null;
|
|
268
|
+
} | {
|
|
269
|
+
ok: true;
|
|
270
|
+
handoff_state: string;
|
|
271
|
+
transfer_boundary: import("./types.js").RolloverTransferBoundary;
|
|
272
|
+
replayed: boolean;
|
|
273
|
+
owner_epoch?: never;
|
|
274
|
+
} | {
|
|
275
|
+
ok: true;
|
|
276
|
+
handoff_state: string;
|
|
277
|
+
transfer_boundary: RolloverTransferBoundary;
|
|
278
|
+
owner_epoch: number | null;
|
|
279
|
+
replayed: boolean;
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* Records the source-session history marker only when a stored, admitted successor REPORT
|
|
283
|
+
* proves first work after the recorded transfer boundary, under the pinned input, current
|
|
284
|
+
* attempt, exact post-transfer claim epochs and the pinned successor native identity.
|
|
285
|
+
*/
|
|
286
|
+
export declare function recordRolloverFirstWork(record: TaskRecord, { intent_id, message, clock, }: {
|
|
287
|
+
intent_id: string;
|
|
288
|
+
message: unknown;
|
|
289
|
+
clock?: number;
|
|
290
|
+
}): RolloverFailure | {
|
|
291
|
+
ok: true;
|
|
292
|
+
succession: {
|
|
293
|
+
schema: string;
|
|
294
|
+
intent_id: string;
|
|
295
|
+
handoff_id: string;
|
|
296
|
+
generation: number;
|
|
297
|
+
old_native: RolloverNativeIdentity;
|
|
298
|
+
successor_native: RolloverNativeIdentity;
|
|
299
|
+
archived_at: string;
|
|
300
|
+
history_retained: true;
|
|
301
|
+
routing: 'pending';
|
|
302
|
+
native_archive: 'unavailable';
|
|
303
|
+
proof: {
|
|
304
|
+
message_id: string;
|
|
305
|
+
digest: string;
|
|
306
|
+
};
|
|
307
|
+
};
|
|
308
|
+
replayed: boolean;
|
|
309
|
+
routing: string;
|
|
310
|
+
native_archive: string;
|
|
311
|
+
};
|