@elie-laloum/outpost 2.0.0 → 4.0.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 +42 -0
- package/README.md +3 -1
- package/SECURITY.md +3 -1
- package/dist/adapters/agents/claude-diagnostics.d.ts +1 -0
- package/dist/adapters/agents/claude-diagnostics.js +7 -0
- package/dist/adapters/agents/claude-diagnostics.js.map +1 -0
- package/dist/adapters/agents/cli-diagnostics.constants.d.ts +12 -0
- package/dist/adapters/agents/cli-diagnostics.constants.js +24 -0
- package/dist/adapters/agents/cli-diagnostics.constants.js.map +1 -0
- package/dist/adapters/agents/cli-diagnostics.d.ts +4 -0
- package/dist/adapters/agents/cli-diagnostics.js +14 -0
- package/dist/adapters/agents/cli-diagnostics.js.map +1 -0
- package/dist/adapters/agents/cli-diagnostics.types.d.ts +13 -0
- package/dist/adapters/agents/cli-diagnostics.types.js +2 -0
- package/dist/adapters/agents/cli-diagnostics.types.js.map +1 -0
- package/dist/adapters/agents/codex-diagnostics.d.ts +1 -0
- package/dist/adapters/agents/codex-diagnostics.js +7 -0
- package/dist/adapters/agents/codex-diagnostics.js.map +1 -0
- package/dist/adapters/agents/gemini-adapter.d.ts +3 -0
- package/dist/adapters/agents/gemini-adapter.js +15 -0
- package/dist/adapters/agents/gemini-adapter.js.map +1 -0
- package/dist/adapters/agents/gemini-diagnostics.d.ts +2 -0
- package/dist/adapters/agents/gemini-diagnostics.js +15 -0
- package/dist/adapters/agents/gemini-diagnostics.js.map +1 -0
- package/dist/adapters/agents/gemini-events.d.ts +2 -0
- package/dist/adapters/agents/gemini-events.js +50 -0
- package/dist/adapters/agents/gemini-events.js.map +1 -0
- package/dist/adapters/agents/gemini-request.d.ts +4 -0
- package/dist/adapters/agents/gemini-request.js +21 -0
- package/dist/adapters/agents/gemini-request.js.map +1 -0
- package/dist/adapters/agents/gemini.types.d.ts +6 -0
- package/dist/adapters/agents/gemini.types.js +2 -0
- package/dist/adapters/agents/gemini.types.js.map +1 -0
- package/dist/adapters/agents/protocol-fixtures.constants.d.ts +2 -0
- package/dist/adapters/agents/protocol-fixtures.constants.js +105 -0
- package/dist/adapters/agents/protocol-fixtures.constants.js.map +1 -0
- package/dist/adapters/agents/protocol-fixtures.types.d.ts +6 -0
- package/dist/adapters/agents/protocol-fixtures.types.js +2 -0
- package/dist/adapters/agents/protocol-fixtures.types.js.map +1 -0
- package/dist/application/agent-bootstrap.constants.d.ts +1 -0
- package/dist/application/agent-bootstrap.constants.js +1 -0
- package/dist/application/agent-bootstrap.constants.js.map +1 -1
- package/dist/application/agent-bootstrap.js +6 -2
- package/dist/application/agent-bootstrap.js.map +1 -1
- package/dist/application/agent-output.js +9 -2
- package/dist/application/agent-output.js.map +1 -1
- package/dist/application/artifact-tasks.d.ts +5 -0
- package/dist/application/artifact-tasks.js +31 -0
- package/dist/application/artifact-tasks.js.map +1 -0
- package/dist/application/artifact-tasks.types.d.ts +8 -0
- package/dist/application/artifact-tasks.types.js +2 -0
- package/dist/application/artifact-tasks.types.js.map +1 -0
- package/dist/application/diagnostic-probe.d.ts +3 -0
- package/dist/application/diagnostic-probe.js +55 -0
- package/dist/application/diagnostic-probe.js.map +1 -0
- package/dist/application/dispatch-validation.js +2 -0
- package/dist/application/dispatch-validation.js.map +1 -1
- package/dist/application/doctor-agent.constants.d.ts +11 -0
- package/dist/application/doctor-agent.constants.js +10 -0
- package/dist/application/doctor-agent.constants.js.map +1 -0
- package/dist/application/doctor-agent.d.ts +3 -0
- package/dist/application/doctor-agent.js +53 -0
- package/dist/application/doctor-agent.js.map +1 -0
- package/dist/application/doctor-image.d.ts +3 -0
- package/dist/application/doctor-image.js +133 -0
- package/dist/application/doctor-image.js.map +1 -0
- package/dist/application/doctor-protocol.d.ts +3 -0
- package/dist/application/doctor-protocol.js +30 -0
- package/dist/application/doctor-protocol.js.map +1 -0
- package/dist/application/doctor-protocol.types.d.ts +10 -0
- package/dist/application/doctor-protocol.types.js +2 -0
- package/dist/application/doctor-protocol.types.js.map +1 -0
- package/dist/application/doctor-sandbox.constants.d.ts +5 -0
- package/dist/application/doctor-sandbox.constants.js +6 -0
- package/dist/application/doctor-sandbox.constants.js.map +1 -0
- package/dist/application/doctor-sandbox.d.ts +4 -0
- package/dist/application/doctor-sandbox.js +133 -0
- package/dist/application/doctor-sandbox.js.map +1 -0
- package/dist/application/doctor-sandbox.types.d.ts +23 -0
- package/dist/application/doctor-sandbox.types.js +2 -0
- package/dist/application/doctor-sandbox.types.js.map +1 -0
- package/dist/application/doctor-transfers.constants.d.ts +6 -0
- package/dist/application/doctor-transfers.constants.js +7 -0
- package/dist/application/doctor-transfers.constants.js.map +1 -0
- package/dist/application/doctor-transfers.d.ts +4 -0
- package/dist/application/doctor-transfers.js +88 -0
- package/dist/application/doctor-transfers.js.map +1 -0
- package/dist/application/doctor.constants.d.ts +9 -0
- package/dist/application/doctor.constants.js +15 -0
- package/dist/application/doctor.constants.js.map +1 -0
- package/dist/application/doctor.d.ts +3 -0
- package/dist/application/doctor.js +106 -0
- package/dist/application/doctor.js.map +1 -0
- package/dist/application/doctor.types.d.ts +39 -0
- package/dist/application/doctor.types.js +2 -0
- package/dist/application/doctor.types.js.map +1 -0
- package/dist/application/execution.js +1 -0
- package/dist/application/execution.js.map +1 -1
- package/dist/application/outpost.types.d.ts +4 -0
- package/dist/application/outpost.types.js.map +1 -1
- package/dist/application/queue-worker.d.ts +2 -0
- package/dist/application/queue-worker.js +75 -0
- package/dist/application/queue-worker.js.map +1 -0
- package/dist/application/queue-worker.types.d.ts +15 -0
- package/dist/application/queue-worker.types.js +2 -0
- package/dist/application/queue-worker.types.js.map +1 -0
- package/dist/application/queued-task.d.ts +3 -0
- package/dist/application/queued-task.js +56 -0
- package/dist/application/queued-task.js.map +1 -0
- package/dist/application/queued-task.types.d.ts +11 -0
- package/dist/application/queued-task.types.js +2 -0
- package/dist/application/queued-task.types.js.map +1 -0
- package/dist/application/recovery-checksum-capture.d.ts +2 -0
- package/dist/application/recovery-checksum-capture.js +32 -0
- package/dist/application/recovery-checksum-capture.js.map +1 -0
- package/dist/application/recovery-checksum-paths.d.ts +2 -0
- package/dist/application/recovery-checksum-paths.js +11 -0
- package/dist/application/recovery-checksum-paths.js.map +1 -0
- package/dist/application/recovery-checksums.constants.d.ts +5 -0
- package/dist/application/recovery-checksums.constants.js +6 -0
- package/dist/application/recovery-checksums.constants.js.map +1 -0
- package/dist/application/recovery-checksums.d.ts +3 -0
- package/dist/application/recovery-checksums.js +94 -0
- package/dist/application/recovery-checksums.js.map +1 -0
- package/dist/application/recovery-checksums.types.d.ts +17 -0
- package/dist/application/recovery-checksums.types.js +2 -0
- package/dist/application/recovery-checksums.types.js.map +1 -0
- package/dist/application/recovery-inspection.d.ts +2 -0
- package/dist/application/recovery-inspection.js +32 -0
- package/dist/application/recovery-inspection.js.map +1 -0
- package/dist/application/recovery-inspection.types.d.ts +18 -0
- package/dist/application/recovery-inspection.types.js +2 -0
- package/dist/application/recovery-inspection.types.js.map +1 -0
- package/dist/application/recovery-restorability.d.ts +2 -0
- package/dist/application/recovery-restorability.js +137 -0
- package/dist/application/recovery-restorability.js.map +1 -0
- package/dist/application/recovery-restore-snapshot.d.ts +2 -0
- package/dist/application/recovery-restore-snapshot.js +57 -0
- package/dist/application/recovery-restore-snapshot.js.map +1 -0
- package/dist/application/recovery-restore.d.ts +3 -0
- package/dist/application/recovery-restore.js +161 -0
- package/dist/application/recovery-restore.js.map +1 -0
- package/dist/application/recovery-restore.types.d.ts +28 -0
- package/dist/application/recovery-restore.types.js +2 -0
- package/dist/application/recovery-restore.types.js.map +1 -0
- package/dist/application/recovery-retention-policy.d.ts +2 -0
- package/dist/application/recovery-retention-policy.js +21 -0
- package/dist/application/recovery-retention-policy.js.map +1 -0
- package/dist/application/recovery-retention.constants.d.ts +3 -0
- package/dist/application/recovery-retention.constants.js +2 -0
- package/dist/application/recovery-retention.constants.js.map +1 -0
- package/dist/application/recovery-retention.d.ts +4 -0
- package/dist/application/recovery-retention.js +207 -0
- package/dist/application/recovery-retention.js.map +1 -0
- package/dist/application/recovery-retention.types.d.ts +52 -0
- package/dist/application/recovery-retention.types.js +2 -0
- package/dist/application/recovery-retention.types.js.map +1 -0
- package/dist/application/recovery-verification.constants.d.ts +5 -0
- package/dist/application/recovery-verification.constants.js +10 -0
- package/dist/application/recovery-verification.constants.js.map +1 -0
- package/dist/application/recovery-verification.d.ts +3 -0
- package/dist/application/recovery-verification.js +107 -0
- package/dist/application/recovery-verification.js.map +1 -0
- package/dist/application/recovery-verification.types.d.ts +26 -0
- package/dist/application/recovery-verification.types.js +2 -0
- package/dist/application/recovery-verification.types.js.map +1 -0
- package/dist/application/remote-apply.js +30 -6
- package/dist/application/remote-apply.js.map +1 -1
- package/dist/application/remote-backup.js +6 -2
- package/dist/application/remote-backup.js.map +1 -1
- package/dist/application/remote-download.js +38 -6
- package/dist/application/remote-download.js.map +1 -1
- package/dist/application/remote-history.d.ts +6 -0
- package/dist/application/remote-history.js +114 -0
- package/dist/application/remote-history.js.map +1 -0
- package/dist/application/remote-upload.d.ts +2 -0
- package/dist/application/remote-upload.js +17 -0
- package/dist/application/remote-upload.js.map +1 -0
- package/dist/application/remote-validation.js +39 -28
- package/dist/application/remote-validation.js.map +1 -1
- package/dist/application/remote-workspace.constants.d.ts +3 -0
- package/dist/application/remote-workspace.constants.js +2 -0
- package/dist/application/remote-workspace.constants.js.map +1 -0
- package/dist/application/remote-workspace.js +10 -10
- package/dist/application/remote-workspace.js.map +1 -1
- package/dist/application/remote-workspace.types.d.ts +3 -1
- package/dist/application/remote-workspace.types.js.map +1 -1
- package/dist/application/sandbox-activity.d.ts +3 -0
- package/dist/application/sandbox-activity.js +25 -0
- package/dist/application/sandbox-activity.js.map +1 -0
- package/dist/application/sandbox-provision.js +55 -10
- package/dist/application/sandbox-provision.js.map +1 -1
- package/dist/application/sandbox-session.types.d.ts +2 -0
- package/dist/application/sandbox-session.types.js.map +1 -1
- package/dist/application/sandbox.js +33 -10
- package/dist/application/sandbox.js.map +1 -1
- package/dist/application/speculation-host.d.ts +2 -0
- package/dist/application/speculation-host.js +30 -0
- package/dist/application/speculation-host.js.map +1 -0
- package/dist/application/speculation.constants.d.ts +4 -0
- package/dist/application/speculation.constants.js +2 -0
- package/dist/application/speculation.constants.js.map +1 -0
- package/dist/application/speculation.d.ts +2 -0
- package/dist/application/speculation.js +166 -0
- package/dist/application/speculation.js.map +1 -0
- package/dist/application/speculation.types.d.ts +56 -0
- package/dist/application/speculation.types.js +2 -0
- package/dist/application/speculation.types.js.map +1 -0
- package/dist/application/storage-reservation.d.ts +3 -0
- package/dist/application/storage-reservation.js +10 -0
- package/dist/application/storage-reservation.js.map +1 -0
- package/dist/application/storage-reservation.types.d.ts +4 -0
- package/dist/application/storage-reservation.types.js +2 -0
- package/dist/application/storage-reservation.types.js.map +1 -0
- package/dist/application/task-usage.d.ts +4 -0
- package/dist/application/task-usage.js +41 -0
- package/dist/application/task-usage.js.map +1 -0
- package/dist/application/task-usage.types.d.ts +5 -0
- package/dist/application/task-usage.types.js +2 -0
- package/dist/application/task-usage.types.js.map +1 -0
- package/dist/application/tasks.js +23 -2
- package/dist/application/tasks.js.map +1 -1
- package/dist/application/tasks.types.d.ts +4 -3
- package/dist/application/tasks.types.js.map +1 -1
- package/dist/application/workspace-allocation.d.ts +3 -0
- package/dist/application/workspace-allocation.js +34 -0
- package/dist/application/workspace-allocation.js.map +1 -0
- package/dist/application/workspace.js +2 -2
- package/dist/application/workspace.js.map +1 -1
- package/dist/cli/commands.js +4 -0
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/doctor-command.d.ts +3 -0
- package/dist/cli/doctor-command.js +38 -0
- package/dist/cli/doctor-command.js.map +1 -0
- package/dist/cli/main.constants.d.ts +38 -2
- package/dist/cli/main.constants.js +21 -2
- package/dist/cli/main.constants.js.map +1 -1
- package/dist/cli/recovery-command.d.ts +2 -0
- package/dist/cli/recovery-command.js +93 -0
- package/dist/cli/recovery-command.js.map +1 -0
- package/dist/cli/recovery-prune-command.d.ts +2 -0
- package/dist/cli/recovery-prune-command.js +34 -0
- package/dist/cli/recovery-prune-command.js.map +1 -0
- package/dist/cli/recovery-restore-command.d.ts +2 -0
- package/dist/cli/recovery-restore-command.js +34 -0
- package/dist/cli/recovery-restore-command.js.map +1 -0
- package/dist/cli/recovery-verify-command.d.ts +2 -0
- package/dist/cli/recovery-verify-command.js +43 -0
- package/dist/cli/recovery-verify-command.js.map +1 -0
- package/dist/cli/scaffold-files.js +2 -2
- package/dist/cli/scaffold-files.js.map +1 -1
- package/dist/cli/scaffold-validation.js +1 -1
- package/dist/cli/scaffold-validation.js.map +1 -1
- package/dist/cli/scaffold.constants.d.ts +5 -0
- package/dist/cli/scaffold.constants.js +7 -2
- package/dist/cli/scaffold.constants.js.map +1 -1
- package/dist/cli/scaffold.types.d.ts +1 -1
- package/dist/cli/scaffold.types.js.map +1 -1
- package/dist/domain/agent.types.d.ts +2 -0
- package/dist/domain/agent.types.js.map +1 -1
- package/dist/domain/artifact-reference.d.ts +4 -0
- package/dist/domain/artifact-reference.js +90 -0
- package/dist/domain/artifact-reference.js.map +1 -0
- package/dist/domain/artifact.constants.d.ts +2 -0
- package/dist/domain/artifact.constants.js +3 -0
- package/dist/domain/artifact.constants.js.map +1 -0
- package/dist/domain/artifact.d.ts +7 -0
- package/dist/domain/artifact.js +104 -0
- package/dist/domain/artifact.js.map +1 -0
- package/dist/domain/artifact.types.d.ts +44 -0
- package/dist/domain/artifact.types.js +2 -0
- package/dist/domain/artifact.types.js.map +1 -0
- package/dist/domain/egress.constants.d.ts +1 -0
- package/dist/domain/egress.constants.js +7 -0
- package/dist/domain/egress.constants.js.map +1 -0
- package/dist/domain/egress.d.ts +2 -0
- package/dist/domain/egress.js +48 -0
- package/dist/domain/egress.js.map +1 -0
- package/dist/domain/egress.types.d.ts +8 -0
- package/dist/domain/egress.types.js +2 -0
- package/dist/domain/egress.types.js.map +1 -0
- package/dist/domain/ports.d.ts +1 -1
- package/dist/domain/ports.js.map +1 -1
- package/dist/domain/sandbox.types.d.ts +13 -0
- package/dist/domain/sandbox.types.js.map +1 -1
- package/dist/domain/task-queue.constants.d.ts +8 -0
- package/dist/domain/task-queue.constants.js +9 -0
- package/dist/domain/task-queue.constants.js.map +1 -0
- package/dist/domain/task-queue.d.ts +11 -0
- package/dist/domain/task-queue.js +105 -0
- package/dist/domain/task-queue.js.map +1 -0
- package/dist/domain/task-queue.types.d.ts +41 -0
- package/dist/domain/task-queue.types.js +2 -0
- package/dist/domain/task-queue.types.js.map +1 -0
- package/dist/domain/workflow/budget.constants.d.ts +1 -0
- package/dist/domain/workflow/budget.constants.js +7 -0
- package/dist/domain/workflow/budget.constants.js.map +1 -0
- package/dist/domain/workflow/budget.d.ts +9 -0
- package/dist/domain/workflow/budget.js +69 -0
- package/dist/domain/workflow/budget.js.map +1 -0
- package/dist/domain/workflow/budget.types.d.ts +15 -0
- package/dist/domain/workflow/budget.types.js +2 -0
- package/dist/domain/workflow/budget.types.js.map +1 -0
- package/dist/domain/workflow/checkpoint-validation.d.ts +3 -0
- package/dist/domain/workflow/checkpoint-validation.js +81 -0
- package/dist/domain/workflow/checkpoint-validation.js.map +1 -0
- package/dist/domain/workflow/checkpoint-value.d.ts +2 -0
- package/dist/domain/workflow/checkpoint-value.js +49 -0
- package/dist/domain/workflow/checkpoint-value.js.map +1 -0
- package/dist/domain/workflow/checkpoint.d.ts +3 -0
- package/dist/domain/workflow/checkpoint.js +70 -0
- package/dist/domain/workflow/checkpoint.js.map +1 -0
- package/dist/domain/workflow/checkpoint.types.d.ts +40 -0
- package/dist/domain/workflow/checkpoint.types.js +2 -0
- package/dist/domain/workflow/checkpoint.types.js.map +1 -0
- package/dist/domain/workflow/gate-validation.d.ts +4 -0
- package/dist/domain/workflow/gate-validation.js +71 -0
- package/dist/domain/workflow/gate-validation.js.map +1 -0
- package/dist/domain/workflow/gates.constants.d.ts +4 -0
- package/dist/domain/workflow/gates.constants.js +5 -0
- package/dist/domain/workflow/gates.constants.js.map +1 -0
- package/dist/domain/workflow/gates.d.ts +7 -0
- package/dist/domain/workflow/gates.js +85 -0
- package/dist/domain/workflow/gates.js.map +1 -0
- package/dist/domain/workflow/gates.types.d.ts +27 -0
- package/dist/domain/workflow/gates.types.js +2 -0
- package/dist/domain/workflow/gates.types.js.map +1 -0
- package/dist/domain/workflow/task-runner.js +22 -3
- package/dist/domain/workflow/task-runner.js.map +1 -1
- package/dist/domain/workflow/usage-receipt.constants.d.ts +2 -0
- package/dist/domain/workflow/usage-receipt.constants.js +3 -0
- package/dist/domain/workflow/usage-receipt.constants.js.map +1 -0
- package/dist/domain/workflow/usage-receipt.d.ts +2 -0
- package/dist/domain/workflow/usage-receipt.js +18 -0
- package/dist/domain/workflow/usage-receipt.js.map +1 -0
- package/dist/domain/workflow/validation.js +6 -0
- package/dist/domain/workflow/validation.js.map +1 -1
- package/dist/domain/workflow/workflow-scheduler.js +68 -33
- package/dist/domain/workflow/workflow-scheduler.js.map +1 -1
- package/dist/domain/workflow/workflow-state.d.ts +2 -1
- package/dist/domain/workflow/workflow-state.js +107 -3
- package/dist/domain/workflow/workflow-state.js.map +1 -1
- package/dist/domain/workflow.d.ts +2 -0
- package/dist/domain/workflow.js +1 -0
- package/dist/domain/workflow.js.map +1 -1
- package/dist/domain/workflow.types.d.ts +23 -3
- package/dist/domain/workflow.types.js.map +1 -1
- package/dist/index.d.ts +44 -5
- package/dist/index.js +19 -2
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/artifact-store.constants.d.ts +1 -0
- package/dist/infrastructure/artifact-store.constants.js +2 -0
- package/dist/infrastructure/artifact-store.constants.js.map +1 -0
- package/dist/infrastructure/artifact-store.d.ts +3 -0
- package/dist/infrastructure/artifact-store.js +100 -0
- package/dist/infrastructure/artifact-store.js.map +1 -0
- package/dist/infrastructure/artifact-store.types.d.ts +4 -0
- package/dist/infrastructure/artifact-store.types.js +2 -0
- package/dist/infrastructure/artifact-store.types.js.map +1 -0
- package/dist/infrastructure/file-manifest.d.ts +6 -0
- package/dist/infrastructure/file-manifest.js +92 -0
- package/dist/infrastructure/file-manifest.js.map +1 -0
- package/dist/infrastructure/git/lock-inspection.constants.d.ts +4 -0
- package/dist/infrastructure/git/lock-inspection.constants.js +5 -0
- package/dist/infrastructure/git/lock-inspection.constants.js.map +1 -0
- package/dist/infrastructure/git/lock-inspection.d.ts +3 -0
- package/dist/infrastructure/git/lock-inspection.js +64 -0
- package/dist/infrastructure/git/lock-inspection.js.map +1 -0
- package/dist/infrastructure/git/lock-inspection.types.d.ts +27 -0
- package/dist/infrastructure/git/lock-inspection.types.js +2 -0
- package/dist/infrastructure/git/lock-inspection.types.js.map +1 -0
- package/dist/infrastructure/git/lock.d.ts +1 -0
- package/dist/infrastructure/git/lock.js +70 -29
- package/dist/infrastructure/git/lock.js.map +1 -1
- package/dist/infrastructure/git/process-identity.d.ts +3 -0
- package/dist/infrastructure/git/process-identity.js +73 -0
- package/dist/infrastructure/git/process-identity.js.map +1 -0
- package/dist/infrastructure/git/process-identity.types.d.ts +10 -0
- package/dist/infrastructure/git/process-identity.types.js +2 -0
- package/dist/infrastructure/git/process-identity.types.js.map +1 -0
- package/dist/infrastructure/git/verification-command.d.ts +1 -0
- package/dist/infrastructure/git/verification-command.js +37 -0
- package/dist/infrastructure/git/verification-command.js.map +1 -0
- package/dist/infrastructure/git/workspace-lease.js +1 -0
- package/dist/infrastructure/git/workspace-lease.js.map +1 -1
- package/dist/infrastructure/git/workspace.js +5 -1
- package/dist/infrastructure/git/workspace.js.map +1 -1
- package/dist/infrastructure/git/worktree-inspection.constants.d.ts +5 -0
- package/dist/infrastructure/git/worktree-inspection.constants.js +16 -0
- package/dist/infrastructure/git/worktree-inspection.constants.js.map +1 -0
- package/dist/infrastructure/git/worktree-inspection.d.ts +3 -0
- package/dist/infrastructure/git/worktree-inspection.js +120 -0
- package/dist/infrastructure/git/worktree-inspection.js.map +1 -0
- package/dist/infrastructure/git/worktree-inspection.types.d.ts +19 -0
- package/dist/infrastructure/git/worktree-inspection.types.js +2 -0
- package/dist/infrastructure/git/worktree-inspection.types.js.map +1 -0
- package/dist/infrastructure/inspection-file.constants.d.ts +1 -0
- package/dist/infrastructure/inspection-file.constants.js +5 -0
- package/dist/infrastructure/inspection-file.constants.js.map +1 -0
- package/dist/infrastructure/inspection-file.d.ts +1 -0
- package/dist/infrastructure/inspection-file.js +43 -0
- package/dist/infrastructure/inspection-file.js.map +1 -0
- package/dist/infrastructure/inspection-hash.constants.d.ts +1 -0
- package/dist/infrastructure/inspection-hash.constants.js +2 -0
- package/dist/infrastructure/inspection-hash.constants.js.map +1 -0
- package/dist/infrastructure/inspection-hash.d.ts +2 -0
- package/dist/infrastructure/inspection-hash.js +62 -0
- package/dist/infrastructure/inspection-hash.js.map +1 -0
- package/dist/infrastructure/inspection-hash.types.d.ts +5 -0
- package/dist/infrastructure/inspection-hash.types.js +2 -0
- package/dist/infrastructure/inspection-hash.types.js.map +1 -0
- package/dist/infrastructure/journal-retention.constants.d.ts +4 -0
- package/dist/infrastructure/journal-retention.constants.js +5 -0
- package/dist/infrastructure/journal-retention.constants.js.map +1 -0
- package/dist/infrastructure/journal-retention.d.ts +2 -0
- package/dist/infrastructure/journal-retention.js +51 -0
- package/dist/infrastructure/journal-retention.js.map +1 -0
- package/dist/infrastructure/journal.js +37 -13
- package/dist/infrastructure/journal.js.map +1 -1
- package/dist/infrastructure/opentelemetry.constants.d.ts +10 -0
- package/dist/infrastructure/opentelemetry.constants.js +11 -0
- package/dist/infrastructure/opentelemetry.constants.js.map +1 -0
- package/dist/infrastructure/opentelemetry.d.ts +3 -0
- package/dist/infrastructure/opentelemetry.js +131 -0
- package/dist/infrastructure/opentelemetry.js.map +1 -0
- package/dist/infrastructure/opentelemetry.types.d.ts +21 -0
- package/dist/infrastructure/opentelemetry.types.js +2 -0
- package/dist/infrastructure/opentelemetry.types.js.map +1 -0
- package/dist/infrastructure/resource-activity-inspection.d.ts +2 -0
- package/dist/infrastructure/resource-activity-inspection.js +152 -0
- package/dist/infrastructure/resource-activity-inspection.js.map +1 -0
- package/dist/infrastructure/resource-activity.constants.d.ts +8 -0
- package/dist/infrastructure/resource-activity.constants.js +26 -0
- package/dist/infrastructure/resource-activity.constants.js.map +1 -0
- package/dist/infrastructure/resource-activity.d.ts +2 -0
- package/dist/infrastructure/resource-activity.js +166 -0
- package/dist/infrastructure/resource-activity.js.map +1 -0
- package/dist/infrastructure/resource-activity.types.d.ts +53 -0
- package/dist/infrastructure/resource-activity.types.js +2 -0
- package/dist/infrastructure/resource-activity.types.js.map +1 -0
- package/dist/infrastructure/storage-inventory.constants.d.ts +6 -0
- package/dist/infrastructure/storage-inventory.constants.js +11 -0
- package/dist/infrastructure/storage-inventory.constants.js.map +1 -0
- package/dist/infrastructure/storage-inventory.d.ts +2 -0
- package/dist/infrastructure/storage-inventory.js +123 -0
- package/dist/infrastructure/storage-inventory.js.map +1 -0
- package/dist/infrastructure/storage-inventory.types.d.ts +38 -0
- package/dist/infrastructure/storage-inventory.types.js +2 -0
- package/dist/infrastructure/storage-inventory.types.js.map +1 -0
- package/dist/infrastructure/storage-mutation-lock.constants.d.ts +5 -0
- package/dist/infrastructure/storage-mutation-lock.constants.js +6 -0
- package/dist/infrastructure/storage-mutation-lock.constants.js.map +1 -0
- package/dist/infrastructure/storage-mutation-lock.d.ts +1 -0
- package/dist/infrastructure/storage-mutation-lock.js +21 -0
- package/dist/infrastructure/storage-mutation-lock.js.map +1 -0
- package/dist/infrastructure/storage-reservations.constants.d.ts +4 -0
- package/dist/infrastructure/storage-reservations.constants.js +5 -0
- package/dist/infrastructure/storage-reservations.constants.js.map +1 -0
- package/dist/infrastructure/storage-reservations.d.ts +2 -0
- package/dist/infrastructure/storage-reservations.js +150 -0
- package/dist/infrastructure/storage-reservations.js.map +1 -0
- package/dist/infrastructure/storage-reservations.types.d.ts +21 -0
- package/dist/infrastructure/storage-reservations.types.js +2 -0
- package/dist/infrastructure/storage-reservations.types.js.map +1 -0
- package/dist/infrastructure/task-queue-http.constants.d.ts +2 -0
- package/dist/infrastructure/task-queue-http.constants.js +3 -0
- package/dist/infrastructure/task-queue-http.constants.js.map +1 -0
- package/dist/infrastructure/task-queue-http.d.ts +4 -0
- package/dist/infrastructure/task-queue-http.js +158 -0
- package/dist/infrastructure/task-queue-http.js.map +1 -0
- package/dist/infrastructure/task-queue-http.types.d.ts +16 -0
- package/dist/infrastructure/task-queue-http.types.js +2 -0
- package/dist/infrastructure/task-queue-http.types.js.map +1 -0
- package/dist/infrastructure/task-queue.d.ts +2 -0
- package/dist/infrastructure/task-queue.js +134 -0
- package/dist/infrastructure/task-queue.js.map +1 -0
- package/dist/infrastructure/transfer.js +17 -0
- package/dist/infrastructure/transfer.js.map +1 -1
- package/dist/infrastructure/workflow-checkpoint.constants.d.ts +1 -0
- package/dist/infrastructure/workflow-checkpoint.constants.js +2 -0
- package/dist/infrastructure/workflow-checkpoint.constants.js.map +1 -0
- package/dist/infrastructure/workflow-checkpoint.d.ts +3 -0
- package/dist/infrastructure/workflow-checkpoint.js +77 -0
- package/dist/infrastructure/workflow-checkpoint.js.map +1 -0
- package/dist/infrastructure/workflow-checkpoint.types.d.ts +4 -0
- package/dist/infrastructure/workflow-checkpoint.types.js +2 -0
- package/dist/infrastructure/workflow-checkpoint.types.js.map +1 -0
- package/dist/providers/agents.d.ts +2 -0
- package/dist/providers/agents.js +1 -0
- package/dist/providers/agents.js.map +1 -1
- package/dist/providers/cloud.constants.d.ts +1 -0
- package/dist/providers/cloud.constants.js +1 -0
- package/dist/providers/cloud.constants.js.map +1 -1
- package/dist/providers/container-cache.constants.d.ts +11 -0
- package/dist/providers/container-cache.constants.js +9 -0
- package/dist/providers/container-cache.constants.js.map +1 -0
- package/dist/providers/container-cache.d.ts +4 -0
- package/dist/providers/container-cache.js +48 -0
- package/dist/providers/container-cache.js.map +1 -0
- package/dist/providers/container-cache.types.d.ts +8 -0
- package/dist/providers/container-cache.types.js +2 -0
- package/dist/providers/container-cache.types.js.map +1 -0
- package/dist/providers/container-isolation.d.ts +2 -0
- package/dist/providers/container-isolation.js +29 -0
- package/dist/providers/container-isolation.js.map +1 -0
- package/dist/providers/container-mounts.js +7 -2
- package/dist/providers/container-mounts.js.map +1 -1
- package/dist/providers/container-network.d.ts +2 -0
- package/dist/providers/container-network.js +14 -0
- package/dist/providers/container-network.js.map +1 -0
- package/dist/providers/container-plan.js +6 -2
- package/dist/providers/container-plan.js.map +1 -1
- package/dist/providers/container.constants.d.ts +1 -0
- package/dist/providers/container.constants.js +1 -0
- package/dist/providers/container.constants.js.map +1 -1
- package/dist/providers/container.js +50 -3
- package/dist/providers/container.js.map +1 -1
- package/dist/providers/container.types.d.ts +5 -0
- package/dist/providers/container.types.js.map +1 -1
- package/dist/providers/daytona-command.js +10 -6
- package/dist/providers/daytona-command.js.map +1 -1
- package/dist/providers/daytona-terminal.d.ts +3 -0
- package/dist/providers/daytona-terminal.js +128 -0
- package/dist/providers/daytona-terminal.js.map +1 -0
- package/dist/providers/daytona.js +15 -4
- package/dist/providers/daytona.js.map +1 -1
- package/dist/providers/diagnostic-container.d.ts +4 -0
- package/dist/providers/diagnostic-container.js +15 -0
- package/dist/providers/diagnostic-container.js.map +1 -0
- package/dist/providers/docker.d.ts +2 -0
- package/dist/providers/docker.js.map +1 -1
- package/dist/providers/file-batches.constants.d.ts +10 -0
- package/dist/providers/file-batches.constants.js +57 -0
- package/dist/providers/file-batches.constants.js.map +1 -0
- package/dist/providers/file-batches.d.ts +2 -0
- package/dist/providers/file-batches.js +160 -0
- package/dist/providers/file-batches.js.map +1 -0
- package/dist/providers/file-upload.constants.d.ts +1 -0
- package/dist/providers/file-upload.constants.js +68 -0
- package/dist/providers/file-upload.constants.js.map +1 -0
- package/dist/providers/file-upload.d.ts +2 -0
- package/dist/providers/file-upload.js +146 -0
- package/dist/providers/file-upload.js.map +1 -0
- package/dist/providers/firecracker-command.d.ts +5 -0
- package/dist/providers/firecracker-command.js +114 -0
- package/dist/providers/firecracker-command.js.map +1 -0
- package/dist/providers/firecracker-files.constants.d.ts +1 -0
- package/dist/providers/firecracker-files.constants.js +21 -0
- package/dist/providers/firecracker-files.constants.js.map +1 -0
- package/dist/providers/firecracker-files.d.ts +3 -0
- package/dist/providers/firecracker-files.js +110 -0
- package/dist/providers/firecracker-files.js.map +1 -0
- package/dist/providers/firecracker-machine.d.ts +3 -0
- package/dist/providers/firecracker-machine.js +155 -0
- package/dist/providers/firecracker-machine.js.map +1 -0
- package/dist/providers/firecracker.constants.d.ts +10 -0
- package/dist/providers/firecracker.constants.js +11 -0
- package/dist/providers/firecracker.constants.js.map +1 -0
- package/dist/providers/firecracker.d.ts +4 -0
- package/dist/providers/firecracker.js +103 -0
- package/dist/providers/firecracker.js.map +1 -0
- package/dist/providers/firecracker.types.d.ts +36 -0
- package/dist/providers/firecracker.types.js +2 -0
- package/dist/providers/firecracker.types.js.map +1 -0
- package/dist/providers/local.js +2 -1
- package/dist/providers/local.js.map +1 -1
- package/dist/providers/podman.d.ts +2 -0
- package/dist/providers/podman.js.map +1 -1
- package/dist/providers/terminal-bridge.d.ts +14 -0
- package/dist/providers/terminal-bridge.js +100 -0
- package/dist/providers/terminal-bridge.js.map +1 -0
- package/dist/providers/vercel-directory.d.ts +2 -0
- package/dist/providers/vercel-directory.js +7 -0
- package/dist/providers/vercel-directory.js.map +1 -0
- package/dist/providers/vercel-files.js +3 -2
- package/dist/providers/vercel-files.js.map +1 -1
- package/dist/providers/vercel-network.d.ts +2 -0
- package/dist/providers/vercel-network.js +18 -0
- package/dist/providers/vercel-network.js.map +1 -0
- package/dist/providers/vercel.d.ts +1 -0
- package/dist/providers/vercel.js +8 -2
- package/dist/providers/vercel.js.map +1 -1
- package/dist/providers/vercel.types.d.ts +2 -0
- package/dist/providers/vercel.types.js.map +1 -1
- package/dist/providers/versions.constants.d.ts +1 -0
- package/dist/providers/versions.constants.js +1 -0
- package/dist/providers/versions.constants.js.map +1 -1
- package/package.json +16 -1
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { lstat, rm } from "node:fs/promises";
|
|
2
|
+
import { OutpostError, invariant } from "../domain/errors.js";
|
|
3
|
+
import { git } from "../infrastructure/git/command.js";
|
|
4
|
+
import { lock, lockPath } from "../infrastructure/git/lock.js";
|
|
5
|
+
import { closedJournal } from "../infrastructure/journal-retention.js";
|
|
6
|
+
import { inspectRecovery } from "./recovery-inspection.js";
|
|
7
|
+
import { retentionPolicy } from "./recovery-retention-policy.js";
|
|
8
|
+
async function workspaceReason(entry, inspection) {
|
|
9
|
+
if (inspection.resources?.complete === false)
|
|
10
|
+
return "RESOURCE_ACTIVITY_UNKNOWN";
|
|
11
|
+
if (inspection.resources?.entries.some((resource) => resource.record?.workspace === entry.path))
|
|
12
|
+
return "RESOURCE_ACTIVITY_RECORDED";
|
|
13
|
+
const workspace = inspection.git?.workspaces.find((value) => value.path === entry.path);
|
|
14
|
+
if (!workspace || workspace.state !== "registered")
|
|
15
|
+
return "WORKSPACE_UNREGISTERED_OR_UNKNOWN";
|
|
16
|
+
if (workspace.branch === null)
|
|
17
|
+
return "DETACHED_WORKSPACE";
|
|
18
|
+
if (workspace.dirty)
|
|
19
|
+
return "DIRTY_WORKSPACE";
|
|
20
|
+
if (workspace.locked)
|
|
21
|
+
return "GIT_LOCKED_WORKSPACE";
|
|
22
|
+
try {
|
|
23
|
+
await lstat(lockPath(inspection.repository, workspace.branch));
|
|
24
|
+
return "OPERATION_LOCK_PRESENT";
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (!(error &&
|
|
28
|
+
typeof error === "object" &&
|
|
29
|
+
"code" in error &&
|
|
30
|
+
error.code === "ENOENT"))
|
|
31
|
+
return "OWNERSHIP_UNKNOWN";
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const ignored = await git(entry.path, [
|
|
35
|
+
"ls-files",
|
|
36
|
+
"--others",
|
|
37
|
+
"--ignored",
|
|
38
|
+
"--exclude-standard",
|
|
39
|
+
"-z",
|
|
40
|
+
]);
|
|
41
|
+
if (ignored.length)
|
|
42
|
+
return "IGNORED_FILES";
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return "WORKSPACE_STATE_UNKNOWN";
|
|
46
|
+
}
|
|
47
|
+
return "ELIGIBLE";
|
|
48
|
+
}
|
|
49
|
+
export async function planRecoveryRetention(options) {
|
|
50
|
+
retentionPolicy(options.policy);
|
|
51
|
+
const policy = structuredClone(options.policy);
|
|
52
|
+
const inspection = await inspectRecovery({
|
|
53
|
+
...options,
|
|
54
|
+
git: true,
|
|
55
|
+
locks: true,
|
|
56
|
+
resources: true,
|
|
57
|
+
});
|
|
58
|
+
const entries = [];
|
|
59
|
+
const inspectedAt = new Date().toISOString();
|
|
60
|
+
const complete = inspection.complete && inspection.git?.complete !== false;
|
|
61
|
+
for (const category of inspection.categories) {
|
|
62
|
+
for (const entry of category.entries) {
|
|
63
|
+
let reason = "RECOVERY_DATA_PROTECTED";
|
|
64
|
+
if (category.name === "locks")
|
|
65
|
+
reason = "OWNERSHIP_RECORD_PROTECTED";
|
|
66
|
+
if (category.name === "logs")
|
|
67
|
+
reason = "LOG_ACTIVITY_OR_CONTENT_UNKNOWN";
|
|
68
|
+
if (category.name === "workspaces")
|
|
69
|
+
reason = "SCOPE_NOT_SELECTED";
|
|
70
|
+
if (category.name === "workspaces" &&
|
|
71
|
+
policy.scopes.includes("clean-workspaces"))
|
|
72
|
+
reason = await workspaceReason(entry, inspection);
|
|
73
|
+
if (category.name === "logs" &&
|
|
74
|
+
policy.scopes.includes("closed-logs") &&
|
|
75
|
+
entry.kind === "file" &&
|
|
76
|
+
entry.name.endsWith(".jsonl") &&
|
|
77
|
+
(await closedJournal(entry.path)))
|
|
78
|
+
reason = "ELIGIBLE";
|
|
79
|
+
if (category.name === "logs" && entry.name.endsWith(".closed.json"))
|
|
80
|
+
reason = "CLOSURE_RECORD_PROTECTED";
|
|
81
|
+
if (reason === "ELIGIBLE" &&
|
|
82
|
+
(!entry.modifiedAt ||
|
|
83
|
+
Date.parse(inspectedAt) - Date.parse(entry.modifiedAt) <
|
|
84
|
+
policy.minAgeMs))
|
|
85
|
+
reason = "RETENTION_AGE";
|
|
86
|
+
if (reason === "ELIGIBLE" && (!complete || !entry.complete))
|
|
87
|
+
reason = "INCOMPLETE_INVENTORY";
|
|
88
|
+
const workspace = inspection.git?.workspaces.find((value) => value.path === entry.path);
|
|
89
|
+
entries.push({
|
|
90
|
+
path: entry.path,
|
|
91
|
+
category: category.name,
|
|
92
|
+
bytes: entry.bytes,
|
|
93
|
+
eligible: reason === "ELIGIBLE",
|
|
94
|
+
reason,
|
|
95
|
+
...(entry.modifiedAt ? { modifiedAt: entry.modifiedAt } : {}),
|
|
96
|
+
...(workspace?.state === "registered" && workspace.branch
|
|
97
|
+
? { branch: workspace.branch, head: workspace.head }
|
|
98
|
+
: {}),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const projectedBytes = inspection.usage.bytes -
|
|
103
|
+
entries
|
|
104
|
+
.filter((entry) => entry.eligible)
|
|
105
|
+
.reduce((sum, entry) => sum +
|
|
106
|
+
entry.bytes +
|
|
107
|
+
(entry.category === "logs"
|
|
108
|
+
? (entries.find((other) => other.path === `${entry.path}.closed.json`)?.bytes ?? 0)
|
|
109
|
+
: 0), 0);
|
|
110
|
+
const workspaces = entries.filter((entry) => entry.category === "workspaces" && !entry.eligible).length;
|
|
111
|
+
const exceeded = (policy.maxBytes !== undefined && projectedBytes > policy.maxBytes) ||
|
|
112
|
+
(policy.maxWorkspaces !== undefined && workspaces > policy.maxWorkspaces);
|
|
113
|
+
return {
|
|
114
|
+
repository: inspection.repository,
|
|
115
|
+
policy,
|
|
116
|
+
inspectedAt,
|
|
117
|
+
inspection,
|
|
118
|
+
entries,
|
|
119
|
+
complete,
|
|
120
|
+
usageBytes: inspection.usage.bytes,
|
|
121
|
+
projectedBytes,
|
|
122
|
+
quota: !complete ? "unknown" : exceeded ? "exceeded" : "within",
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
export async function pruneRecoveryRetention(plan) {
|
|
126
|
+
retentionPolicy(plan.policy);
|
|
127
|
+
invariant(plan.complete, "Cannot prune an incomplete retention plan");
|
|
128
|
+
const removed = [];
|
|
129
|
+
const retained = [];
|
|
130
|
+
for (const candidate of plan.entries.filter((entry) => entry.eligible)) {
|
|
131
|
+
const fresh = await planRecoveryRetention({
|
|
132
|
+
repository: plan.repository,
|
|
133
|
+
policy: plan.policy,
|
|
134
|
+
});
|
|
135
|
+
const entry = fresh.entries.find((value) => value.path === candidate.path);
|
|
136
|
+
if (!entry?.eligible ||
|
|
137
|
+
entry.head !== candidate.head ||
|
|
138
|
+
entry.branch !== candidate.branch ||
|
|
139
|
+
entry.bytes !== candidate.bytes ||
|
|
140
|
+
entry.modifiedAt !== candidate.modifiedAt) {
|
|
141
|
+
retained.push({ path: candidate.path, reason: "PLAN_CHANGED" });
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
if (entry.category === "workspaces" && entry.branch) {
|
|
146
|
+
const release = await lock(plan.repository, entry.branch);
|
|
147
|
+
try {
|
|
148
|
+
const status = await git(entry.path, [
|
|
149
|
+
"status",
|
|
150
|
+
"--porcelain=v1",
|
|
151
|
+
"--ignored",
|
|
152
|
+
"--untracked-files=all",
|
|
153
|
+
]);
|
|
154
|
+
invariant(!status.length, "Workspace changed before pruning");
|
|
155
|
+
invariant((await git(entry.path, ["rev-parse", "HEAD"])).trim() ===
|
|
156
|
+
entry.head, "Workspace HEAD changed before pruning");
|
|
157
|
+
invariant((await git(entry.path, ["symbolic-ref", "--short", "HEAD"])).trim() === entry.branch, "Workspace branch changed before pruning");
|
|
158
|
+
await git(plan.repository, ["worktree", "remove", entry.path]);
|
|
159
|
+
}
|
|
160
|
+
finally {
|
|
161
|
+
await release();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
const release = await lock(plan.repository, `journal:${entry.path}`);
|
|
166
|
+
try {
|
|
167
|
+
invariant(entry.category === "logs" && (await closedJournal(entry.path)), "Journal changed before pruning");
|
|
168
|
+
await rm(entry.path);
|
|
169
|
+
await rm(`${entry.path}.closed.json`);
|
|
170
|
+
}
|
|
171
|
+
finally {
|
|
172
|
+
await release();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
removed.push(entry.path);
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
retained.push({
|
|
179
|
+
path: candidate.path,
|
|
180
|
+
reason: "REVALIDATION_OR_REMOVAL_FAILED",
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
removed,
|
|
186
|
+
retained,
|
|
187
|
+
after: await planRecoveryRetention({
|
|
188
|
+
repository: plan.repository,
|
|
189
|
+
policy: plan.policy,
|
|
190
|
+
}),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
export async function assertRecoveryQuota(options) {
|
|
194
|
+
invariant(Number.isSafeInteger(options.maxBytes) && options.maxBytes >= 0, "maxBytes must be a nonnegative integer");
|
|
195
|
+
const reserve = options.reserveBytes ?? 0;
|
|
196
|
+
invariant(Number.isSafeInteger(reserve) && reserve >= 0, "reserveBytes must be a nonnegative integer");
|
|
197
|
+
const inspection = await inspectRecovery(options);
|
|
198
|
+
if (!inspection.complete ||
|
|
199
|
+
inspection.usage.bytes + reserve > options.maxBytes)
|
|
200
|
+
throw new OutpostError("workspace", "Outpost storage quota admission refused", {
|
|
201
|
+
usageBytes: inspection.usage.bytes,
|
|
202
|
+
reserveBytes: reserve,
|
|
203
|
+
maxBytes: options.maxBytes,
|
|
204
|
+
complete: inspection.complete,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=recovery-retention.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recovery-retention.js","sourceRoot":"","sources":["../../src/application/recovery-retention.ts"],"names":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AAwC,CACzC,CAAC;IACF,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,IAAI,CAAC,CAAC;IAC1C,SAAS,CACP,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,OAAO,IAAI,CAAC,EAC7C,4CAA4C,CAC7C,CAAC;IACF,MAAM,UAAU,GAAG,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC;IAClD,IACE,CAAC,UAAU,CAAC,QAAQ;QACpB,UAAU,CAAC,KAAK,CAAC,KAAK,GAAG,OAAO,GAAG,OAAO,CAAC,QAAQ;QAEnD,MAAM,IAAI,YAAY,CACpB,WAAW,EACX,yCAAyC,EACzC;YACE,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK;YAClC,YAAY,EAAE,OAAO;YACrB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,QAAQ,EAAE,UAAU,CAAC,QAAQ;SAC9B,CACF,CAAC;AACN,CAAC","sourcesContent":["import { lstat, rm } from \"node:fs/promises\";\nimport { OutpostError, invariant } from \"../domain/errors.ts\";\nimport { git } from \"../infrastructure/git/command.ts\";\nimport { lock, lockPath } from \"../infrastructure/git/lock.ts\";\nimport { closedJournal } from \"../infrastructure/journal-retention.ts\";\nimport type { StorageEntry } from \"../infrastructure/storage-inventory.types.ts\";\nimport type { RecoveryInspection } from \"./recovery-inspection.types.ts\";\nimport { inspectRecovery } from \"./recovery-inspection.ts\";\nimport { retentionPolicy } from \"./recovery-retention-policy.ts\";\nimport type {\n RecoveryPruneResult,\n RecoveryRetainedEntry,\n RecoveryQuotaOptions,\n RecoveryRetentionEntry,\n RecoveryRetentionOptions,\n RecoveryRetentionPlan,\n} from \"./recovery-retention.types.ts\";\n\nasync function workspaceReason(\n entry: StorageEntry,\n inspection: RecoveryInspection,\n): Promise<string> {\n if (inspection.resources?.complete === false)\n return \"RESOURCE_ACTIVITY_UNKNOWN\";\n if (\n inspection.resources?.entries.some(\n (resource) => resource.record?.workspace === entry.path,\n )\n )\n return \"RESOURCE_ACTIVITY_RECORDED\";\n const workspace = inspection.git?.workspaces.find(\n (value) => value.path === entry.path,\n );\n if (!workspace || workspace.state !== \"registered\")\n return \"WORKSPACE_UNREGISTERED_OR_UNKNOWN\";\n if (workspace.branch === null) return \"DETACHED_WORKSPACE\";\n if (workspace.dirty) return \"DIRTY_WORKSPACE\";\n if (workspace.locked) return \"GIT_LOCKED_WORKSPACE\";\n try {\n await lstat(lockPath(inspection.repository, workspace.branch));\n return \"OPERATION_LOCK_PRESENT\";\n } catch (error) {\n if (!(\n error &&\n typeof error === \"object\" &&\n \"code\" in error &&\n error.code === \"ENOENT\"\n ))\n return \"OWNERSHIP_UNKNOWN\";\n }\n try {\n const ignored = await git(entry.path, [\n \"ls-files\",\n \"--others\",\n \"--ignored\",\n \"--exclude-standard\",\n \"-z\",\n ]);\n if (ignored.length) return \"IGNORED_FILES\";\n } catch {\n return \"WORKSPACE_STATE_UNKNOWN\";\n }\n return \"ELIGIBLE\";\n}\n\nexport async function planRecoveryRetention(\n options: RecoveryRetentionOptions,\n): Promise<RecoveryRetentionPlan> {\n retentionPolicy(options.policy);\n const policy = structuredClone(options.policy);\n const inspection = await inspectRecovery({\n ...options,\n git: true,\n locks: true,\n resources: true,\n });\n const entries: RecoveryRetentionEntry[] = [];\n const inspectedAt = new Date().toISOString();\n const complete = inspection.complete && inspection.git?.complete !== false;\n for (const category of inspection.categories) {\n for (const entry of category.entries) {\n let reason = \"RECOVERY_DATA_PROTECTED\";\n if (category.name === \"locks\") reason = \"OWNERSHIP_RECORD_PROTECTED\";\n if (category.name === \"logs\") reason = \"LOG_ACTIVITY_OR_CONTENT_UNKNOWN\";\n if (category.name === \"workspaces\") reason = \"SCOPE_NOT_SELECTED\";\n if (\n category.name === \"workspaces\" &&\n policy.scopes.includes(\"clean-workspaces\")\n )\n reason = await workspaceReason(entry, inspection);\n if (\n category.name === \"logs\" &&\n policy.scopes.includes(\"closed-logs\") &&\n entry.kind === \"file\" &&\n entry.name.endsWith(\".jsonl\") &&\n (await closedJournal(entry.path))\n )\n reason = \"ELIGIBLE\";\n if (category.name === \"logs\" && entry.name.endsWith(\".closed.json\"))\n reason = \"CLOSURE_RECORD_PROTECTED\";\n if (\n reason === \"ELIGIBLE\" &&\n (!entry.modifiedAt ||\n Date.parse(inspectedAt) - Date.parse(entry.modifiedAt) <\n policy.minAgeMs)\n )\n reason = \"RETENTION_AGE\";\n if (reason === \"ELIGIBLE\" && (!complete || !entry.complete))\n reason = \"INCOMPLETE_INVENTORY\";\n const workspace = inspection.git?.workspaces.find(\n (value) => value.path === entry.path,\n );\n entries.push({\n path: entry.path,\n category: category.name,\n bytes: entry.bytes,\n eligible: reason === \"ELIGIBLE\",\n reason,\n ...(entry.modifiedAt ? { modifiedAt: entry.modifiedAt } : {}),\n ...(workspace?.state === \"registered\" && workspace.branch\n ? { branch: workspace.branch, head: workspace.head }\n : {}),\n });\n }\n }\n const projectedBytes =\n inspection.usage.bytes -\n entries\n .filter((entry) => entry.eligible)\n .reduce(\n (sum, entry) =>\n sum +\n entry.bytes +\n (entry.category === \"logs\"\n ? (entries.find(\n (other) => other.path === `${entry.path}.closed.json`,\n )?.bytes ?? 0)\n : 0),\n 0,\n );\n const workspaces = entries.filter(\n (entry) => entry.category === \"workspaces\" && !entry.eligible,\n ).length;\n const exceeded =\n (policy.maxBytes !== undefined && projectedBytes > policy.maxBytes) ||\n (policy.maxWorkspaces !== undefined && workspaces > policy.maxWorkspaces);\n return {\n repository: inspection.repository,\n policy,\n inspectedAt,\n inspection,\n entries,\n complete,\n usageBytes: inspection.usage.bytes,\n projectedBytes,\n quota: !complete ? \"unknown\" : exceeded ? \"exceeded\" : \"within\",\n };\n}\n\nexport async function pruneRecoveryRetention(\n plan: RecoveryRetentionPlan,\n): Promise<RecoveryPruneResult> {\n retentionPolicy(plan.policy);\n invariant(plan.complete, \"Cannot prune an incomplete retention plan\");\n const removed: string[] = [];\n const retained: RecoveryRetainedEntry[] = [];\n for (const candidate of plan.entries.filter((entry) => entry.eligible)) {\n const fresh = await planRecoveryRetention({\n repository: plan.repository,\n policy: plan.policy,\n });\n const entry = fresh.entries.find((value) => value.path === candidate.path);\n if (\n !entry?.eligible ||\n entry.head !== candidate.head ||\n entry.branch !== candidate.branch ||\n entry.bytes !== candidate.bytes ||\n entry.modifiedAt !== candidate.modifiedAt\n ) {\n retained.push({ path: candidate.path, reason: \"PLAN_CHANGED\" });\n continue;\n }\n try {\n if (entry.category === \"workspaces\" && entry.branch) {\n const release = await lock(plan.repository, entry.branch);\n try {\n const status = await git(entry.path, [\n \"status\",\n \"--porcelain=v1\",\n \"--ignored\",\n \"--untracked-files=all\",\n ]);\n invariant(!status.length, \"Workspace changed before pruning\");\n invariant(\n (await git(entry.path, [\"rev-parse\", \"HEAD\"])).trim() ===\n entry.head,\n \"Workspace HEAD changed before pruning\",\n );\n invariant(\n (\n await git(entry.path, [\"symbolic-ref\", \"--short\", \"HEAD\"])\n ).trim() === entry.branch,\n \"Workspace branch changed before pruning\",\n );\n await git(plan.repository, [\"worktree\", \"remove\", entry.path]);\n } finally {\n await release();\n }\n } else {\n const release = await lock(plan.repository, `journal:${entry.path}`);\n try {\n invariant(\n entry.category === \"logs\" && (await closedJournal(entry.path)),\n \"Journal changed before pruning\",\n );\n await rm(entry.path);\n await rm(`${entry.path}.closed.json`);\n } finally {\n await release();\n }\n }\n removed.push(entry.path);\n } catch {\n retained.push({\n path: candidate.path,\n reason: \"REVALIDATION_OR_REMOVAL_FAILED\",\n });\n }\n }\n return {\n removed,\n retained,\n after: await planRecoveryRetention({\n repository: plan.repository,\n policy: plan.policy,\n }),\n };\n}\n\nexport async function assertRecoveryQuota(\n options: RecoveryQuotaOptions,\n): Promise<void> {\n invariant(\n Number.isSafeInteger(options.maxBytes) && options.maxBytes >= 0,\n \"maxBytes must be a nonnegative integer\",\n );\n const reserve = options.reserveBytes ?? 0;\n invariant(\n Number.isSafeInteger(reserve) && reserve >= 0,\n \"reserveBytes must be a nonnegative integer\",\n );\n const inspection = await inspectRecovery(options);\n if (\n !inspection.complete ||\n inspection.usage.bytes + reserve > options.maxBytes\n )\n throw new OutpostError(\n \"workspace\",\n \"Outpost storage quota admission refused\",\n {\n usageBytes: inspection.usage.bytes,\n reserveBytes: reserve,\n maxBytes: options.maxBytes,\n complete: inspection.complete,\n },\n );\n}\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { RecoveryInspection } from "./recovery-inspection.types.ts";
|
|
2
|
+
export interface RecoveryRetentionPolicy {
|
|
3
|
+
readonly version: 1;
|
|
4
|
+
readonly scopes: readonly ("clean-workspaces" | "closed-logs")[];
|
|
5
|
+
readonly minAgeMs: number;
|
|
6
|
+
readonly maxBytes?: number;
|
|
7
|
+
readonly maxWorkspaces?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface RecoveryRetentionOptions {
|
|
10
|
+
readonly repository?: string;
|
|
11
|
+
readonly policy: RecoveryRetentionPolicy;
|
|
12
|
+
readonly maxEntries?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface RecoveryRetentionEntry {
|
|
15
|
+
readonly path: string;
|
|
16
|
+
readonly category: string;
|
|
17
|
+
readonly bytes: number;
|
|
18
|
+
readonly eligible: boolean;
|
|
19
|
+
readonly reason: string;
|
|
20
|
+
readonly branch?: string;
|
|
21
|
+
readonly head?: string;
|
|
22
|
+
readonly modifiedAt?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface RecoveryRetentionPlan {
|
|
25
|
+
readonly repository: string;
|
|
26
|
+
readonly policy: RecoveryRetentionPolicy;
|
|
27
|
+
readonly inspectedAt: string;
|
|
28
|
+
readonly inspection: RecoveryInspection;
|
|
29
|
+
readonly entries: readonly RecoveryRetentionEntry[];
|
|
30
|
+
readonly complete: boolean;
|
|
31
|
+
readonly usageBytes: number;
|
|
32
|
+
readonly projectedBytes: number;
|
|
33
|
+
readonly quota: "within" | "exceeded" | "unknown";
|
|
34
|
+
}
|
|
35
|
+
export interface RecoveryRetainedEntry {
|
|
36
|
+
readonly path: string;
|
|
37
|
+
readonly reason: string;
|
|
38
|
+
}
|
|
39
|
+
export interface RecoveryPruneResult {
|
|
40
|
+
readonly removed: readonly string[];
|
|
41
|
+
readonly retained: readonly {
|
|
42
|
+
readonly path: string;
|
|
43
|
+
readonly reason: string;
|
|
44
|
+
}[];
|
|
45
|
+
readonly after: RecoveryRetentionPlan;
|
|
46
|
+
}
|
|
47
|
+
export interface RecoveryQuotaOptions {
|
|
48
|
+
readonly repository?: string;
|
|
49
|
+
readonly maxBytes: number;
|
|
50
|
+
readonly reserveBytes?: number;
|
|
51
|
+
readonly maxEntries?: number;
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recovery-retention.types.js","sourceRoot":"","sources":["../../src/application/recovery-retention.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { RecoveryInspection } from \"./recovery-inspection.types.ts\";\nexport interface RecoveryRetentionPolicy {\n readonly version: 1;\n readonly scopes: readonly (\"clean-workspaces\" | \"closed-logs\")[];\n readonly minAgeMs: number;\n readonly maxBytes?: number;\n readonly maxWorkspaces?: number;\n}\nexport interface RecoveryRetentionOptions {\n readonly repository?: string;\n readonly policy: RecoveryRetentionPolicy;\n readonly maxEntries?: number;\n}\nexport interface RecoveryRetentionEntry {\n readonly path: string;\n readonly category: string;\n readonly bytes: number;\n readonly eligible: boolean;\n readonly reason: string;\n readonly branch?: string;\n readonly head?: string;\n readonly modifiedAt?: string;\n}\nexport interface RecoveryRetentionPlan {\n readonly repository: string;\n readonly policy: RecoveryRetentionPolicy;\n readonly inspectedAt: string;\n readonly inspection: RecoveryInspection;\n readonly entries: readonly RecoveryRetentionEntry[];\n readonly complete: boolean;\n readonly usageBytes: number;\n readonly projectedBytes: number;\n readonly quota: \"within\" | \"exceeded\" | \"unknown\";\n}\nexport interface RecoveryRetainedEntry {\n readonly path: string;\n readonly reason: string;\n}\nexport interface RecoveryPruneResult {\n readonly removed: readonly string[];\n readonly retained: readonly {\n readonly path: string;\n readonly reason: string;\n }[];\n readonly after: RecoveryRetentionPlan;\n}\nexport interface RecoveryQuotaOptions {\n readonly repository?: string;\n readonly maxBytes: number;\n readonly reserveBytes?: number;\n readonly maxEntries?: number;\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const recoveryVerificationDefaults = {
|
|
2
|
+
maxStateBytes: 65_536,
|
|
3
|
+
maxPaths: 1000,
|
|
4
|
+
};
|
|
5
|
+
export const recoveryTransferPatches = [
|
|
6
|
+
"remote.patch",
|
|
7
|
+
"previous.patch",
|
|
8
|
+
"previous-index.patch",
|
|
9
|
+
];
|
|
10
|
+
//# sourceMappingURL=recovery-verification.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recovery-verification.constants.js","sourceRoot":"","sources":["../../src/application/recovery-verification.constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,4BAA4B,GAAG;IAC1C,aAAa,EAAE,MAAM;IACrB,QAAQ,EAAE,IAAI;CACN,CAAC;AAEX,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,cAAc;IACd,gBAAgB;IAChB,sBAAsB;CACd,CAAC","sourcesContent":["export const recoveryVerificationDefaults = {\n maxStateBytes: 65_536,\n maxPaths: 1000,\n} as const;\n\nexport const recoveryTransferPatches = [\n \"remote.patch\",\n \"previous.patch\",\n \"previous-index.patch\",\n] as const;\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { RecoveryTransferState, RecoveryVerification, RecoveryVerificationOptions } from "./recovery-verification.types.ts";
|
|
2
|
+
export declare function transferState(value: unknown): value is RecoveryTransferState;
|
|
3
|
+
export declare function verifyRecoveryTransfer(path: string, options?: RecoveryVerificationOptions): Promise<RecoveryVerification>;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { verifyRecoveryRestorability } from "./recovery-restorability.js";
|
|
2
|
+
import { verifyRecoveryChecksums } from "./recovery-checksums.js";
|
|
3
|
+
import { invariant, positive } from "../domain/errors.js";
|
|
4
|
+
import { lstat } from "node:fs/promises";
|
|
5
|
+
import { isAbsolute, join, win32 } from "node:path";
|
|
6
|
+
import { directory, safeDestination } from "../infrastructure/files.js";
|
|
7
|
+
import { readInspectionFile } from "../infrastructure/inspection-file.js";
|
|
8
|
+
import { recoveryTransferPatches, recoveryVerificationDefaults, } from "./recovery-verification.constants.js";
|
|
9
|
+
function paths(value) {
|
|
10
|
+
if (!Array.isArray(value) ||
|
|
11
|
+
value.length > recoveryVerificationDefaults.maxPaths)
|
|
12
|
+
return false;
|
|
13
|
+
return (value.every((path) => typeof path === "string" &&
|
|
14
|
+
path.length > 0 &&
|
|
15
|
+
!path.includes("\0") &&
|
|
16
|
+
!isAbsolute(path) &&
|
|
17
|
+
!win32.parse(path).root &&
|
|
18
|
+
!path
|
|
19
|
+
.split(/[\\/]/)
|
|
20
|
+
.some((part) => !part ||
|
|
21
|
+
part === "." ||
|
|
22
|
+
part === ".." ||
|
|
23
|
+
part.toLowerCase() === ".git")) && new Set(value).size === value.length);
|
|
24
|
+
}
|
|
25
|
+
export function transferState(value) {
|
|
26
|
+
if (!value || typeof value !== "object")
|
|
27
|
+
return false;
|
|
28
|
+
if (!("previous" in value) ||
|
|
29
|
+
!("next" in value) ||
|
|
30
|
+
!("previousExtras" in value) ||
|
|
31
|
+
!("incoming" in value))
|
|
32
|
+
return false;
|
|
33
|
+
return (typeof value.previous === "string" &&
|
|
34
|
+
/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(value.previous) &&
|
|
35
|
+
typeof value.next === "string" &&
|
|
36
|
+
/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(value.next) &&
|
|
37
|
+
value.next.length === value.previous.length &&
|
|
38
|
+
paths(value.previousExtras) &&
|
|
39
|
+
paths(value.incoming));
|
|
40
|
+
}
|
|
41
|
+
async function checkFile(root, name, allowSymlink = false) {
|
|
42
|
+
try {
|
|
43
|
+
const path = await safeDestination(root, name);
|
|
44
|
+
const info = await lstat(path);
|
|
45
|
+
if (allowSymlink && info.isSymbolicLink())
|
|
46
|
+
return { path, status: "pass", code: "SYMLINK_PRESENT" };
|
|
47
|
+
if (info.isFile())
|
|
48
|
+
return { path, status: "pass", code: "FILE_PRESENT" };
|
|
49
|
+
return { path, status: "fail", code: "UNEXPECTED_TYPE" };
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return { path: join(root, name), status: "fail", code: "FILE_UNAVAILABLE" };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export async function verifyRecoveryTransfer(path, options = {}) {
|
|
56
|
+
invariant(!options.restorability || !!options.repository, "Restorability verification requires a repository");
|
|
57
|
+
if (options.maxBytes !== undefined)
|
|
58
|
+
positive(options.maxBytes, "maxBytes");
|
|
59
|
+
const root = await directory(path);
|
|
60
|
+
const checks = [];
|
|
61
|
+
const report = () => ({
|
|
62
|
+
directory: root,
|
|
63
|
+
scope: options.restorability
|
|
64
|
+
? "transfer-restorability"
|
|
65
|
+
: "transfer-structure",
|
|
66
|
+
complete: checks.every((check) => check.status === "pass"),
|
|
67
|
+
integrity: "unverified",
|
|
68
|
+
checks,
|
|
69
|
+
});
|
|
70
|
+
const statePath = join(root, "state.json");
|
|
71
|
+
let state;
|
|
72
|
+
try {
|
|
73
|
+
state = JSON.parse((await readInspectionFile(statePath, recoveryVerificationDefaults.maxStateBytes)).toString("utf8"));
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
checks.push({ path: statePath, status: "fail", code: "STATE_UNAVAILABLE" });
|
|
77
|
+
return report();
|
|
78
|
+
}
|
|
79
|
+
if (!transferState(state)) {
|
|
80
|
+
checks.push({ path: statePath, status: "fail", code: "INVALID_STATE" });
|
|
81
|
+
return report();
|
|
82
|
+
}
|
|
83
|
+
checks.push({
|
|
84
|
+
path: statePath,
|
|
85
|
+
status: "pass",
|
|
86
|
+
code: "STATE_STRUCTURE_VALID",
|
|
87
|
+
});
|
|
88
|
+
for (const name of recoveryTransferPatches)
|
|
89
|
+
checks.push(await checkFile(root, name));
|
|
90
|
+
if (state.previous !== state.next)
|
|
91
|
+
checks.push(await checkFile(root, "commits.bundle"));
|
|
92
|
+
for (const name of state.previousExtras)
|
|
93
|
+
checks.push(await checkFile(root, `previous-files/${name}`, true));
|
|
94
|
+
for (const name of state.incoming)
|
|
95
|
+
checks.push(await checkFile(root, `incoming/${name}`, true));
|
|
96
|
+
if (options.restorability &&
|
|
97
|
+
options.repository &&
|
|
98
|
+
checks.every((check) => check.status === "pass"))
|
|
99
|
+
checks.push(...(await verifyRecoveryRestorability(root, state, options.repository)));
|
|
100
|
+
if (options.checksums && checks.every((check) => check.status === "pass")) {
|
|
101
|
+
const checksums = await verifyRecoveryChecksums(root, state, options.maxBytes);
|
|
102
|
+
checks.push(...checksums.checks);
|
|
103
|
+
return { ...report(), integrity: checksums.integrity, checksums };
|
|
104
|
+
}
|
|
105
|
+
return report();
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=recovery-verification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recovery-verification.js","sourceRoot":"","sources":["../../src/application/recovery-verification.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EACL,uBAAuB,EACvB,4BAA4B,GAC7B,MAAM,sCAAsC,CAAC;AAQ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AAC,SAAS,EAAE,SAAS,EAAE,CAAC;IACpE,CAAC;IACD,OAAO,MAAM,EAAE,CAAC;AAClB,CAAC","sourcesContent":["import { verifyRecoveryRestorability } from \"./recovery-restorability.ts\";\nimport { verifyRecoveryChecksums } from \"./recovery-checksums.ts\";\nimport { invariant, positive } from \"../domain/errors.ts\";\nimport { lstat } from \"node:fs/promises\";\nimport { isAbsolute, join, win32 } from \"node:path\";\nimport { directory, safeDestination } from \"../infrastructure/files.ts\";\nimport { readInspectionFile } from \"../infrastructure/inspection-file.ts\";\nimport {\n recoveryTransferPatches,\n recoveryVerificationDefaults,\n} from \"./recovery-verification.constants.ts\";\nimport type {\n RecoveryStructureCheck,\n RecoveryTransferState,\n RecoveryVerification,\n RecoveryVerificationOptions,\n} from \"./recovery-verification.types.ts\";\n\nfunction paths(value: unknown): value is readonly string[] {\n if (\n !Array.isArray(value) ||\n value.length > recoveryVerificationDefaults.maxPaths\n )\n return false;\n return (\n value.every(\n (path: unknown) =>\n typeof path === \"string\" &&\n path.length > 0 &&\n !path.includes(\"\\0\") &&\n !isAbsolute(path) &&\n !win32.parse(path).root &&\n !path\n .split(/[\\\\/]/)\n .some(\n (part) =>\n !part ||\n part === \".\" ||\n part === \"..\" ||\n part.toLowerCase() === \".git\",\n ),\n ) && new Set(value).size === value.length\n );\n}\n\nexport function transferState(value: unknown): value is RecoveryTransferState {\n if (!value || typeof value !== \"object\") return false;\n if (\n !(\"previous\" in value) ||\n !(\"next\" in value) ||\n !(\"previousExtras\" in value) ||\n !(\"incoming\" in value)\n )\n return false;\n return (\n typeof value.previous === \"string\" &&\n /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(value.previous) &&\n typeof value.next === \"string\" &&\n /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(value.next) &&\n value.next.length === value.previous.length &&\n paths(value.previousExtras) &&\n paths(value.incoming)\n );\n}\n\nasync function checkFile(\n root: string,\n name: string,\n allowSymlink = false,\n): Promise<RecoveryStructureCheck> {\n try {\n const path = await safeDestination(root, name);\n const info = await lstat(path);\n if (allowSymlink && info.isSymbolicLink())\n return { path, status: \"pass\", code: \"SYMLINK_PRESENT\" };\n if (info.isFile()) return { path, status: \"pass\", code: \"FILE_PRESENT\" };\n return { path, status: \"fail\", code: \"UNEXPECTED_TYPE\" };\n } catch {\n return { path: join(root, name), status: \"fail\", code: \"FILE_UNAVAILABLE\" };\n }\n}\n\nexport async function verifyRecoveryTransfer(\n path: string,\n options: RecoveryVerificationOptions = {},\n): Promise<RecoveryVerification> {\n invariant(\n !options.restorability || !!options.repository,\n \"Restorability verification requires a repository\",\n );\n if (options.maxBytes !== undefined) positive(options.maxBytes, \"maxBytes\");\n const root = await directory(path);\n const checks: RecoveryStructureCheck[] = [];\n const report = (): RecoveryVerification => ({\n directory: root,\n scope: options.restorability\n ? \"transfer-restorability\"\n : \"transfer-structure\",\n complete: checks.every((check) => check.status === \"pass\"),\n integrity: \"unverified\",\n checks,\n });\n const statePath = join(root, \"state.json\");\n let state: unknown;\n try {\n state = JSON.parse(\n (\n await readInspectionFile(\n statePath,\n recoveryVerificationDefaults.maxStateBytes,\n )\n ).toString(\"utf8\"),\n );\n } catch {\n checks.push({ path: statePath, status: \"fail\", code: \"STATE_UNAVAILABLE\" });\n return report();\n }\n if (!transferState(state)) {\n checks.push({ path: statePath, status: \"fail\", code: \"INVALID_STATE\" });\n return report();\n }\n checks.push({\n path: statePath,\n status: \"pass\",\n code: \"STATE_STRUCTURE_VALID\",\n });\n for (const name of recoveryTransferPatches)\n checks.push(await checkFile(root, name));\n if (state.previous !== state.next)\n checks.push(await checkFile(root, \"commits.bundle\"));\n for (const name of state.previousExtras)\n checks.push(await checkFile(root, `previous-files/${name}`, true));\n for (const name of state.incoming)\n checks.push(await checkFile(root, `incoming/${name}`, true));\n if (\n options.restorability &&\n options.repository &&\n checks.every((check) => check.status === \"pass\")\n )\n checks.push(\n ...(await verifyRecoveryRestorability(root, state, options.repository)),\n );\n if (options.checksums && checks.every((check) => check.status === \"pass\")) {\n const checksums = await verifyRecoveryChecksums(\n root,\n state,\n options.maxBytes,\n );\n checks.push(...checksums.checks);\n return { ...report(), integrity: checksums.integrity, checksums };\n }\n return report();\n}\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { RecoveryChecksumResult, RecoveryIntegrity } from "./recovery-checksums.types.ts";
|
|
2
|
+
export interface RecoveryTransferState {
|
|
3
|
+
readonly previous: string;
|
|
4
|
+
readonly next: string;
|
|
5
|
+
readonly previousExtras: readonly string[];
|
|
6
|
+
readonly incoming: readonly string[];
|
|
7
|
+
}
|
|
8
|
+
export interface RecoveryStructureCheck {
|
|
9
|
+
readonly path: string;
|
|
10
|
+
readonly status: "pass" | "fail";
|
|
11
|
+
readonly code: string;
|
|
12
|
+
}
|
|
13
|
+
export interface RecoveryVerification {
|
|
14
|
+
readonly directory: string;
|
|
15
|
+
readonly scope: "transfer-structure" | "transfer-restorability";
|
|
16
|
+
readonly complete: boolean;
|
|
17
|
+
readonly integrity: RecoveryIntegrity;
|
|
18
|
+
readonly checksums?: RecoveryChecksumResult;
|
|
19
|
+
readonly checks: readonly RecoveryStructureCheck[];
|
|
20
|
+
}
|
|
21
|
+
export interface RecoveryVerificationOptions {
|
|
22
|
+
readonly restorability?: boolean;
|
|
23
|
+
readonly repository?: string;
|
|
24
|
+
readonly checksums?: boolean;
|
|
25
|
+
readonly maxBytes?: number;
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recovery-verification.types.js","sourceRoot":"","sources":["../../src/application/recovery-verification.types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n RecoveryChecksumResult,\n RecoveryIntegrity,\n} from \"./recovery-checksums.types.ts\";\nexport interface RecoveryTransferState {\n readonly previous: string;\n readonly next: string;\n readonly previousExtras: readonly string[];\n readonly incoming: readonly string[];\n}\n\nexport interface RecoveryStructureCheck {\n readonly path: string;\n readonly status: \"pass\" | \"fail\";\n readonly code: string;\n}\n\nexport interface RecoveryVerification {\n readonly directory: string;\n readonly scope: \"transfer-structure\" | \"transfer-restorability\";\n readonly complete: boolean;\n readonly integrity: RecoveryIntegrity;\n readonly checksums?: RecoveryChecksumResult;\n readonly checks: readonly RecoveryStructureCheck[];\n}\n\nexport interface RecoveryVerificationOptions {\n readonly restorability?: boolean;\n readonly repository?: string;\n readonly checksums?: boolean;\n readonly maxBytes?: number;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { cp, mkdir, readFile, rm } from "node:fs/promises";
|
|
2
|
-
import { dirname, join } from "node:path";
|
|
1
|
+
import { cp, lstat, mkdir, readFile, rm, rmdir } from "node:fs/promises";
|
|
2
|
+
import { dirname, join, resolve } from "node:path";
|
|
3
3
|
import { OutpostError } from "../domain/errors.js";
|
|
4
4
|
import { safeDestination } from "../infrastructure/files.js";
|
|
5
5
|
import { git } from "../infrastructure/git/command.js";
|
|
@@ -10,6 +10,12 @@ export async function applyChanges(context, changes, backup, synchronized, expec
|
|
|
10
10
|
const { previousPatch, previousExtras } = backup;
|
|
11
11
|
if ((await digest(workspace.directory, recovery)) !== expected)
|
|
12
12
|
throw new OutpostError("conflict", "Host workspace changed during synchronization", { recovery });
|
|
13
|
+
if (head !== synchronized)
|
|
14
|
+
await git(workspace.directory, [
|
|
15
|
+
"fetch",
|
|
16
|
+
join(transfer, "commits.bundle"),
|
|
17
|
+
"HEAD",
|
|
18
|
+
]);
|
|
13
19
|
if ((await readFile(previousPatch)).length)
|
|
14
20
|
await git(workspace.directory, [
|
|
15
21
|
"apply",
|
|
@@ -18,10 +24,23 @@ export async function applyChanges(context, changes, backup, synchronized, expec
|
|
|
18
24
|
previousPatch,
|
|
19
25
|
]);
|
|
20
26
|
await git(workspace.directory, ["reset", "--mixed", "HEAD"]);
|
|
21
|
-
for (const file of previousExtras.filter((file) => !protectedFiles.includes(file)))
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
for (const file of previousExtras.filter((file) => !protectedFiles.includes(file))) {
|
|
28
|
+
const target = await safeDestination(workspace.directory, file);
|
|
29
|
+
await rm(target, { force: true });
|
|
30
|
+
let parent = dirname(target);
|
|
31
|
+
while (parent !== resolve(workspace.directory)) {
|
|
32
|
+
const removed = await rmdir(parent).then(() => true, (error) => {
|
|
33
|
+
if (error.code === "ENOTEMPTY" ||
|
|
34
|
+
error.code === "ENOENT" ||
|
|
35
|
+
error.code === "EEXIST")
|
|
36
|
+
return false;
|
|
37
|
+
throw error;
|
|
38
|
+
});
|
|
39
|
+
if (!removed)
|
|
40
|
+
break;
|
|
41
|
+
parent = dirname(parent);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
25
44
|
if (head !== synchronized)
|
|
26
45
|
await git(workspace.directory, ["merge", "--ff-only", "FETCH_HEAD"]);
|
|
27
46
|
if ((await readFile(patch)).length)
|
|
@@ -37,9 +56,14 @@ export async function applyChanges(context, changes, backup, synchronized, expec
|
|
|
37
56
|
]);
|
|
38
57
|
for (const file of incoming) {
|
|
39
58
|
const target = await safeDestination(workspace.directory, file);
|
|
59
|
+
if ((await lstat(target).catch(() => undefined))?.isDirectory())
|
|
60
|
+
await rmdir(target);
|
|
40
61
|
await mkdir(dirname(target), { recursive: true });
|
|
41
62
|
await cp(join(transfer, "incoming", file), target, {
|
|
42
63
|
dereference: false,
|
|
64
|
+
verbatimSymlinks: true,
|
|
65
|
+
force: false,
|
|
66
|
+
errorOnExist: true,
|
|
43
67
|
});
|
|
44
68
|
}
|
|
45
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-apply.js","sourceRoot":"","sources":["../../src/application/remote-apply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"remote-apply.js","sourceRoot":"","sources":["../../src/application/remote-apply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;IAC/D,IAAI,CAAC,OAAO,CAAC,kBAAkB,IAAI,CAAC,MAAM,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM;QACtE,MAAM,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC,CAAC;IACtE,IAAI,CAAC,OAAO,CAAC,kBAAkB,IAAI,CAAC,MAAM,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM;QACtE,MAAM,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE;YAC7B,OAAO;YACP,UAAU;YACV,UAAU;YACV,YAAY;SACb,CAAC,CAAC;IACL,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAChE,IAAI,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,WAAW,EAAE;YAC7D,MAAM,KAAK,CAAC,MAAM,CAAC,CAAC;QACtB,MAAM,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE;YACjD,WAAW,EAAE,KAAK;YAClB,gBAAgB,EAAE,IAAI;YACtB,KAAK,EAAE,KAAK;YACZ,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;IACL,CAAC;AACH,CAAC","sourcesContent":["import { cp, lstat, mkdir, readFile, rm, rmdir } from \"node:fs/promises\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { OutpostError } from \"../domain/errors.ts\";\nimport { safeDestination } from \"../infrastructure/files.ts\";\nimport { git } from \"../infrastructure/git/command.ts\";\nimport type {\n HostBackup,\n RemoteChanges,\n RemoteWorkspaceContext,\n} from \"./remote-workspace.types.ts\";\nimport { digest } from \"./workspace-fingerprint.ts\";\n\nexport async function applyChanges(\n context: RemoteWorkspaceContext,\n changes: RemoteChanges,\n backup: HostBackup,\n synchronized: string,\n expected: string,\n transfer: string,\n): Promise<void> {\n const {\n workspace,\n options,\n recovery,\n protectedFiles,\n initialPatch,\n initialIndex,\n } = context;\n const { head, patch, incoming } = changes;\n const { previousPatch, previousExtras } = backup;\n if ((await digest(workspace.directory, recovery)) !== expected)\n throw new OutpostError(\n \"conflict\",\n \"Host workspace changed during synchronization\",\n { recovery },\n );\n if (head !== synchronized)\n await git(workspace.directory, [\n \"fetch\",\n join(transfer, \"commits.bundle\"),\n \"HEAD\",\n ]);\n if ((await readFile(previousPatch)).length)\n await git(workspace.directory, [\n \"apply\",\n \"--reverse\",\n \"--binary\",\n previousPatch,\n ]);\n await git(workspace.directory, [\"reset\", \"--mixed\", \"HEAD\"]);\n for (const file of previousExtras.filter(\n (file) => !protectedFiles.includes(file),\n )) {\n const target = await safeDestination(workspace.directory, file);\n await rm(target, { force: true });\n let parent = dirname(target);\n while (parent !== resolve(workspace.directory)) {\n const removed = await rmdir(parent).then(\n () => true,\n (error: NodeJS.ErrnoException) => {\n if (\n error.code === \"ENOTEMPTY\" ||\n error.code === \"ENOENT\" ||\n error.code === \"EEXIST\"\n )\n return false;\n throw error;\n },\n );\n if (!removed) break;\n parent = dirname(parent);\n }\n }\n if (head !== synchronized)\n await git(workspace.directory, [\"merge\", \"--ff-only\", \"FETCH_HEAD\"]);\n if ((await readFile(patch)).length)\n await git(workspace.directory, [\"apply\", \"--binary\", patch]);\n if (!options.includeUncommitted && (await readFile(initialPatch)).length)\n await git(workspace.directory, [\"apply\", \"--binary\", initialPatch]);\n if (!options.includeUncommitted && (await readFile(initialIndex)).length)\n await git(workspace.directory, [\n \"apply\",\n \"--cached\",\n \"--binary\",\n initialIndex,\n ]);\n for (const file of incoming) {\n const target = await safeDestination(workspace.directory, file);\n if ((await lstat(target).catch(() => undefined))?.isDirectory())\n await rmdir(target);\n await mkdir(dirname(target), { recursive: true });\n await cp(join(transfer, \"incoming\", file), target, {\n dereference: false,\n verbatimSymlinks: true,\n force: false,\n errorOnExist: true,\n });\n }\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { captureRecoveryChecksums } from "./recovery-checksum-capture.js";
|
|
1
2
|
import { cp, mkdir, writeFile } from "node:fs/promises";
|
|
2
3
|
import { dirname, join } from "node:path";
|
|
3
4
|
import { safeDestination } from "../infrastructure/files.js";
|
|
@@ -25,14 +26,17 @@ export async function backupHost(context, changes, synchronized, transfer) {
|
|
|
25
26
|
await mkdir(dirname(backup), { recursive: true });
|
|
26
27
|
await cp(await safeDestination(workspace.directory, file), backup, {
|
|
27
28
|
dereference: false,
|
|
29
|
+
verbatimSymlinks: true,
|
|
28
30
|
});
|
|
29
31
|
}
|
|
30
|
-
|
|
32
|
+
const state = {
|
|
31
33
|
previous: synchronized,
|
|
32
34
|
next: head,
|
|
33
35
|
previousExtras,
|
|
34
36
|
incoming,
|
|
35
|
-
}
|
|
37
|
+
};
|
|
38
|
+
await writeFile(join(transfer, "state.json"), JSON.stringify(state));
|
|
39
|
+
await captureRecoveryChecksums(transfer, state);
|
|
36
40
|
return { previousPatch, previousExtras };
|
|
37
41
|
}
|
|
38
42
|
//# sourceMappingURL=remote-backup.js.map
|