firedrill-run 2.2.4 → 3.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/README.md +178 -22
- package/bin/firedrill.mjs +29 -5
- package/dist/assembly.json +13 -0
- package/dist/cli/runtime/candidate_copy.py +395 -0
- package/dist/cli/runtime/source_snapshot.py +391 -0
- package/dist/cli/src/administration.js +295 -0
- package/dist/cli/src/agent-changes.js +496 -0
- package/dist/cli/src/assessment-requests.js +67 -0
- package/dist/cli/src/auth.js +465 -0
- package/dist/cli/src/billing-commerce-contracts.js +1 -0
- package/dist/cli/src/billing-usage.js +227 -0
- package/dist/cli/src/billing-wallet-contracts.js +1 -0
- package/dist/cli/src/billing.js +170 -0
- package/dist/cli/src/bootstrap-process-lock.js +136 -0
- package/dist/cli/src/browser-links.js +14 -0
- package/dist/cli/src/campaign-controls.js +122 -0
- package/dist/cli/src/campaign-diagnoses.js +118 -0
- package/dist/cli/src/campaign-reports.js +1215 -0
- package/dist/cli/src/campaign-world.js +156 -0
- package/dist/cli/src/candidate-copy.js +376 -0
- package/dist/cli/src/catalog-contracts.js +1 -0
- package/dist/cli/src/ci-access-contracts.js +1 -0
- package/dist/cli/src/ci-configuration-contracts.js +1 -0
- package/dist/cli/src/ci-coverage.js +64 -0
- package/dist/cli/src/ci-delivery-contracts.js +1 -0
- package/dist/cli/src/ci-result-contracts.js +1 -0
- package/dist/cli/src/ci-run-contracts.js +1 -0
- package/dist/cli/src/ci-setup-proposals.js +52 -0
- package/dist/cli/src/company-policies.js +229 -0
- package/dist/cli/src/completion.js +79 -0
- package/dist/cli/src/configuration-intents.js +277 -0
- package/dist/cli/src/configuration.js +369 -0
- package/dist/cli/src/continuous-simulation.js +277 -0
- package/dist/cli/src/coordinated-checkpoints.js +133 -0
- package/dist/cli/src/credential-mode.js +139 -0
- package/dist/cli/src/credentials.js +331 -0
- package/dist/cli/src/credit-format.js +8 -0
- package/dist/cli/src/dataset-contracts.js +1 -0
- package/dist/cli/src/dataset-export.js +154 -0
- package/dist/cli/src/dataset-reads.js +37 -0
- package/dist/cli/src/dependency-preparation.js +239 -0
- package/dist/cli/src/director-tool-setup.js +104 -0
- package/dist/cli/src/driver-review.js +225 -0
- package/dist/cli/src/evaluation-authoring.js +315 -0
- package/dist/cli/src/evidence-bundles.js +367 -0
- package/dist/cli/src/execution-proposals.js +36 -0
- package/dist/cli/src/http.js +302 -0
- package/dist/cli/src/local-container-boundary.js +38 -0
- package/dist/cli/src/local-container-policy.js +201 -0
- package/dist/cli/src/local-execution-setup.js +81 -0
- package/dist/cli/src/local-source-basis.js +73 -0
- package/dist/cli/src/local-source.js +66 -0
- package/dist/cli/src/local-value-store.js +91 -0
- package/dist/cli/src/local-values.js +163 -0
- package/dist/cli/src/login-organizations.js +70 -0
- package/dist/cli/src/main.js +1622 -0
- package/dist/cli/src/mcp-connection.js +109 -0
- package/dist/cli/src/native/bindings.js +137 -0
- package/dist/cli/src/native/canonical.js +370 -0
- package/dist/cli/src/native/cloud-resources.js +942 -0
- package/dist/cli/src/native/companion-channel.js +421 -0
- package/dist/cli/src/native/companion-ipc.js +473 -0
- package/dist/cli/src/native/contracts.js +218 -0
- package/dist/cli/src/native/control-plane.js +1354 -0
- package/dist/cli/src/native/credit-approval.js +15 -0
- package/dist/cli/src/native/dependency-proxy.js +1006 -0
- package/dist/cli/src/native/drill-cleanup.js +115 -0
- package/dist/cli/src/native/drill-runner.js +1562 -0
- package/dist/cli/src/native/drivers/action-trace.js +210 -0
- package/dist/cli/src/native/drivers/function-wrapper.js +152 -0
- package/dist/cli/src/native/drivers/http.js +442 -0
- package/dist/cli/src/native/drivers/index.js +47 -0
- package/dist/cli/src/native/drivers/jsonl-process.js +538 -0
- package/dist/cli/src/native/drivers/playwright.js +600 -0
- package/dist/cli/src/native/drivers/signed-event.js +244 -0
- package/dist/cli/src/native/drivers/types.js +578 -0
- package/dist/cli/src/native/evidence-filter.js +255 -0
- package/dist/cli/src/native/isolated-access.js +241 -0
- package/dist/cli/src/native/library-sharing.js +220 -0
- package/dist/cli/src/native/local-run.js +667 -0
- package/dist/cli/src/native/local-secrets.js +19 -0
- package/dist/cli/src/native/mcp-config.js +123 -0
- package/dist/cli/src/native/metadata-requests.js +120 -0
- package/dist/cli/src/native/observations.js +1159 -0
- package/dist/cli/src/native/owned-groups.js +46 -0
- package/dist/cli/src/native/plan.js +594 -0
- package/dist/cli/src/native/png.js +159 -0
- package/dist/cli/src/native/ports.js +43 -0
- package/dist/cli/src/native/readiness.js +139 -0
- package/dist/cli/src/native/reassessments.js +206 -0
- package/dist/cli/src/native/redaction.js +235 -0
- package/dist/cli/src/native/registration.js +155 -0
- package/dist/cli/src/native/roots.js +110 -0
- package/dist/cli/src/native/run-cleanup.js +199 -0
- package/dist/cli/src/native/scratch.js +117 -0
- package/dist/cli/src/native/screenshots.js +60 -0
- package/dist/cli/src/native/session.js +556 -0
- package/dist/cli/src/native/standalone-proxy.js +580 -0
- package/dist/cli/src/native/standalone-renewals.js +183 -0
- package/dist/cli/src/native/standalone-state.js +193 -0
- package/dist/cli/src/native/standalone-tools.js +187 -0
- package/dist/cli/src/native/supervisor.js +831 -0
- package/dist/cli/src/native/target-auth.js +161 -0
- package/dist/cli/src/native/target-state.js +330 -0
- package/dist/cli/src/native/tool-reuse.js +364 -0
- package/dist/cli/src/native/tool-setups.js +336 -0
- package/dist/cli/src/native/world-reuse.js +288 -0
- package/dist/cli/src/onboarding.js +23 -0
- package/dist/cli/src/priority-requests.js +70 -0
- package/dist/cli/src/priority.js +223 -0
- package/dist/cli/src/prompts.js +184 -0
- package/dist/cli/src/real-operations.js +221 -0
- package/dist/cli/src/recipe-intents.js +58 -0
- package/dist/cli/src/recorded-context-intents.js +59 -0
- package/dist/cli/src/recorded-context.js +248 -0
- package/dist/cli/src/recordings.js +69 -0
- package/dist/cli/src/registration-guide.js +39 -0
- package/dist/cli/src/report-exports.js +213 -0
- package/dist/cli/src/request-input.js +47 -0
- package/dist/cli/src/resource-lifecycle.js +141 -0
- package/dist/cli/src/revision-requests.js +55 -0
- package/dist/cli/src/runner-abandon.js +53 -0
- package/dist/cli/src/runner-campaign-controls.js +262 -0
- package/dist/cli/src/runner-claim-reads.js +36 -0
- package/dist/cli/src/runner-completion.js +65 -0
- package/dist/cli/src/runner-configuration.js +546 -0
- package/dist/cli/src/runner-container.js +794 -0
- package/dist/cli/src/runner-evidence-erasure.js +351 -0
- package/dist/cli/src/runner-evidence-privacy.js +37 -0
- package/dist/cli/src/runner-evidence-retention.js +161 -0
- package/dist/cli/src/runner-evidence.js +326 -0
- package/dist/cli/src/runner-execute.js +92 -0
- package/dist/cli/src/runner-execution-deadline.js +25 -0
- package/dist/cli/src/runner-grants.js +307 -0
- package/dist/cli/src/runner-identity.js +615 -0
- package/dist/cli/src/runner-inputs.js +308 -0
- package/dist/cli/src/runner-jobs.js +49 -0
- package/dist/cli/src/runner-model-transport.js +392 -0
- package/dist/cli/src/runner-ownership.js +332 -0
- package/dist/cli/src/runner-process-lock.js +175 -0
- package/dist/cli/src/runner-runtime.js +396 -0
- package/dist/cli/src/runner-session-channel.js +377 -0
- package/dist/cli/src/runner-trial-completion.js +34 -0
- package/dist/cli/src/runner-trial-journal.js +358 -0
- package/dist/cli/src/runner-trial-live.js +393 -0
- package/dist/cli/src/runner-trial-protocol.js +289 -0
- package/dist/cli/src/runner-trial-sync.js +110 -0
- package/dist/cli/src/runner-trial-transfer.js +107 -0
- package/dist/cli/src/runner-voice.js +40 -0
- package/dist/cli/src/runner-world-claim.js +21 -0
- package/dist/cli/src/runner-world-collector.js +159 -0
- package/dist/cli/src/runner-world-command-evidence.js +487 -0
- package/dist/cli/src/runner-world-commands.js +268 -0
- package/dist/cli/src/runner-world-completion.js +76 -0
- package/dist/cli/src/runner-world-erasure.js +95 -0
- package/dist/cli/src/runner-world-evidence-sync.js +91 -0
- package/dist/cli/src/runner-world-journal.js +510 -0
- package/dist/cli/src/runner-world-native-filters.js +134 -0
- package/dist/cli/src/runner-world-observations.js +50 -0
- package/dist/cli/src/runner-world-session-protocol.js +134 -0
- package/dist/cli/src/saved-records.js +40 -0
- package/dist/cli/src/scenario-authoring.js +212 -0
- package/dist/cli/src/scenario-discovery.js +216 -0
- package/dist/cli/src/scenario-paths.js +68 -0
- package/dist/cli/src/scenario-requests.js +4 -0
- package/dist/cli/src/service-receipts.js +105 -0
- package/dist/cli/src/simple/authoring.js +270 -0
- package/dist/cli/src/simple/credit-approval.js +16 -0
- package/dist/cli/src/simple/help.js +98 -0
- package/dist/cli/src/simple/init.js +61 -0
- package/dist/cli/src/simple/library-sharing.js +414 -0
- package/dist/cli/src/simple/metadata-requests.js +46 -0
- package/dist/cli/src/simple/native-report.js +841 -0
- package/dist/cli/src/simple/native-tools.js +780 -0
- package/dist/cli/src/simple/plan-apply.js +506 -0
- package/dist/cli/src/simple/reassessment.js +323 -0
- package/dist/cli/src/simple/register.js +123 -0
- package/dist/cli/src/simple/run.js +122 -0
- package/dist/cli/src/simple/status.js +49 -0
- package/dist/cli/src/simple/tool-renewal.js +308 -0
- package/dist/cli/src/simple/tool-reuse.js +526 -0
- package/dist/cli/src/simple/tool-start-catalog.js +100 -0
- package/dist/cli/src/simple/tool-state.js +426 -0
- package/dist/cli/src/simple/tools-author.js +222 -0
- package/dist/cli/src/simple/watch.js +28 -0
- package/dist/cli/src/simple/world-reuse.js +586 -0
- package/dist/cli/src/simulation-intents.js +406 -0
- package/dist/cli/src/simulation-run.js +1058 -0
- package/dist/cli/src/source-batch.js +322 -0
- package/dist/cli/src/source-connection.js +451 -0
- package/dist/cli/src/source-runtime.js +346 -0
- package/dist/cli/src/source-selection-intents.js +75 -0
- package/dist/cli/src/source-sets.js +214 -0
- package/dist/cli/src/target-models.js +109 -0
- package/dist/cli/src/tool-catalog.js +224 -0
- package/dist/cli/src/tool-command-contracts.js +1 -0
- package/dist/cli/src/tool-command-export.js +245 -0
- package/dist/cli/src/tool-connection-contracts.js +1 -0
- package/dist/cli/src/tool-connection-reads.js +23 -0
- package/dist/cli/src/tool-contributions.js +58 -0
- package/dist/cli/src/tool-data.js +116 -0
- package/dist/cli/src/tool-datasets.js +176 -0
- package/dist/cli/src/tool-group-contracts.js +1 -0
- package/dist/cli/src/tool-group-reads.js +26 -0
- package/dist/cli/src/tool-group-state.js +147 -0
- package/dist/cli/src/tool-groups.js +311 -0
- package/dist/cli/src/tool-instances.js +186 -0
- package/dist/cli/src/tool-lifecycle-contracts.js +1 -0
- package/dist/cli/src/tool-lifecycle-reads.js +30 -0
- package/dist/cli/src/tool-lifecycle.js +323 -0
- package/dist/cli/src/tool-package-contracts.js +1 -0
- package/dist/cli/src/tool-package-reads.js +41 -0
- package/dist/cli/src/tool-records.js +53 -0
- package/dist/cli/src/tool-runtime.js +96 -0
- package/dist/cli/src/tool-state-contracts.js +1 -0
- package/dist/cli/src/tool-state-reads.js +31 -0
- package/dist/cli/src/tools.js +306 -0
- package/dist/cli/src/trial-actions.js +93 -0
- package/dist/cli/src/trial-checkpoints.js +133 -0
- package/dist/cli/src/trial-checks.js +70 -0
- package/dist/cli/src/trial-state.js +197 -0
- package/dist/cli/src/vault.js +266 -0
- package/dist/cli/src/workspace-registration.js +383 -0
- package/dist/cli/src/workspace-team-contracts.js +1 -0
- package/dist/cli/src/world-access.js +231 -0
- package/dist/cli/src/world-agent.js +4 -0
- package/dist/cli/src/world-checkpoint-scopes.js +15 -0
- package/dist/cli/src/world-contracts.js +6 -0
- package/dist/cli/src/world-creation.js +201 -0
- package/dist/cli/src/world-datasets.js +207 -0
- package/dist/cli/src/world-inspection.js +257 -0
- package/dist/cli/src/world-recipes.js +103 -0
- package/dist/cli/src/world-requests.js +241 -0
- package/dist/cli/src/world-session-checkpoints.js +196 -0
- package/dist/cli/src/world-session-lifecycle.js +207 -0
- package/dist/cli/src/world-session-requests.js +215 -0
- package/dist/cli/src/world-session-state.js +145 -0
- package/dist/cli/src/world-session-voice.js +66 -0
- package/dist/cli/src/world-sessions.js +288 -0
- package/dist/cli/src/world-stream.js +99 -0
- package/dist/cli/src/world-time-report.js +58 -0
- package/dist/contracts/agent-change-contracts.js +75 -0
- package/dist/contracts/agent-execution-contracts.js +38 -0
- package/dist/contracts/application-state-contracts.js +26 -0
- package/dist/contracts/assessment-aggregate-contracts.js +15 -0
- package/dist/contracts/assessment-contracts.js +74 -0
- package/dist/contracts/billing-commerce-contracts.js +107 -0
- package/dist/contracts/billing-wallet-contracts.js +43 -0
- package/dist/contracts/campaign-lifecycle.js +1 -0
- package/dist/contracts/campaign-world-contracts.js +80 -0
- package/dist/contracts/catalog-contracts.js +73 -0
- package/dist/contracts/ci-access-contracts.js +68 -0
- package/dist/contracts/ci-configuration-contracts.js +88 -0
- package/dist/contracts/ci-coverage-contracts.js +65 -0
- package/dist/contracts/ci-coverage-labels.js +25 -0
- package/dist/contracts/ci-delivery-contracts.js +61 -0
- package/dist/contracts/ci-result-contracts.js +103 -0
- package/dist/contracts/ci-run-contracts.js +51 -0
- package/dist/contracts/ci-setup-contracts.js +88 -0
- package/dist/contracts/clip-contracts.js +32 -0
- package/dist/contracts/comparison-contracts.js +53 -0
- package/dist/contracts/composite-contracts.js +34 -0
- package/dist/contracts/context-contracts.js +76 -0
- package/dist/contracts/continuation-report-contracts.js +1 -0
- package/dist/contracts/continuity-requirements.js +8 -0
- package/dist/contracts/coordinated-checkpoint-contracts.js +34 -0
- package/dist/contracts/dataset-contracts.js +88 -0
- package/dist/contracts/dependency-decision-contracts.js +36 -0
- package/dist/contracts/dependency-protocol-contracts.js +43 -0
- package/dist/contracts/director-execution.js +51 -0
- package/dist/contracts/driver-review-contracts.js +99 -0
- package/dist/contracts/evidence-contracts.js +65 -0
- package/dist/contracts/evidence-coverage-contracts.js +10 -0
- package/dist/contracts/export-contracts.js +44 -0
- package/dist/contracts/github-directory-contracts.js +96 -0
- package/dist/contracts/insight-contracts.js +11 -0
- package/dist/contracts/inspection-contracts.js +1 -0
- package/dist/contracts/local-claim-contracts.js +39 -0
- package/dist/contracts/local-configuration-contracts.js +7 -0
- package/dist/contracts/local-evidence-contracts.js +32 -0
- package/dist/contracts/local-grant-contracts.js +83 -0
- package/dist/contracts/local-input-contracts.js +19 -0
- package/dist/contracts/local-runner-contracts.js +42 -0
- package/dist/contracts/local-trial-live-contracts.js +16 -0
- package/dist/contracts/local-value-source-contracts.js +92 -0
- package/dist/contracts/local-world-native-contracts.js +8 -0
- package/dist/contracts/mcp-contracts.js +42 -0
- package/dist/contracts/media-contracts.js +28 -0
- package/dist/contracts/native-check-contracts.js +31 -0
- package/dist/contracts/native-identity-contracts.js +52 -0
- package/dist/contracts/onboarding-contracts.js +32 -0
- package/dist/contracts/performance-contracts.js +85 -0
- package/dist/contracts/planning-contracts.js +81 -0
- package/dist/contracts/real-operation-contracts.js +30 -0
- package/dist/contracts/recommendation-contracts.js +54 -0
- package/dist/contracts/report-contracts.js +1 -0
- package/dist/contracts/resource-lifecycle-contracts.js +57 -0
- package/dist/contracts/revision-contracts.js +12 -0
- package/dist/contracts/revision-request-contracts.js +39 -0
- package/dist/contracts/saved-record-contracts.js +76 -0
- package/dist/contracts/scenario-draft-comparison.js +91 -0
- package/dist/contracts/scenario-world-contracts.js +14 -0
- package/dist/contracts/service-contracts.js +1 -0
- package/dist/contracts/session-command-contracts.js +56 -0
- package/dist/contracts/session-contracts.js +65 -0
- package/dist/contracts/session-state-contracts.js +67 -0
- package/dist/contracts/session-voice-contracts.js +45 -0
- package/dist/contracts/source-set-contracts.js +26 -0
- package/dist/contracts/source-upload-contracts.js +22 -0
- package/dist/contracts/tool-command-contracts.js +57 -0
- package/dist/contracts/tool-connection-contracts.js +87 -0
- package/dist/contracts/tool-contribution-contracts.js +35 -0
- package/dist/contracts/tool-group-contracts.js +53 -0
- package/dist/contracts/tool-group-state-contracts.js +63 -0
- package/dist/contracts/tool-lifecycle-contracts.js +94 -0
- package/dist/contracts/tool-package-contracts.js +91 -0
- package/dist/contracts/tool-protocol-contracts.js +71 -0
- package/dist/contracts/tool-runtime-billing-contracts.js +28 -0
- package/dist/contracts/tool-setup-proposal.js +59 -0
- package/dist/contracts/tool-state-contracts.js +79 -0
- package/dist/contracts/trial-state-contracts.js +30 -0
- package/dist/contracts/typescript/agent-change.js +1 -0
- package/dist/contracts/typescript/assessment-aggregate.js +1 -0
- package/dist/contracts/typescript/assessment.js +1 -0
- package/dist/contracts/typescript/billing-commerce.js +1 -0
- package/dist/contracts/typescript/campaigns.js +1 -0
- package/dist/contracts/typescript/catalog.js +1 -0
- package/dist/contracts/typescript/ci-access.js +1 -0
- package/dist/contracts/typescript/ci-configuration.js +1 -0
- package/dist/contracts/typescript/ci-delivery.js +1 -0
- package/dist/contracts/typescript/ci-result.js +1 -0
- package/dist/contracts/typescript/ci-runs.js +1 -0
- package/dist/contracts/typescript/clips.js +1 -0
- package/dist/contracts/typescript/comparison.js +1 -0
- package/dist/contracts/typescript/composite.js +1 -0
- package/dist/contracts/typescript/connections.js +1 -0
- package/dist/contracts/typescript/context.js +1 -0
- package/dist/contracts/typescript/datasets.js +1 -0
- package/dist/contracts/typescript/evidence-coverage.js +1 -0
- package/dist/contracts/typescript/export.js +1 -0
- package/dist/contracts/typescript/github-directory.js +1 -0
- package/dist/contracts/typescript/insight.js +1 -0
- package/dist/contracts/typescript/inspection.js +1 -0
- package/dist/contracts/typescript/intake.js +1 -0
- package/dist/contracts/typescript/local-claim.js +1 -0
- package/dist/contracts/typescript/local-configuration.js +1 -0
- package/dist/contracts/typescript/local-evidence.js +1 -0
- package/dist/contracts/typescript/local-grant.js +1 -0
- package/dist/contracts/typescript/local-input.js +1 -0
- package/dist/contracts/typescript/local-runner.js +1 -0
- package/dist/contracts/typescript/local-trial-live.js +1 -0
- package/dist/contracts/typescript/local-value-source.js +1 -0
- package/dist/contracts/typescript/local-world-native.js +1 -0
- package/dist/contracts/typescript/mcp.js +1 -0
- package/dist/contracts/typescript/media.js +1 -0
- package/dist/contracts/typescript/native-check.js +1 -0
- package/dist/contracts/typescript/native-identity.js +1 -0
- package/dist/contracts/typescript/onboarding.js +1 -0
- package/dist/contracts/typescript/performance.js +1 -0
- package/dist/contracts/typescript/planning.js +1 -0
- package/dist/contracts/typescript/preparation.js +1 -0
- package/dist/contracts/typescript/real-operation.js +1 -0
- package/dist/contracts/typescript/recommendation.js +1 -0
- package/dist/contracts/typescript/reports.js +1 -0
- package/dist/contracts/typescript/resource-lifecycle.js +1 -0
- package/dist/contracts/typescript/saved-record.js +1 -0
- package/dist/contracts/typescript/scenarios.js +1 -0
- package/dist/contracts/typescript/services.js +1 -0
- package/dist/contracts/typescript/session-command.js +1 -0
- package/dist/contracts/typescript/session-state.js +1 -0
- package/dist/contracts/typescript/session-voice.js +1 -0
- package/dist/contracts/typescript/session.js +1 -0
- package/dist/contracts/typescript/tool-command.js +1 -0
- package/dist/contracts/typescript/tool-connection.js +1 -0
- package/dist/contracts/typescript/tool-contribution.js +1 -0
- package/dist/contracts/typescript/tool-groups.js +1 -0
- package/dist/contracts/typescript/tool-lifecycle.js +1 -0
- package/dist/contracts/typescript/tool-package.js +1 -0
- package/dist/contracts/typescript/tool-state.js +1 -0
- package/dist/contracts/typescript/trial-state.js +1 -0
- package/dist/contracts/typescript/vault.js +1 -0
- package/dist/contracts/typescript/workspace-team.js +1 -0
- package/dist/contracts/typescript/world-stream.js +1 -0
- package/dist/contracts/workspace-team-contracts.js +55 -0
- package/dist/contracts/world-command.js +65 -0
- package/dist/contracts/world-lifetime-contracts.js +74 -0
- package/dist/contracts/world-recipe-contracts.js +27 -0
- package/dist/contracts/world-stream-contracts.js +27 -0
- package/dist/package.json +1 -0
- package/package.json +16 -16
- package/LICENSE.md +0 -23
- package/PACKAGING.json +0 -50
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
+
import { constants } from 'node:fs';
|
|
3
|
+
import { lstat, mkdir, open, rename, unlink } from 'node:fs/promises';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { privateDirectory } from './credentials.js';
|
|
6
|
+
import { CliError } from './http.js';
|
|
7
|
+
import { identifier } from './world-contracts.js';
|
|
8
|
+
import { executeLocalTrial } from './runner-container.js';
|
|
9
|
+
import { inspectTrialReport, trialReportBytes, trialStatus } from './runner-trial-protocol.js';
|
|
10
|
+
import { withLocalJobInputs } from './runner-ownership.js';
|
|
11
|
+
import { assertEvidencePrivacy, evidenceNeedles } from './runner-evidence-privacy.js';
|
|
12
|
+
import { createLiveTrialRetainer } from './runner-trial-live.js';
|
|
13
|
+
import { acquireLocalEvidence, assertEvidenceRetentionCurrent, evidenceRetentionSignal, frozenEvidenceRetention, retentionMatches } from './runner-evidence-retention.js';
|
|
14
|
+
const hash = (body) => createHash('sha256').update(body).digest('hex');
|
|
15
|
+
const fail = () => new CliError('local_trial_journal_invalid', 'The private drill journal is incomplete. No target was restarted or cloud result claimed.');
|
|
16
|
+
async function folder(owner, create = true) {
|
|
17
|
+
const directory = join(await privateDirectory(), `trial-${identifier(owner.owner)}-${identifier(owner.workspace)}-${identifier(owner.lease)}`);
|
|
18
|
+
if (create)
|
|
19
|
+
await mkdir(directory, { mode: 0o700 }).catch(error => { if (error.code !== 'EEXIST')
|
|
20
|
+
throw error; });
|
|
21
|
+
const row = await lstat(directory);
|
|
22
|
+
if (!row.isDirectory() || row.isSymbolicLink() || row.mode & 0o077 || process.getuid && row.uid !== process.getuid())
|
|
23
|
+
throw fail();
|
|
24
|
+
return directory;
|
|
25
|
+
}
|
|
26
|
+
async function syncDirectory(directory) {
|
|
27
|
+
const file = await open(directory, constants.O_RDONLY | (constants.O_DIRECTORY ?? 0));
|
|
28
|
+
try {
|
|
29
|
+
await file.sync();
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
await file.close();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function write(directory, name, body, replace = false) {
|
|
36
|
+
const path = join(directory, name), pending = replace ? path + '.' + randomUUID() + '.tmp' : path;
|
|
37
|
+
const file = await open(pending, 'wx', 0o600);
|
|
38
|
+
try {
|
|
39
|
+
await file.writeFile(body);
|
|
40
|
+
await file.sync();
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
await file.close();
|
|
44
|
+
}
|
|
45
|
+
if (replace)
|
|
46
|
+
await rename(pending, path);
|
|
47
|
+
await syncDirectory(directory);
|
|
48
|
+
}
|
|
49
|
+
async function retainArtifact(directory, metadata, reader, blocked, retention, signal) {
|
|
50
|
+
assertEvidenceRetentionCurrent(retention);
|
|
51
|
+
const exported = await reader.artifact(metadata), partial = join(directory, metadata.id + '.partial');
|
|
52
|
+
const file = await open(partial, 'wx', 0o600), digest = createHash('sha256');
|
|
53
|
+
const overlap = blocked.reduce((maximum, value) => Math.max(maximum, value.length), 512);
|
|
54
|
+
let position = 0, tail = Buffer.alloc(0), accepted = false;
|
|
55
|
+
try {
|
|
56
|
+
while (position < metadata.size) {
|
|
57
|
+
signal.throwIfAborted();
|
|
58
|
+
assertEvidenceRetentionCurrent(retention);
|
|
59
|
+
const bytes = await exported.read(position, Math.min(16384, metadata.size - position));
|
|
60
|
+
assertEvidenceRetentionCurrent(retention);
|
|
61
|
+
if (!bytes.length || bytes.length > 16384 || position + bytes.length > metadata.size)
|
|
62
|
+
throw fail();
|
|
63
|
+
const scan = Buffer.concat([tail, bytes]);
|
|
64
|
+
assertEvidencePrivacy(scan, blocked);
|
|
65
|
+
tail.fill(0);
|
|
66
|
+
tail = Buffer.from(scan.subarray(Math.max(0, scan.length - overlap + 1)));
|
|
67
|
+
digest.update(bytes);
|
|
68
|
+
let written = 0;
|
|
69
|
+
while (written < bytes.length) {
|
|
70
|
+
const result = await file.write(bytes, written, bytes.length - written);
|
|
71
|
+
if (!result.bytesWritten)
|
|
72
|
+
throw fail();
|
|
73
|
+
written += result.bytesWritten;
|
|
74
|
+
}
|
|
75
|
+
position += bytes.length;
|
|
76
|
+
}
|
|
77
|
+
if (position !== metadata.size || digest.digest('hex') !== metadata.sha256)
|
|
78
|
+
throw fail();
|
|
79
|
+
await file.sync();
|
|
80
|
+
accepted = true;
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
await file.close();
|
|
84
|
+
tail.fill(0);
|
|
85
|
+
if (!accepted)
|
|
86
|
+
await unlink(partial).catch(() => undefined);
|
|
87
|
+
}
|
|
88
|
+
// Exact metadata was already retained in the immutable report page. Only a
|
|
89
|
+
// successful hash-checked rename publishes its bytes to a future sync reader.
|
|
90
|
+
await rename(partial, join(directory, metadata.id));
|
|
91
|
+
await syncDirectory(directory);
|
|
92
|
+
await write(directory, metadata.id + '.json', Buffer.from(JSON.stringify(metadata)));
|
|
93
|
+
}
|
|
94
|
+
async function collect(owner, manifest, configuration, observation, reader, retention, signal) {
|
|
95
|
+
signal = evidenceRetentionSignal(retention, signal);
|
|
96
|
+
const control = configuration.control;
|
|
97
|
+
if (owner.purpose !== 'trial' || control.schema !== 'firedrill.trial.v1')
|
|
98
|
+
throw fail();
|
|
99
|
+
const directory = await folder(owner), blocked = evidenceNeedles(configuration);
|
|
100
|
+
const journal = { schema: 'firedrill.local-trial-journal.v1', owner, manifest_sha256: manifest,
|
|
101
|
+
execution_id: control.execution_id, scenario_key: control.scenario_key, observation, stage: 'collecting', retention,
|
|
102
|
+
pages: 0, event_offset: 0, artifact_offset: 0, artifacts_retained: 0, page_chain_sha256: hash(''), collected_at: null,
|
|
103
|
+
cloud_completion_recorded: false, provenance: 'customer_device' };
|
|
104
|
+
const persist = (initial = false) => {
|
|
105
|
+
assertEvidenceRetentionCurrent(retention);
|
|
106
|
+
const body = Buffer.from(JSON.stringify(journal));
|
|
107
|
+
assertEvidencePrivacy(body, blocked);
|
|
108
|
+
return write(directory, 'receipt.json', body, !initial);
|
|
109
|
+
};
|
|
110
|
+
try {
|
|
111
|
+
await persist(true); // Existing/uncertain attempt is never overwritten.
|
|
112
|
+
for (;;) {
|
|
113
|
+
signal.throwIfAborted();
|
|
114
|
+
assertEvidenceRetentionCurrent(retention);
|
|
115
|
+
const report = await reader.report(journal.event_offset, journal.artifact_offset);
|
|
116
|
+
assertEvidenceRetentionCurrent(retention);
|
|
117
|
+
if (JSON.stringify(report.status) !== JSON.stringify(observation.status))
|
|
118
|
+
throw fail();
|
|
119
|
+
const body = trialReportBytes(report);
|
|
120
|
+
assertEvidencePrivacy(body, blocked);
|
|
121
|
+
const digest = hash(body), page = journal.pages;
|
|
122
|
+
await write(directory, `page-${page}.json`, body);
|
|
123
|
+
journal.pages++;
|
|
124
|
+
journal.event_offset = report.offset;
|
|
125
|
+
journal.artifact_offset = report.artifact_offset;
|
|
126
|
+
journal.page_chain_sha256 = hash(journal.page_chain_sha256 + ':' + page + ':' + digest);
|
|
127
|
+
await persist(); // Keep events even if the next artifact/pipe is lost.
|
|
128
|
+
for (const metadata of report.artifacts) {
|
|
129
|
+
await retainArtifact(directory, metadata, reader, blocked, retention, signal);
|
|
130
|
+
journal.artifacts_retained++;
|
|
131
|
+
await persist();
|
|
132
|
+
}
|
|
133
|
+
if (!report.events_more && !report.artifacts_more)
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
journal.stage = 'local_collected';
|
|
137
|
+
journal.collected_at = new Date().toISOString();
|
|
138
|
+
await persist();
|
|
139
|
+
return { schema: 'firedrill.local-trial-collection.v1', operation_id: owner.lease, execution_id: control.execution_id,
|
|
140
|
+
state: journal.stage, events: journal.event_offset, artifacts: journal.artifacts_retained,
|
|
141
|
+
provenance: 'customer_device', cloud_completion_recorded: false };
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
for (const value of blocked)
|
|
145
|
+
value.fill(0);
|
|
146
|
+
blocked.length = 0;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/** Uses the same claim/keeper/engine and exact cleanup path, never a new engine.
|
|
150
|
+
* Campaign admission and the explicit assignment command own the user intent.
|
|
151
|
+
*/
|
|
152
|
+
export async function retainLocalTrial(context, device, job, request, signal, output) {
|
|
153
|
+
let operation, executionError;
|
|
154
|
+
let result;
|
|
155
|
+
let live;
|
|
156
|
+
try {
|
|
157
|
+
result = await withLocalJobInputs(context, device, job, request, 'trial', signal, async (owner, inputs, configuration, active) => {
|
|
158
|
+
operation = owner.lease;
|
|
159
|
+
if (owner.purpose !== 'trial')
|
|
160
|
+
throw fail();
|
|
161
|
+
const evidence = await acquireLocalEvidence(owner, owner.lease, frozenEvidenceRetention(owner, inputs.manifestSha256, inputs.manifest.evidence_recovery_until));
|
|
162
|
+
try {
|
|
163
|
+
active = AbortSignal.any([active, evidence.signal]);
|
|
164
|
+
const stream = await createLiveTrialRetainer(owner, inputs.manifestSha256, configuration, evidence.retention, active, output);
|
|
165
|
+
let collected;
|
|
166
|
+
try {
|
|
167
|
+
collected = await executeLocalTrial(owner, inputs, configuration, (owned, observation, reader, collecting) => collect(owned, inputs.manifestSha256, configuration, observation, reader, evidence.retention, collecting), active, stream.accept, stream.artifact);
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
await stream.finish().catch(() => undefined);
|
|
171
|
+
throw error;
|
|
172
|
+
}
|
|
173
|
+
live = await stream.finish();
|
|
174
|
+
return collected;
|
|
175
|
+
}
|
|
176
|
+
finally {
|
|
177
|
+
await evidence.close();
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
executionError = error;
|
|
183
|
+
}
|
|
184
|
+
const { syncLocalTrialCompletion } = await import('./runner-trial-completion.js');
|
|
185
|
+
if (operation) {
|
|
186
|
+
try {
|
|
187
|
+
await syncLocalTrialCompletion(context, operation, AbortSignal.timeout(30000));
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
if (!executionError)
|
|
191
|
+
throw error;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
if (executionError) {
|
|
195
|
+
if (operation) {
|
|
196
|
+
// Original evidence consent still governs bounded partial bookkeeping.
|
|
197
|
+
// This transfer cannot start/renew the failed or interrupted execution.
|
|
198
|
+
try {
|
|
199
|
+
const { syncLocalTrialEvidence } = await import('./runner-trial-sync.js');
|
|
200
|
+
await syncLocalTrialEvidence(context, operation, AbortSignal.timeout(30000), output);
|
|
201
|
+
}
|
|
202
|
+
catch { /* Exact private journal remains. */ }
|
|
203
|
+
}
|
|
204
|
+
throw executionError;
|
|
205
|
+
}
|
|
206
|
+
if (!result || !operation)
|
|
207
|
+
throw fail();
|
|
208
|
+
const { syncLocalTrialEvidence } = await import('./runner-trial-sync.js');
|
|
209
|
+
const evidence = await syncLocalTrialEvidence(context, operation, signal, output);
|
|
210
|
+
const closing = await syncLocalTrialCompletion(context, operation, signal, { wait: true });
|
|
211
|
+
return { ...result, live, evidence, closing };
|
|
212
|
+
}
|
|
213
|
+
async function privateFile(path, maximum) {
|
|
214
|
+
const before = await lstat(path);
|
|
215
|
+
if (!before.isFile() || before.isSymbolicLink() || before.nlink !== 1 || before.mode & 0o077 || before.size > maximum
|
|
216
|
+
|| process.getuid && before.uid !== process.getuid())
|
|
217
|
+
throw fail();
|
|
218
|
+
const file = await open(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0));
|
|
219
|
+
const actual = await file.stat();
|
|
220
|
+
if (actual.ino !== before.ino || actual.dev !== before.dev || actual.size !== before.size) {
|
|
221
|
+
await file.close();
|
|
222
|
+
throw fail();
|
|
223
|
+
}
|
|
224
|
+
return file;
|
|
225
|
+
}
|
|
226
|
+
async function privateJson(path, maximum) {
|
|
227
|
+
const file = await privateFile(path, maximum);
|
|
228
|
+
try {
|
|
229
|
+
const before = await file.stat(), body = await file.readFile('utf8'), after = await file.stat();
|
|
230
|
+
if (after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.ctimeMs !== before.ctimeMs)
|
|
231
|
+
throw fail();
|
|
232
|
+
return JSON.parse(body);
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
throw fail();
|
|
236
|
+
}
|
|
237
|
+
finally {
|
|
238
|
+
await file.close();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
/** Immutable local snapshot for subsequent explicit sync. Never opens Docker,
|
|
242
|
+
* renews a lease, runs an agent or assumes the cloud retained this evidence.
|
|
243
|
+
* A consumer must exhaust pages before committing an aggregate: the final chain
|
|
244
|
+
* check is not permission to treat a partially consumed snapshot as complete.
|
|
245
|
+
*/
|
|
246
|
+
export async function localTrialCollection(scope, operation, retention) {
|
|
247
|
+
const directory = await folder({ ...scope, lease: identifier(operation) }, false);
|
|
248
|
+
const value = await privateJson(join(directory, 'receipt.json'), 65536);
|
|
249
|
+
if (!value || value.schema !== 'firedrill.local-trial-journal.v1' || !value.owner || value.owner.owner !== scope.owner
|
|
250
|
+
|| value.owner.workspace !== scope.workspace || value.owner.lease !== operation || value.owner.purpose !== 'trial'
|
|
251
|
+
|| !['collecting', 'local_collected'].includes(value.stage) || value.provenance !== 'customer_device'
|
|
252
|
+
|| value.cloud_completion_recorded !== false || !/^[a-f0-9]{64}$/.test(value.manifest_sha256)
|
|
253
|
+
|| !/^[a-f0-9]{64}$/.test(value.page_chain_sha256) || typeof value.scenario_key !== 'string'
|
|
254
|
+
|| !value.scenario_key.length || value.scenario_key.length > 255
|
|
255
|
+
|| [value.pages, value.event_offset, value.artifact_offset, value.artifacts_retained].some(item => !Number.isSafeInteger(item) || item < 0)
|
|
256
|
+
|| value.artifacts_retained > value.artifact_offset || value.event_offset > value.pages || value.artifact_offset > value.pages
|
|
257
|
+
|| value.stage === 'local_collected' && (value.artifacts_retained !== value.artifact_offset
|
|
258
|
+
|| typeof value.collected_at !== 'string' || !Number.isFinite(Date.parse(value.collected_at))))
|
|
259
|
+
throw fail();
|
|
260
|
+
for (const id of [value.execution_id, value.owner.job, value.owner.attempt, value.owner.device, value.owner.request])
|
|
261
|
+
identifier(id);
|
|
262
|
+
const observation = value.observation;
|
|
263
|
+
if (!observation || observation.operation_id !== operation || observation.provenance !== 'customer_device'
|
|
264
|
+
|| !/^[a-f0-9]{64}$/.test(observation.container_id) || !observation.launch || observation.launch.launch_id !== operation
|
|
265
|
+
|| !['exited', 'launch_failed'].includes(observation.launch.state)
|
|
266
|
+
|| observation.launch.state === 'exited' && (!Number.isSafeInteger(observation.launch.exit_code)
|
|
267
|
+
|| observation.launch.exit_code < -128 || observation.launch.exit_code > 255))
|
|
268
|
+
throw fail();
|
|
269
|
+
trialStatus(observation.status);
|
|
270
|
+
const raw = () => {
|
|
271
|
+
if (!retention || !retentionMatches(value.retention, retention) || value.manifest_sha256 !== retention.manifest_sha256)
|
|
272
|
+
throw new CliError('local_evidence_retention_missing', 'This drill is available for metadata inspection only. Raw evidence needs its original finite device retention policy.');
|
|
273
|
+
assertEvidenceRetentionCurrent(retention);
|
|
274
|
+
};
|
|
275
|
+
return { journal: value,
|
|
276
|
+
pages: async function* (signal) {
|
|
277
|
+
raw();
|
|
278
|
+
let after = 0, artifactAfter = 0, chain = hash(''), last = null;
|
|
279
|
+
for (let position = 0; position < value.pages; position++) {
|
|
280
|
+
signal.throwIfAborted();
|
|
281
|
+
raw();
|
|
282
|
+
const file = await privateFile(join(directory, `page-${position}.json`), 4 * 1024 ** 2);
|
|
283
|
+
let bytes;
|
|
284
|
+
try {
|
|
285
|
+
const before = await file.stat();
|
|
286
|
+
bytes = await file.readFile();
|
|
287
|
+
const after = await file.stat();
|
|
288
|
+
if (after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.ctimeMs !== before.ctimeMs)
|
|
289
|
+
throw fail();
|
|
290
|
+
}
|
|
291
|
+
finally {
|
|
292
|
+
await file.close();
|
|
293
|
+
}
|
|
294
|
+
let decoded;
|
|
295
|
+
try {
|
|
296
|
+
decoded = JSON.parse(bytes.toString('utf8'));
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
throw fail();
|
|
300
|
+
}
|
|
301
|
+
last = inspectTrialReport(decoded, operation, value.execution_id, value.scenario_key, observation.launch, after, artifactAfter);
|
|
302
|
+
if (JSON.stringify(last.status) !== JSON.stringify(observation.status))
|
|
303
|
+
throw fail();
|
|
304
|
+
after = last.offset;
|
|
305
|
+
artifactAfter = last.artifact_offset;
|
|
306
|
+
chain = hash(chain + ':' + position + ':' + hash(bytes));
|
|
307
|
+
yield { position, size: bytes.length, sha256: hash(bytes), bytes, report: last };
|
|
308
|
+
}
|
|
309
|
+
if (chain !== value.page_chain_sha256 || after !== value.event_offset || artifactAfter !== value.artifact_offset
|
|
310
|
+
|| value.stage === 'local_collected' && (!last || last.events_more || last.artifacts_more))
|
|
311
|
+
throw fail();
|
|
312
|
+
},
|
|
313
|
+
artifact: async (metadata, consume, signal) => {
|
|
314
|
+
raw();
|
|
315
|
+
if (!/^(0|[1-9][0-9]{0,9})\.bin$/.test(metadata.id) || metadata.execution_id !== value.execution_id
|
|
316
|
+
|| metadata.scenario_key !== value.scenario_key)
|
|
317
|
+
throw fail();
|
|
318
|
+
const retained = await privateJson(join(directory, metadata.id + '.json'), 8192);
|
|
319
|
+
if (!retained || Object.keys(retained).sort().join(',') !== Object.keys(metadata).sort().join(',')
|
|
320
|
+
|| Object.keys(metadata).some(key => retained[key] !== metadata[key])
|
|
321
|
+
|| !Number.isSafeInteger(metadata.size) || metadata.size < 0 || metadata.size > 512 * 1024 ** 2)
|
|
322
|
+
throw fail();
|
|
323
|
+
const file = await privateFile(join(directory, metadata.id), 512 * 1024 ** 2);
|
|
324
|
+
try {
|
|
325
|
+
const before = await file.stat(), digest = createHash('sha256');
|
|
326
|
+
for await (const body of file.createReadStream({ autoClose: false, start: 0 })) {
|
|
327
|
+
signal.throwIfAborted();
|
|
328
|
+
raw();
|
|
329
|
+
digest.update(body);
|
|
330
|
+
}
|
|
331
|
+
if (before.size !== metadata.size || digest.digest('hex') !== metadata.sha256)
|
|
332
|
+
throw fail();
|
|
333
|
+
await consume(async (offset, length) => {
|
|
334
|
+
signal.throwIfAborted();
|
|
335
|
+
raw();
|
|
336
|
+
if (!Number.isSafeInteger(offset) || offset < 0 || !Number.isSafeInteger(length) || length < 1 || length > 1024 ** 2
|
|
337
|
+
|| offset + length > metadata.size)
|
|
338
|
+
throw fail();
|
|
339
|
+
const bytes = Buffer.alloc(length);
|
|
340
|
+
let position = 0;
|
|
341
|
+
while (position < length) {
|
|
342
|
+
const part = await file.read(bytes, position, length - position, offset + position);
|
|
343
|
+
if (!part.bytesRead)
|
|
344
|
+
throw fail();
|
|
345
|
+
position += part.bytesRead;
|
|
346
|
+
}
|
|
347
|
+
const after = await file.stat();
|
|
348
|
+
if (after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.ctimeMs !== before.ctimeMs)
|
|
349
|
+
throw fail();
|
|
350
|
+
return bytes;
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
finally {
|
|
354
|
+
await file.close();
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
};
|
|
358
|
+
}
|