@lesliechan721/aw 0.1.0-beta.6 → 0.1.0-beta.60
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/dist/authoring/assets/aw-config.mjs +100 -501
- package/dist/authoring/assets/aw-config.mjs.map +1 -1
- package/dist/authoring/assets/aw-runtime-config.d.mts +13 -0
- package/dist/authoring/assets/aw-runtime-config.mjs +199 -0
- package/dist/authoring/assets/aw-runtime-config.mjs.map +1 -0
- package/dist/authoring/scripts/add-skill.mjs +4 -4
- package/dist/authoring/scripts/add-skill.mjs.map +1 -1
- package/dist/authoring/scripts/init-plugin.mjs +67 -97
- package/dist/authoring/scripts/init-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/lib/plugin-root.mjs +4 -4
- package/dist/authoring/scripts/lib/plugin-root.mjs.map +1 -1
- package/dist/authoring/scripts/lib/plugin-version-check.d.mts +1 -0
- package/dist/authoring/scripts/lib/plugin-version-check.mjs +229 -8
- package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -1
- package/dist/authoring/scripts/lib/skill-scaffold.d.mts +77 -92
- package/dist/authoring/scripts/lib/skill-scaffold.mjs +99 -124
- package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -1
- package/dist/authoring/scripts/plugin-status.mjs +8 -11
- package/dist/authoring/scripts/plugin-status.mjs.map +1 -1
- package/dist/authoring/scripts/remove-plugin.mjs +3 -2
- package/dist/authoring/scripts/remove-plugin.mjs.map +1 -1
- package/dist/authoring/scripts/validate-plugin.mjs +552 -1142
- package/dist/authoring/scripts/validate-plugin.mjs.map +1 -1
- package/dist/native-runtime/reader-runtime.mjs +34 -0
- package/dist/native-runtime/reader.d.mts +6 -0
- package/dist/native-runtime/reader.mjs +11 -0
- package/dist/scripts/aw-skill-eval-materializer.d.ts +26 -0
- package/dist/scripts/aw-skill-eval-materializer.js +306 -0
- package/dist/scripts/aw-skill-eval-materializer.js.map +1 -0
- package/dist/scripts/bundle-plugins.d.ts +1 -0
- package/dist/scripts/bundle-plugins.js +19 -8
- package/dist/scripts/bundle-plugins.js.map +1 -1
- package/dist/scripts/plugin-staging.d.ts +7 -9
- package/dist/scripts/plugin-staging.js +18 -29
- package/dist/scripts/plugin-staging.js.map +1 -1
- package/dist/scripts/plugin-test-reporter.d.mts +2 -0
- package/dist/scripts/plugin-test-reporter.mjs +21 -0
- package/dist/scripts/plugin-test-reporter.mjs.map +1 -0
- package/dist/scripts/test-plugin-scripts.d.ts +5 -0
- package/dist/scripts/test-plugin-scripts.js +208 -89
- package/dist/scripts/test-plugin-scripts.js.map +1 -1
- package/dist/scripts/test-workers.d.mts +24 -0
- package/dist/scripts/test-workers.mjs +59 -0
- package/dist/scripts/test-workers.mjs.map +1 -0
- package/dist/src/adapters/helpers.d.ts +7 -0
- package/dist/src/adapters/helpers.js +2 -2
- package/dist/src/adapters/helpers.js.map +1 -1
- package/dist/src/authoring/workspace-commands.d.ts +19 -1
- package/dist/src/authoring/workspace-commands.js +24 -5
- package/dist/src/authoring/workspace-commands.js.map +1 -1
- package/dist/src/commands/aw-capabilities.d.ts +78 -0
- package/dist/src/commands/aw-capabilities.js +266 -0
- package/dist/src/commands/aw-capabilities.js.map +1 -0
- package/dist/src/commands/catalog-dev-source.d.ts +154 -0
- package/dist/src/commands/catalog-dev-source.js +655 -0
- package/dist/src/commands/catalog-dev-source.js.map +1 -0
- package/dist/src/commands/catalog-generation.d.ts +21 -0
- package/dist/src/commands/catalog-generation.js +9 -0
- package/dist/src/commands/catalog-generation.js.map +1 -0
- package/dist/src/commands/catalog-publication-inspection.d.ts +71 -30
- package/dist/src/commands/catalog-publication-inspection.js +475 -63
- package/dist/src/commands/catalog-publication-inspection.js.map +1 -1
- package/dist/src/commands/catalog-publication-journal.d.ts +68 -0
- package/dist/src/commands/catalog-publication-journal.js +292 -0
- package/dist/src/commands/catalog-publication-journal.js.map +1 -0
- package/dist/src/commands/catalog-publication-target.d.ts +18 -0
- package/dist/src/commands/catalog-publication-target.js +95 -0
- package/dist/src/commands/catalog-publication-target.js.map +1 -0
- package/dist/src/commands/catalog-publish.d.ts +73 -15
- package/dist/src/commands/catalog-publish.js +701 -212
- package/dist/src/commands/catalog-publish.js.map +1 -1
- package/dist/src/commands/catalog-source.d.ts +60 -22
- package/dist/src/commands/catalog-source.js +311 -91
- package/dist/src/commands/catalog-source.js.map +1 -1
- package/dist/src/commands/catalog-status.d.ts +18 -22
- package/dist/src/commands/catalog-status.js +81 -115
- package/dist/src/commands/catalog-status.js.map +1 -1
- package/dist/src/commands/catalog-store.d.ts +104 -0
- package/dist/src/commands/catalog-store.js +685 -0
- package/dist/src/commands/catalog-store.js.map +1 -0
- package/dist/src/commands/catalog-workspace-resolution.d.ts +13 -0
- package/dist/src/commands/catalog-workspace-resolution.js +42 -0
- package/dist/src/commands/catalog-workspace-resolution.js.map +1 -0
- package/dist/src/commands/console.js +28 -17
- package/dist/src/commands/console.js.map +1 -1
- package/dist/src/commands/dependency-operation-plan.d.ts +52 -15
- package/dist/src/commands/dependency-operation-plan.js +289 -7
- package/dist/src/commands/dependency-operation-plan.js.map +1 -1
- package/dist/src/commands/init.d.ts +5 -11
- package/dist/src/commands/init.js +30 -51
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/managed-commands.d.ts +28 -0
- package/dist/src/commands/managed-commands.js +315 -0
- package/dist/src/commands/managed-commands.js.map +1 -0
- package/dist/src/commands/offline-cleanup-evidence.d.ts +67 -0
- package/dist/src/commands/offline-cleanup-evidence.js +181 -0
- package/dist/src/commands/offline-cleanup-evidence.js.map +1 -0
- package/dist/src/commands/operation-plan.d.ts +182 -0
- package/dist/src/commands/operation-plan.js +71 -0
- package/dist/src/commands/operation-plan.js.map +1 -0
- package/dist/src/commands/operation-planner.d.ts +47 -0
- package/dist/src/commands/operation-planner.js +142 -0
- package/dist/src/commands/operation-planner.js.map +1 -0
- package/dist/src/commands/options.d.ts +9 -7
- package/dist/src/commands/options.js +83 -21
- package/dist/src/commands/options.js.map +1 -1
- package/dist/src/commands/plugin-capabilities.js +65 -4
- package/dist/src/commands/plugin-capabilities.js.map +1 -1
- package/dist/src/commands/rebuild-command.d.ts +78 -31
- package/dist/src/commands/rebuild-command.js +5229 -942
- package/dist/src/commands/rebuild-command.js.map +1 -1
- package/dist/src/commands/rebuild-integration.d.ts +143 -21
- package/dist/src/commands/rebuild-integration.js +3384 -1342
- package/dist/src/commands/rebuild-integration.js.map +1 -1
- package/dist/src/commands/rebuild-operations.d.ts +60 -30
- package/dist/src/commands/rebuild-operations.js +267 -320
- package/dist/src/commands/rebuild-operations.js.map +1 -1
- package/dist/src/commands/reconcile-operation-plan.d.ts +28 -0
- package/dist/src/commands/reconcile-operation-plan.js +47 -0
- package/dist/src/commands/reconcile-operation-plan.js.map +1 -0
- package/dist/src/commands/review-inspection.d.ts +60 -0
- package/dist/src/commands/review-inspection.js +422 -0
- package/dist/src/commands/review-inspection.js.map +1 -0
- package/dist/src/commands/review-preparation.d.ts +49 -0
- package/dist/src/commands/review-preparation.js +427 -0
- package/dist/src/commands/review-preparation.js.map +1 -0
- package/dist/src/commands/runtime.d.ts +1 -5
- package/dist/src/commands/runtime.js +27 -53
- package/dist/src/commands/runtime.js.map +1 -1
- package/dist/src/commands/skill-eval.d.ts +39 -0
- package/dist/src/commands/skill-eval.js +400 -0
- package/dist/src/commands/skill-eval.js.map +1 -0
- package/dist/src/commands/status-v6.d.ts +279 -0
- package/dist/src/commands/status-v6.js +2785 -0
- package/dist/src/commands/status-v6.js.map +1 -0
- package/dist/src/commands/sync-command.d.ts +40 -0
- package/dist/src/commands/sync-command.js +254 -0
- package/dist/src/commands/sync-command.js.map +1 -0
- package/dist/src/commands/wizard.d.ts +8 -5
- package/dist/src/commands/wizard.js +6 -4
- package/dist/src/commands/wizard.js.map +1 -1
- package/dist/src/commands/write-commands.d.ts +9 -3
- package/dist/src/commands/write-commands.js +136 -31
- package/dist/src/commands/write-commands.js.map +1 -1
- package/dist/src/constants.d.ts +7 -2
- package/dist/src/constants.js +7 -2
- package/dist/src/constants.js.map +1 -1
- package/dist/src/eval/manifest-v1.d.ts +68 -0
- package/dist/src/eval/manifest-v1.js +353 -0
- package/dist/src/eval/manifest-v1.js.map +1 -0
- package/dist/src/generators/local-plugin.d.ts +5 -1
- package/dist/src/generators/local-plugin.js +261 -109
- package/dist/src/generators/local-plugin.js.map +1 -1
- package/dist/src/generators/permissions.d.ts +5 -2
- package/dist/src/generators/permissions.js +28 -15
- package/dist/src/generators/permissions.js.map +1 -1
- package/dist/src/index.d.ts +10 -4
- package/dist/src/index.js +1774 -609
- package/dist/src/index.js.map +1 -1
- package/dist/src/output/command-receipt.d.ts +47 -46
- package/dist/src/output/command-receipt.js +277 -79
- package/dist/src/output/command-receipt.js.map +1 -1
- package/dist/src/output/model.d.ts +3 -44
- package/dist/src/output/model.js +1 -144
- package/dist/src/output/model.js.map +1 -1
- package/dist/src/output/rebuild-progress.js +15 -13
- package/dist/src/output/rebuild-progress.js.map +1 -1
- package/dist/src/portable/commands.d.ts +46 -7
- package/dist/src/portable/commands.js +349 -37
- package/dist/src/portable/commands.js.map +1 -1
- package/dist/src/portable/materializer.d.ts +17 -4
- package/dist/src/portable/materializer.js +186 -41
- package/dist/src/portable/materializer.js.map +1 -1
- package/dist/src/portable/skills-cli.d.ts +15 -7
- package/dist/src/portable/skills-cli.js +74 -20
- package/dist/src/portable/skills-cli.js.map +1 -1
- package/dist/src/review/eval-source-input.d.ts +43 -0
- package/dist/src/review/eval-source-input.js +207 -0
- package/dist/src/review/eval-source-input.js.map +1 -0
- package/dist/src/review/review-profile.d.ts +17 -0
- package/dist/src/review/review-profile.js +234 -0
- package/dist/src/review/review-profile.js.map +1 -0
- package/dist/src/review/review-selection.d.ts +30 -0
- package/dist/src/review/review-selection.js +527 -0
- package/dist/src/review/review-selection.js.map +1 -0
- package/dist/src/review/review-types.d.ts +68 -0
- package/dist/src/review/review-types.js +16 -0
- package/dist/src/review/review-types.js.map +1 -0
- package/dist/src/review/skill-materialization.d.ts +26 -0
- package/dist/src/review/skill-materialization.js +217 -0
- package/dist/src/review/skill-materialization.js.map +1 -0
- package/dist/src/review/source-binding.d.ts +183 -0
- package/dist/src/review/source-binding.js +708 -0
- package/dist/src/review/source-binding.js.map +1 -0
- package/dist/src/tui/catalog-freshness.d.ts +1 -0
- package/dist/src/tui/catalog-freshness.js +2 -0
- package/dist/src/tui/catalog-freshness.js.map +1 -0
- package/dist/src/tui/catalog-generation.d.ts +21 -0
- package/dist/src/tui/catalog-generation.js +156 -0
- package/dist/src/tui/catalog-generation.js.map +1 -0
- package/dist/src/tui/catalog-sources/projection.d.ts +4 -0
- package/dist/src/tui/catalog-sources/projection.js +17 -0
- package/dist/src/tui/catalog-sources/projection.js.map +1 -0
- package/dist/src/tui/catalog-sources/review.d.ts +3 -0
- package/dist/src/tui/catalog-sources/review.js +13 -0
- package/dist/src/tui/catalog-sources/review.js.map +1 -0
- package/dist/src/tui/catalog-sources/screens.d.ts +12 -0
- package/dist/src/tui/catalog-sources/screens.js +40 -0
- package/dist/src/tui/catalog-sources/screens.js.map +1 -0
- package/dist/src/tui/catalog-sources/session.d.ts +32 -0
- package/dist/src/tui/catalog-sources/session.js +300 -0
- package/dist/src/tui/catalog-sources/session.js.map +1 -0
- package/dist/src/tui/catalog-sources/types.d.ts +54 -0
- package/dist/src/tui/catalog-sources/types.js +2 -0
- package/dist/src/tui/catalog-sources/types.js.map +1 -0
- package/dist/src/tui/catalog-store-task.d.ts +16 -0
- package/dist/src/tui/catalog-store-task.js +19 -0
- package/dist/src/tui/catalog-store-task.js.map +1 -0
- package/dist/src/tui/clipboard.d.ts +13 -0
- package/dist/src/tui/clipboard.js +95 -0
- package/dist/src/tui/clipboard.js.map +1 -0
- package/dist/src/tui/components.d.ts +110 -3
- package/dist/src/tui/components.js +183 -36
- package/dist/src/tui/components.js.map +1 -1
- package/dist/src/tui/config-array-draft.d.ts +29 -0
- package/dist/src/tui/config-array-draft.js +48 -0
- package/dist/src/tui/config-array-draft.js.map +1 -0
- package/dist/src/tui/config-leaf-editor.d.ts +19 -0
- package/dist/src/tui/config-leaf-editor.js +212 -0
- package/dist/src/tui/config-leaf-editor.js.map +1 -0
- package/dist/src/tui/config-references.d.ts +34 -0
- package/dist/src/tui/config-references.js +70 -0
- package/dist/src/tui/config-references.js.map +1 -0
- package/dist/src/tui/config-value-presentation.d.ts +20 -0
- package/dist/src/tui/config-value-presentation.js +104 -0
- package/dist/src/tui/config-value-presentation.js.map +1 -0
- package/dist/src/tui/console-app-v4.d.ts +14 -4
- package/dist/src/tui/console-app-v4.js +9205 -1951
- package/dist/src/tui/console-app-v4.js.map +1 -1
- package/dist/src/tui/content-item-card.d.ts +13 -0
- package/dist/src/tui/content-item-card.js +51 -0
- package/dist/src/tui/content-item-card.js.map +1 -0
- package/dist/src/tui/controller-runtime.d.ts +10 -2
- package/dist/src/tui/controller-runtime.js +3289 -388
- package/dist/src/tui/controller-runtime.js.map +1 -1
- package/dist/src/tui/controller.d.ts +622 -45
- package/dist/src/tui/controller.js +3589 -768
- package/dist/src/tui/controller.js.map +1 -1
- package/dist/src/tui/dependency-graph-view.d.ts +39 -0
- package/dist/src/tui/dependency-graph-view.js +121 -0
- package/dist/src/tui/dependency-graph-view.js.map +1 -0
- package/dist/src/tui/dependency-graph.d.ts +81 -0
- package/dist/src/tui/dependency-graph.js +452 -0
- package/dist/src/tui/dependency-graph.js.map +1 -0
- package/dist/src/tui/diagnostic-projection.d.ts +23 -0
- package/dist/src/tui/diagnostic-projection.js +595 -0
- package/dist/src/tui/diagnostic-projection.js.map +1 -0
- package/dist/src/tui/diagnostics.d.ts +3 -3
- package/dist/src/tui/diagnostics.js +14 -2
- package/dist/src/tui/diagnostics.js.map +1 -1
- package/dist/src/tui/entity-cards.d.ts +55 -0
- package/dist/src/tui/entity-cards.js +220 -0
- package/dist/src/tui/entity-cards.js.map +1 -0
- package/dist/src/tui/glossary.d.ts +23 -0
- package/dist/src/tui/glossary.js +42 -0
- package/dist/src/tui/glossary.js.map +1 -0
- package/dist/src/tui/index.d.ts +6 -1
- package/dist/src/tui/index.js +5 -1
- package/dist/src/tui/index.js.map +1 -1
- package/dist/src/tui/input-display.d.ts +9 -0
- package/dist/src/tui/input-display.js +58 -0
- package/dist/src/tui/input-display.js.map +1 -0
- package/dist/src/tui/keys.d.ts +44 -0
- package/dist/src/tui/keys.js +43 -15
- package/dist/src/tui/keys.js.map +1 -1
- package/dist/src/tui/lifecycle-action-view.d.ts +6 -0
- package/dist/src/tui/lifecycle-action-view.js +36 -0
- package/dist/src/tui/lifecycle-action-view.js.map +1 -0
- package/dist/src/tui/model.d.ts +224 -31
- package/dist/src/tui/model.js +1510 -397
- package/dist/src/tui/model.js.map +1 -1
- package/dist/src/tui/operation-diagnostic-screens.d.ts +8 -0
- package/dist/src/tui/operation-diagnostic-screens.js +71 -0
- package/dist/src/tui/operation-diagnostic-screens.js.map +1 -0
- package/dist/src/tui/operation-history.d.ts +81 -0
- package/dist/src/tui/operation-history.js +136 -0
- package/dist/src/tui/operation-history.js.map +1 -0
- package/dist/src/tui/operation-review-planner.d.ts +21 -0
- package/dist/src/tui/operation-review-planner.js +1392 -0
- package/dist/src/tui/operation-review-planner.js.map +1 -0
- package/dist/src/tui/plugin-content.d.ts +31 -0
- package/dist/src/tui/plugin-content.js +680 -0
- package/dist/src/tui/plugin-content.js.map +1 -0
- package/dist/src/tui/plugin-detail.d.ts +52 -0
- package/dist/src/tui/plugin-detail.js +165 -0
- package/dist/src/tui/plugin-detail.js.map +1 -0
- package/dist/src/tui/plugin-write-task.d.ts +69 -0
- package/dist/src/tui/plugin-write-task.js +286 -0
- package/dist/src/tui/plugin-write-task.js.map +1 -0
- package/dist/src/tui/project-inventory.d.ts +68 -0
- package/dist/src/tui/project-inventory.js +203 -0
- package/dist/src/tui/project-inventory.js.map +1 -0
- package/dist/src/tui/prompt.js +4 -15
- package/dist/src/tui/prompt.js.map +1 -1
- package/dist/src/tui/query-header.d.ts +30 -0
- package/dist/src/tui/query-header.js +40 -0
- package/dist/src/tui/query-header.js.map +1 -0
- package/dist/src/tui/reader.d.ts +37 -0
- package/dist/src/tui/reader.js +47 -0
- package/dist/src/tui/reader.js.map +1 -0
- package/dist/src/tui/router.d.ts +197 -10
- package/dist/src/tui/router.js +338 -50
- package/dist/src/tui/router.js.map +1 -1
- package/dist/src/tui/screen-registry.d.ts +701 -0
- package/dist/src/tui/screen-registry.js +230 -0
- package/dist/src/tui/screen-registry.js.map +1 -0
- package/dist/src/tui/session-console-app.d.ts +6 -0
- package/dist/src/tui/session-console-app.js +13 -0
- package/dist/src/tui/session-console-app.js.map +1 -0
- package/dist/src/tui/session-host.d.ts +45 -0
- package/dist/src/tui/session-host.js +209 -0
- package/dist/src/tui/session-host.js.map +1 -0
- package/dist/src/tui/source-detail-card.d.ts +29 -0
- package/dist/src/tui/source-detail-card.js +45 -0
- package/dist/src/tui/source-detail-card.js.map +1 -0
- package/dist/src/tui/source-ref-presets.d.ts +3 -0
- package/dist/src/tui/source-ref-presets.js +11 -0
- package/dist/src/tui/source-ref-presets.js.map +1 -0
- package/dist/src/tui/theme.d.ts +12 -0
- package/dist/src/tui/theme.js +12 -0
- package/dist/src/tui/theme.js.map +1 -1
- package/dist/src/tui/viewport.d.ts +1 -0
- package/dist/src/tui/viewport.js +23 -0
- package/dist/src/tui/viewport.js.map +1 -1
- package/dist/src/tui/views.js +31 -3
- package/dist/src/tui/views.js.map +1 -1
- package/dist/src/tui/wizard.js +37 -13
- package/dist/src/tui/wizard.js.map +1 -1
- package/dist/src/types.d.ts +264 -21
- package/dist/src/types.js +1 -0
- package/dist/src/types.js.map +1 -1
- package/dist/src/utils/agent-version.d.ts +7 -1
- package/dist/src/utils/agent-version.js +36 -7
- package/dist/src/utils/agent-version.js.map +1 -1
- package/dist/src/utils/artifact-plan.d.ts +8 -6
- package/dist/src/utils/artifact-plan.js +67 -13
- package/dist/src/utils/artifact-plan.js.map +1 -1
- package/dist/src/utils/artifact-renderer.d.ts +24 -10
- package/dist/src/utils/artifact-renderer.js +230 -220
- package/dist/src/utils/artifact-renderer.js.map +1 -1
- package/dist/src/utils/artifact-request.d.ts +32 -0
- package/dist/src/utils/artifact-request.js +90 -0
- package/dist/src/utils/artifact-request.js.map +1 -0
- package/dist/src/utils/artifact-sources.d.ts +4 -0
- package/dist/src/utils/artifact-sources.js +17 -0
- package/dist/src/utils/artifact-sources.js.map +1 -1
- package/dist/src/utils/aw-home-mutation-lock.d.ts +1 -0
- package/dist/src/utils/aw-home-mutation-lock.js +32 -4
- package/dist/src/utils/aw-home-mutation-lock.js.map +1 -1
- package/dist/src/utils/bundle-integrity.d.ts +0 -1
- package/dist/src/utils/bundle-integrity.js +0 -25
- package/dist/src/utils/bundle-integrity.js.map +1 -1
- package/dist/src/utils/bundle-layout.js +29 -29
- package/dist/src/utils/bundle-layout.js.map +1 -1
- package/dist/src/utils/catalog-capability-projection.d.ts +8 -0
- package/dist/src/utils/catalog-capability-projection.js +14 -0
- package/dist/src/utils/catalog-capability-projection.js.map +1 -0
- package/dist/src/utils/catalog-digests.d.ts +10 -0
- package/dist/src/utils/catalog-digests.js +57 -20
- package/dist/src/utils/catalog-digests.js.map +1 -1
- package/dist/src/utils/catalog-generation-control-snapshot.d.ts +11 -0
- package/dist/src/utils/catalog-generation-control-snapshot.js +45 -0
- package/dist/src/utils/catalog-generation-control-snapshot.js.map +1 -0
- package/dist/src/utils/catalog-generation-error.d.ts +16 -0
- package/dist/src/utils/catalog-generation-error.js +30 -0
- package/dist/src/utils/catalog-generation-error.js.map +1 -0
- package/dist/src/utils/catalog-generation-resolver.d.ts +44 -0
- package/dist/src/utils/catalog-generation-resolver.js +273 -0
- package/dist/src/utils/catalog-generation-resolver.js.map +1 -0
- package/dist/src/utils/catalog-generation-service.d.ts +172 -0
- package/dist/src/utils/catalog-generation-service.js +1271 -0
- package/dist/src/utils/catalog-generation-service.js.map +1 -0
- package/dist/src/utils/catalog-generation-state.d.ts +22 -0
- package/dist/src/utils/catalog-generation-state.js +192 -0
- package/dist/src/utils/catalog-generation-state.js.map +1 -0
- package/dist/src/utils/catalog-generation-store.d.ts +58 -0
- package/dist/src/utils/catalog-generation-store.js +452 -0
- package/dist/src/utils/catalog-generation-store.js.map +1 -0
- package/dist/src/utils/catalog-manifest-v7.d.ts +5 -0
- package/dist/src/utils/{catalog-manifest-v4.js → catalog-manifest-v7.js} +35 -43
- package/dist/src/utils/catalog-manifest-v7.js.map +1 -0
- package/dist/src/utils/catalog-operation-context.d.ts +20 -0
- package/dist/src/utils/catalog-operation-context.js +142 -0
- package/dist/src/utils/catalog-operation-context.js.map +1 -0
- package/dist/src/utils/catalog-public-error.d.ts +7 -3
- package/dist/src/utils/catalog-public-error.js +28 -8
- package/dist/src/utils/catalog-public-error.js.map +1 -1
- package/dist/src/utils/catalog-runtime-projection.d.ts +3 -0
- package/dist/src/utils/catalog-runtime-projection.js +5 -40
- package/dist/src/utils/catalog-runtime-projection.js.map +1 -1
- package/dist/src/utils/catalog-snapshot.d.ts +5 -3
- package/dist/src/utils/catalog-snapshot.js +11 -3
- package/dist/src/utils/catalog-snapshot.js.map +1 -1
- package/dist/src/utils/catalog-source-identity.d.ts +1 -0
- package/dist/src/utils/catalog-source-identity.js +21 -2
- package/dist/src/utils/catalog-source-identity.js.map +1 -1
- package/dist/src/utils/catalog-source-impact.d.ts +21 -0
- package/dist/src/utils/catalog-source-impact.js +344 -0
- package/dist/src/utils/catalog-source-impact.js.map +1 -0
- package/dist/src/utils/catalog-source-references.d.ts +3 -2
- package/dist/src/utils/catalog-source-references.js +195 -347
- package/dist/src/utils/catalog-source-references.js.map +1 -1
- package/dist/src/utils/catalog-sources.d.ts +15 -1
- package/dist/src/utils/catalog-sources.js +206 -27
- package/dist/src/utils/catalog-sources.js.map +1 -1
- package/dist/src/utils/claude-skills-root.d.ts +8 -0
- package/dist/src/utils/claude-skills-root.js +76 -0
- package/dist/src/utils/claude-skills-root.js.map +1 -0
- package/dist/src/utils/codex-config.d.ts +2 -0
- package/dist/src/utils/codex-config.js +26 -5
- package/dist/src/utils/codex-config.js.map +1 -1
- package/dist/src/utils/codex-manager.d.ts +79 -0
- package/dist/src/utils/codex-manager.js +735 -0
- package/dist/src/utils/codex-manager.js.map +1 -0
- package/dist/src/utils/codex-marketplace-path.d.ts +5 -0
- package/dist/src/utils/codex-marketplace-path.js +45 -0
- package/dist/src/utils/codex-marketplace-path.js.map +1 -0
- package/dist/src/utils/codex-native-observation.d.ts +49 -0
- package/dist/src/utils/codex-native-observation.js +154 -0
- package/dist/src/utils/codex-native-observation.js.map +1 -0
- package/dist/src/utils/codex-native-render-receipt.d.ts +40 -0
- package/dist/src/utils/codex-native-render-receipt.js +205 -0
- package/dist/src/utils/codex-native-render-receipt.js.map +1 -0
- package/dist/src/utils/codex-reconciler.d.ts +126 -0
- package/dist/src/utils/codex-reconciler.js +298 -0
- package/dist/src/utils/codex-reconciler.js.map +1 -0
- package/dist/src/utils/codex-shared-native.d.ts +43 -0
- package/dist/src/utils/codex-shared-native.js +81 -0
- package/dist/src/utils/codex-shared-native.js.map +1 -0
- package/dist/src/utils/codex-skill-staging.d.ts +2 -0
- package/dist/src/utils/codex-skill-staging.js.map +1 -1
- package/dist/src/utils/codex-skills-root.d.ts +4 -0
- package/dist/src/utils/codex-skills-root.js +25 -0
- package/dist/src/utils/codex-skills-root.js.map +1 -0
- package/dist/src/utils/codex-surface-analysis.d.ts +46 -0
- package/dist/src/utils/codex-surface-analysis.js +247 -0
- package/dist/src/utils/codex-surface-analysis.js.map +1 -0
- package/dist/src/utils/dynamic-skill-tree.d.ts +5 -0
- package/dist/src/utils/dynamic-skill-tree.js +56 -7
- package/dist/src/utils/dynamic-skill-tree.js.map +1 -1
- package/dist/src/utils/git-catalog-provider.d.ts +16 -0
- package/dist/src/utils/git-catalog-provider.js +177 -145
- package/dist/src/utils/git-catalog-provider.js.map +1 -1
- package/dist/src/utils/local-marketplace.d.ts +27 -1
- package/dist/src/utils/local-marketplace.js +434 -84
- package/dist/src/utils/local-marketplace.js.map +1 -1
- package/dist/src/utils/managed-command-closure.d.ts +3 -0
- package/dist/src/utils/managed-command-closure.js +35 -0
- package/dist/src/utils/managed-command-closure.js.map +1 -0
- package/dist/src/utils/managed-command-evidence.d.ts +7 -0
- package/dist/src/utils/managed-command-evidence.js +86 -0
- package/dist/src/utils/managed-command-evidence.js.map +1 -0
- package/dist/src/utils/managed-command-materialization.d.ts +115 -0
- package/dist/src/utils/managed-command-materialization.js +359 -0
- package/dist/src/utils/managed-command-materialization.js.map +1 -0
- package/dist/src/utils/managed-command-runtime.d.ts +33 -0
- package/dist/src/utils/managed-command-runtime.js +121 -0
- package/dist/src/utils/managed-command-runtime.js.map +1 -0
- package/dist/src/utils/managed-command-store.d.ts +128 -0
- package/dist/src/utils/managed-command-store.js +589 -0
- package/dist/src/utils/managed-command-store.js.map +1 -0
- package/dist/src/utils/manifest.d.ts +1 -3
- package/dist/src/utils/manifest.js +1 -3
- package/dist/src/utils/manifest.js.map +1 -1
- package/dist/src/utils/multi-source-catalog.d.ts +3 -9
- package/dist/src/utils/multi-source-catalog.js +54 -110
- package/dist/src/utils/multi-source-catalog.js.map +1 -1
- package/dist/src/utils/native-cli.d.ts +61 -7
- package/dist/src/utils/native-cli.js +426 -58
- package/dist/src/utils/native-cli.js.map +1 -1
- package/dist/src/utils/native-tool-context.d.ts +14 -0
- package/dist/src/utils/native-tool-context.js +38 -0
- package/dist/src/utils/native-tool-context.js.map +1 -0
- package/dist/src/utils/native-tool-review.d.ts +21 -0
- package/dist/src/utils/native-tool-review.js +102 -0
- package/dist/src/utils/native-tool-review.js.map +1 -0
- package/dist/src/utils/orphan-marketplace-cleanup.js +0 -4
- package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -1
- package/dist/src/utils/ownership.d.ts +88 -20
- package/dist/src/utils/ownership.js +185 -223
- package/dist/src/utils/ownership.js.map +1 -1
- package/dist/src/utils/path-catalog-provider.d.ts +1 -1
- package/dist/src/utils/path-catalog-provider.js +54 -65
- package/dist/src/utils/path-catalog-provider.js.map +1 -1
- package/dist/src/utils/paths.d.ts +0 -1
- package/dist/src/utils/paths.js +0 -1
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/src/utils/plugin-config-impact.d.ts +40 -0
- package/dist/src/utils/plugin-config-impact.js +373 -0
- package/dist/src/utils/plugin-config-impact.js.map +1 -0
- package/dist/src/utils/plugin-config-write.d.ts +52 -27
- package/dist/src/utils/plugin-config-write.js +1112 -298
- package/dist/src/utils/plugin-config-write.js.map +1 -1
- package/dist/src/utils/plugin-config.d.ts +153 -93
- package/dist/src/utils/plugin-config.js +1116 -968
- package/dist/src/utils/plugin-config.js.map +1 -1
- package/dist/src/utils/plugin-intent-state.d.ts +49 -0
- package/dist/src/utils/plugin-intent-state.js +320 -0
- package/dist/src/utils/plugin-intent-state.js.map +1 -0
- package/dist/src/utils/plugin-scripts.d.ts +66 -125
- package/dist/src/utils/plugin-scripts.js +518 -526
- package/dist/src/utils/plugin-scripts.js.map +1 -1
- package/dist/src/utils/process-lock.js +14 -5
- package/dist/src/utils/process-lock.js.map +1 -1
- package/dist/src/utils/process-tree.d.ts +2 -2
- package/dist/src/utils/process-tree.js +1 -1
- package/dist/src/utils/process-tree.js.map +1 -1
- package/dist/src/utils/project-boundary.d.ts +11 -13
- package/dist/src/utils/project-boundary.js +28 -34
- package/dist/src/utils/project-boundary.js.map +1 -1
- package/dist/src/utils/rendered-contract.js +18 -1
- package/dist/src/utils/rendered-contract.js.map +1 -1
- package/dist/src/utils/runtime-config.d.ts +20 -0
- package/dist/src/utils/runtime-config.js +75 -0
- package/dist/src/utils/runtime-config.js.map +1 -0
- package/dist/src/utils/runtime-skill-closure.js +47 -6
- package/dist/src/utils/runtime-skill-closure.js.map +1 -1
- package/dist/src/utils/safe-fs.d.ts +21 -0
- package/dist/src/utils/safe-fs.js +111 -0
- package/dist/src/utils/safe-fs.js.map +1 -0
- package/dist/src/utils/safe-operation-diagnostic.d.ts +15 -0
- package/dist/src/utils/safe-operation-diagnostic.js +33 -0
- package/dist/src/utils/safe-operation-diagnostic.js.map +1 -0
- package/dist/src/utils/sensitive-content.d.ts +4 -0
- package/dist/src/utils/sensitive-content.js +36 -0
- package/dist/src/utils/sensitive-content.js.map +1 -0
- package/dist/src/utils/state-paths.js +7 -2
- package/dist/src/utils/state-paths.js.map +1 -1
- package/dist/src/utils/target-eligibility.d.ts +8 -2
- package/dist/src/utils/target-eligibility.js +17 -8
- package/dist/src/utils/target-eligibility.js.map +1 -1
- package/dist/src/utils/windows-claude-shim.d.ts +7 -0
- package/dist/src/utils/windows-claude-shim.js +10 -0
- package/dist/src/utils/windows-claude-shim.js.map +1 -0
- package/dist/src/utils/windows-npm-shim.d.ts +14 -0
- package/dist/src/utils/windows-npm-shim.js +140 -0
- package/dist/src/utils/windows-npm-shim.js.map +1 -0
- package/dist/vitest.config.js +100 -9
- package/dist/vitest.config.js.map +1 -1
- package/package.json +31 -21
- package/dist/authoring/scripts/check-plugin-versions.d.mts +0 -2
- package/dist/authoring/scripts/check-plugin-versions.mjs +0 -5
- package/dist/authoring/scripts/check-plugin-versions.mjs.map +0 -1
- package/dist/scripts/aw-skill-eval-engine.d.ts +0 -13
- package/dist/scripts/aw-skill-eval-engine.js +0 -31
- package/dist/scripts/aw-skill-eval-engine.js.map +0 -1
- package/dist/scripts/codex-eval-app-server.d.ts +0 -89
- package/dist/scripts/codex-eval-app-server.js +0 -1228
- package/dist/scripts/codex-eval-app-server.js.map +0 -1
- package/dist/scripts/codex-eval-isolation.d.ts +0 -61
- package/dist/scripts/codex-eval-isolation.js +0 -318
- package/dist/scripts/codex-eval-isolation.js.map +0 -1
- package/dist/scripts/codex-eval-process-management.d.ts +0 -8
- package/dist/scripts/codex-eval-process-management.js +0 -69
- package/dist/scripts/codex-eval-process-management.js.map +0 -1
- package/dist/scripts/codex-eval-process-tree.d.ts +0 -38
- package/dist/scripts/codex-eval-process-tree.js +0 -803
- package/dist/scripts/codex-eval-process-tree.js.map +0 -1
- package/dist/scripts/codex-eval-runtime-config.d.ts +0 -62
- package/dist/scripts/codex-eval-runtime-config.js +0 -843
- package/dist/scripts/codex-eval-runtime-config.js.map +0 -1
- package/dist/scripts/codex-trigger-eval.d.ts +0 -84
- package/dist/scripts/codex-trigger-eval.js +0 -968
- package/dist/scripts/codex-trigger-eval.js.map +0 -1
- package/dist/scripts/eval-plugin-skills-audited.d.ts +0 -6
- package/dist/scripts/eval-plugin-skills-audited.js +0 -261
- package/dist/scripts/eval-plugin-skills-audited.js.map +0 -1
- package/dist/scripts/eval-plugin-skills.d.ts +0 -45
- package/dist/scripts/eval-plugin-skills.js +0 -1586
- package/dist/scripts/eval-plugin-skills.js.map +0 -1
- package/dist/scripts/eval-run-layout.d.ts +0 -17
- package/dist/scripts/eval-run-layout.js +0 -26
- package/dist/scripts/eval-run-layout.js.map +0 -1
- package/dist/scripts/plugin-eval-contract.d.ts +0 -185
- package/dist/scripts/plugin-eval-contract.js +0 -695
- package/dist/scripts/plugin-eval-contract.js.map +0 -1
- package/dist/scripts/plugin-eval-materializer.d.ts +0 -13
- package/dist/scripts/plugin-eval-materializer.js +0 -421
- package/dist/scripts/plugin-eval-materializer.js.map +0 -1
- package/dist/scripts/skill-reporting.d.ts +0 -212
- package/dist/scripts/skill-reporting.js +0 -922
- package/dist/scripts/skill-reporting.js.map +0 -1
- package/dist/src/commands/review-publication.d.ts +0 -99
- package/dist/src/commands/review-publication.js +0 -904
- package/dist/src/commands/review-publication.js.map +0 -1
- package/dist/src/commands/status-v4.d.ts +0 -123
- package/dist/src/commands/status-v4.js +0 -905
- package/dist/src/commands/status-v4.js.map +0 -1
- package/dist/src/commands/status.d.ts +0 -93
- package/dist/src/commands/status.js +0 -442
- package/dist/src/commands/status.js.map +0 -1
- package/dist/src/utils/active-marketplace-runtime-lock.d.ts +0 -12
- package/dist/src/utils/active-marketplace-runtime-lock.js +0 -133
- package/dist/src/utils/active-marketplace-runtime-lock.js.map +0 -1
- package/dist/src/utils/catalog-manifest-v3.d.ts +0 -2
- package/dist/src/utils/catalog-manifest-v3.js +0 -3
- package/dist/src/utils/catalog-manifest-v3.js.map +0 -1
- package/dist/src/utils/catalog-manifest-v4.d.ts +0 -5
- package/dist/src/utils/catalog-manifest-v4.js.map +0 -1
- package/dist/src/utils/catalog-source-cache.d.ts +0 -62
- package/dist/src/utils/catalog-source-cache.js +0 -296
- package/dist/src/utils/catalog-source-cache.js.map +0 -1
- package/dist/src/utils/codex-project-surface.d.ts +0 -3
- package/dist/src/utils/codex-project-surface.js +0 -49
- package/dist/src/utils/codex-project-surface.js.map +0 -1
- package/dist/src/utils/lifecycle-active-store.d.ts +0 -175
- package/dist/src/utils/lifecycle-active-store.js +0 -1276
- package/dist/src/utils/lifecycle-active-store.js.map +0 -1
- package/dist/src/utils/plugin-release.d.ts +0 -2
- package/dist/src/utils/plugin-release.js +0 -2
- package/dist/src/utils/plugin-release.js.map +0 -1
|
@@ -0,0 +1,685 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import { CATALOG_STORE_DIRECTORY } from '../constants.js';
|
|
5
|
+
import { withAwHomeMutationLock } from '../utils/aw-home-mutation-lock.js';
|
|
6
|
+
import { createCatalogStoreKey, readCatalogStoreEntry } from '../utils/catalog-generation-store.js';
|
|
7
|
+
import { catalogGenerationErrorCode } from '../utils/catalog-generation-error.js';
|
|
8
|
+
import { readCatalogGenerationState } from '../utils/catalog-generation-state.js';
|
|
9
|
+
import { readCatalogSourcesConfig } from '../utils/catalog-sources.js';
|
|
10
|
+
import { resolveAwHome } from '../utils/state-paths.js';
|
|
11
|
+
const FORMAL_RETENTION_MS = 30 * 24 * 60 * 60 * 1000;
|
|
12
|
+
const TEMP_RETENTION_MS = 24 * 60 * 60 * 1000;
|
|
13
|
+
const HEX_SEGMENT = /^[0-9a-f]{64}$/u;
|
|
14
|
+
const TEMP_SEGMENT = /^\.(staging|replacement|quarantine)-[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.tmp$/u;
|
|
15
|
+
const DELETE_CLAIM_SEGMENT = /^\.delete-[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\.tmp$/u;
|
|
16
|
+
function catalogStorePruneItemKey(item) {
|
|
17
|
+
return `${item.category}\u0000${item.storeKey}`;
|
|
18
|
+
}
|
|
19
|
+
const CATALOG_STORE_APPLICATION_ERROR_CODES = new Set([
|
|
20
|
+
'invalidArguments',
|
|
21
|
+
'catalogStoreInspectionFailed',
|
|
22
|
+
'catalogStoreDeleteFailed',
|
|
23
|
+
]);
|
|
24
|
+
export function catalogStoreErrorCode(error) {
|
|
25
|
+
const generationCode = catalogGenerationErrorCode(error);
|
|
26
|
+
if (generationCode !== 'catalogGenerationFailed')
|
|
27
|
+
return generationCode;
|
|
28
|
+
const explicitCode = error?.code;
|
|
29
|
+
return typeof explicitCode === 'string' && CATALOG_STORE_APPLICATION_ERROR_CODES.has(explicitCode)
|
|
30
|
+
? explicitCode
|
|
31
|
+
: 'catalogStoreInspectionFailed';
|
|
32
|
+
}
|
|
33
|
+
function opaqueForeignKey(parent, name) {
|
|
34
|
+
const digest = crypto.createHash('sha256').update(name).digest('hex').slice(0, 12);
|
|
35
|
+
return `${parent === '' ? '' : `${parent}/`}<foreign-${digest}>`;
|
|
36
|
+
}
|
|
37
|
+
async function inspectTree(root, nowMs) {
|
|
38
|
+
let newestMtimeMs = Number.NEGATIVE_INFINITY;
|
|
39
|
+
let bytes = 0;
|
|
40
|
+
let rootIdentity = null;
|
|
41
|
+
const pending = [root];
|
|
42
|
+
try {
|
|
43
|
+
while (pending.length > 0) {
|
|
44
|
+
const current = pending.pop();
|
|
45
|
+
const stat = await fs.lstat(current);
|
|
46
|
+
if (current === root)
|
|
47
|
+
rootIdentity = {
|
|
48
|
+
device: stat.dev,
|
|
49
|
+
inode: stat.ino,
|
|
50
|
+
mode: stat.mode,
|
|
51
|
+
birthtimeMs: stat.birthtimeMs,
|
|
52
|
+
};
|
|
53
|
+
newestMtimeMs = Math.max(newestMtimeMs, stat.mtimeMs);
|
|
54
|
+
if (stat.isSymbolicLink()) {
|
|
55
|
+
return { ageMs: null, bytes: null, safe: false, reason: 'unsafeSymlink', rootIdentity };
|
|
56
|
+
}
|
|
57
|
+
if (stat.isFile()) {
|
|
58
|
+
bytes += stat.size;
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (!stat.isDirectory()) {
|
|
62
|
+
return { ageMs: null, bytes: null, safe: false, reason: 'unsafeNode', rootIdentity };
|
|
63
|
+
}
|
|
64
|
+
const children = await fs.readdir(current);
|
|
65
|
+
for (const child of children)
|
|
66
|
+
pending.push(path.join(current, child));
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
ageMs: Math.max(0, nowMs - newestMtimeMs),
|
|
70
|
+
bytes,
|
|
71
|
+
safe: true,
|
|
72
|
+
rootIdentity,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return { ageMs: null, bytes: null, safe: false, reason: 'unreadable', rootIdentity };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async function readEntryIdentity(entryDir) {
|
|
80
|
+
try {
|
|
81
|
+
const value = await fs.readJson(path.join(entryDir, 'metadata.json'));
|
|
82
|
+
if (typeof value.logicalIdentity !== 'string'
|
|
83
|
+
|| typeof value.snapshotDigest !== 'string'
|
|
84
|
+
|| !/^sha256:[0-9a-f]{64}$/u.test(value.snapshotDigest))
|
|
85
|
+
return null;
|
|
86
|
+
return { logicalIdentity: value.logicalIdentity, snapshotDigest: value.snapshotDigest };
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function retainedEntry(options) {
|
|
93
|
+
return {
|
|
94
|
+
storeKey: options.storeKey,
|
|
95
|
+
category: options.category,
|
|
96
|
+
status: options.evidence.safe ? 'retained' : 'error',
|
|
97
|
+
generationReference: options.generationReference ?? 'none',
|
|
98
|
+
ageMs: options.evidence.ageMs,
|
|
99
|
+
reclaimableBytes: null,
|
|
100
|
+
reason: options.evidence.reason ?? options.reason,
|
|
101
|
+
absolutePath: options.absolutePath,
|
|
102
|
+
rootIdentity: options.evidence.rootIdentity,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
async function inspectFormalEntry(options) {
|
|
106
|
+
const storeKey = `${options.identitySegment}/${options.digestSegment}`;
|
|
107
|
+
const generationReference = options.activeKeys.has(storeKey)
|
|
108
|
+
? 'active'
|
|
109
|
+
: options.orphanKeys.has(storeKey) ? 'orphan' : 'none';
|
|
110
|
+
if (!options.evidence.safe)
|
|
111
|
+
return retainedEntry({
|
|
112
|
+
storeKey, category: 'entry', absolutePath: options.entryDir,
|
|
113
|
+
evidence: options.evidence, reason: 'unsafeEntry', generationReference,
|
|
114
|
+
});
|
|
115
|
+
const identity = await readEntryIdentity(options.entryDir);
|
|
116
|
+
if (!identity)
|
|
117
|
+
return retainedEntry({
|
|
118
|
+
storeKey, category: 'entry', absolutePath: options.entryDir,
|
|
119
|
+
evidence: options.evidence, reason: 'validationFailed', generationReference,
|
|
120
|
+
});
|
|
121
|
+
try {
|
|
122
|
+
if (createCatalogStoreKey(identity.logicalIdentity, identity.snapshotDigest) !== storeKey) {
|
|
123
|
+
throw new Error('store key mismatch');
|
|
124
|
+
}
|
|
125
|
+
await readCatalogStoreEntry({ ...identity, env: options.env });
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return retainedEntry({
|
|
129
|
+
storeKey, category: 'entry', absolutePath: options.entryDir,
|
|
130
|
+
evidence: options.evidence, reason: 'validationFailed', generationReference,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
if (options.activeKeys.has(storeKey))
|
|
134
|
+
return {
|
|
135
|
+
storeKey,
|
|
136
|
+
category: 'entry',
|
|
137
|
+
status: 'active',
|
|
138
|
+
generationReference,
|
|
139
|
+
ageMs: options.evidence.ageMs,
|
|
140
|
+
reclaimableBytes: null,
|
|
141
|
+
reason: 'active',
|
|
142
|
+
absolutePath: options.entryDir,
|
|
143
|
+
rootIdentity: options.evidence.rootIdentity,
|
|
144
|
+
};
|
|
145
|
+
const reclaimable = options.evidence.ageMs !== null && options.evidence.ageMs > FORMAL_RETENTION_MS;
|
|
146
|
+
return {
|
|
147
|
+
storeKey,
|
|
148
|
+
category: 'entry',
|
|
149
|
+
status: reclaimable ? 'reclaimable' : 'retained',
|
|
150
|
+
generationReference,
|
|
151
|
+
ageMs: options.evidence.ageMs,
|
|
152
|
+
reclaimableBytes: reclaimable ? options.evidence.bytes : null,
|
|
153
|
+
reason: reclaimable ? 'inactiveOlderThan30Days' : 'inactiveWithin30Days',
|
|
154
|
+
absolutePath: options.entryDir,
|
|
155
|
+
rootIdentity: options.evidence.rootIdentity,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
async function inspectTempEntry(options) {
|
|
159
|
+
const match = TEMP_SEGMENT.exec(options.name);
|
|
160
|
+
const category = match[1];
|
|
161
|
+
const storeKey = `${options.identitySegment}/${options.name}`;
|
|
162
|
+
const rootStat = await fs.lstat(options.entryDir).catch(() => null);
|
|
163
|
+
if (!rootStat?.isDirectory() || rootStat.isSymbolicLink())
|
|
164
|
+
return retainedEntry({
|
|
165
|
+
storeKey, category, absolutePath: options.entryDir,
|
|
166
|
+
evidence: { ...options.evidence, safe: false, reason: 'unsafeTemporaryRoot' },
|
|
167
|
+
reason: 'unsafeTemporaryRoot',
|
|
168
|
+
});
|
|
169
|
+
if (!options.evidence.safe)
|
|
170
|
+
return retainedEntry({
|
|
171
|
+
storeKey, category, absolutePath: options.entryDir,
|
|
172
|
+
evidence: options.evidence, reason: 'unsafeTemporaryEntry',
|
|
173
|
+
});
|
|
174
|
+
if (options.evidence.ageMs === null || options.evidence.ageMs <= TEMP_RETENTION_MS) {
|
|
175
|
+
return retainedEntry({
|
|
176
|
+
storeKey, category, absolutePath: options.entryDir,
|
|
177
|
+
evidence: options.evidence, reason: 'temporaryWithin24Hours',
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
if (category === 'quarantine') {
|
|
181
|
+
const identity = await readEntryIdentity(options.entryDir);
|
|
182
|
+
if (!identity)
|
|
183
|
+
return retainedEntry({
|
|
184
|
+
storeKey, category, absolutePath: options.entryDir,
|
|
185
|
+
evidence: options.evidence, reason: 'quarantineCanonicalUnknown',
|
|
186
|
+
});
|
|
187
|
+
try {
|
|
188
|
+
const canonicalKey = createCatalogStoreKey(identity.logicalIdentity, identity.snapshotDigest);
|
|
189
|
+
if (!canonicalKey.startsWith(`${options.identitySegment}/`))
|
|
190
|
+
throw new Error('identity mismatch');
|
|
191
|
+
await readCatalogStoreEntry({ ...identity, env: options.env });
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
return retainedEntry({
|
|
195
|
+
storeKey, category, absolutePath: options.entryDir,
|
|
196
|
+
evidence: options.evidence, reason: 'quarantineCanonicalUnhealthy',
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
storeKey,
|
|
202
|
+
category,
|
|
203
|
+
status: 'reclaimable',
|
|
204
|
+
generationReference: 'none',
|
|
205
|
+
ageMs: options.evidence.ageMs,
|
|
206
|
+
reclaimableBytes: options.evidence.bytes,
|
|
207
|
+
reason: 'temporaryOlderThan24Hours',
|
|
208
|
+
absolutePath: options.entryDir,
|
|
209
|
+
rootIdentity: options.evidence.rootIdentity,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
async function inspectDeleteClaim(options) {
|
|
213
|
+
const storeKey = `${options.identitySegment}/${options.name}`;
|
|
214
|
+
const rootStat = await fs.lstat(options.entryDir).catch(() => null);
|
|
215
|
+
if (!rootStat?.isDirectory() || rootStat.isSymbolicLink())
|
|
216
|
+
return retainedEntry({
|
|
217
|
+
storeKey, category: 'deleteClaim', absolutePath: options.entryDir,
|
|
218
|
+
evidence: { ...options.evidence, safe: false, reason: 'unsafeDeleteClaimRoot' },
|
|
219
|
+
reason: 'unsafeDeleteClaimRoot',
|
|
220
|
+
});
|
|
221
|
+
if (!options.evidence.safe)
|
|
222
|
+
return retainedEntry({
|
|
223
|
+
storeKey, category: 'deleteClaim', absolutePath: options.entryDir,
|
|
224
|
+
evidence: options.evidence, reason: 'unsafeDeleteClaim',
|
|
225
|
+
});
|
|
226
|
+
const reclaimable = options.evidence.ageMs !== null && options.evidence.ageMs > TEMP_RETENTION_MS;
|
|
227
|
+
return {
|
|
228
|
+
storeKey,
|
|
229
|
+
category: 'deleteClaim',
|
|
230
|
+
status: reclaimable ? 'reclaimable' : 'retained',
|
|
231
|
+
generationReference: 'none',
|
|
232
|
+
ageMs: options.evidence.ageMs,
|
|
233
|
+
reclaimableBytes: reclaimable ? options.evidence.bytes : null,
|
|
234
|
+
reason: reclaimable ? 'deleteClaimOlderThan24Hours' : 'deleteClaimWithin24Hours',
|
|
235
|
+
absolutePath: options.entryDir,
|
|
236
|
+
rootIdentity: options.evidence.rootIdentity,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
async function generationReferenceKeys(env) {
|
|
240
|
+
const [config, state] = await Promise.all([
|
|
241
|
+
readCatalogSourcesConfig(env),
|
|
242
|
+
readCatalogGenerationState(env),
|
|
243
|
+
]);
|
|
244
|
+
const configuredSourceIds = new Set(config.sources.map((source) => source.id));
|
|
245
|
+
const activeKeys = new Set();
|
|
246
|
+
const orphanKeys = new Set();
|
|
247
|
+
for (const [sourceId, source] of Object.entries(state.sources)) {
|
|
248
|
+
if (!source.active)
|
|
249
|
+
continue;
|
|
250
|
+
const storeKey = createCatalogStoreKey(source.active.logicalIdentity, source.active.snapshotDigest);
|
|
251
|
+
if (configuredSourceIds.has(sourceId))
|
|
252
|
+
activeKeys.add(storeKey);
|
|
253
|
+
else
|
|
254
|
+
orphanKeys.add(storeKey);
|
|
255
|
+
}
|
|
256
|
+
for (const storeKey of activeKeys)
|
|
257
|
+
orphanKeys.delete(storeKey);
|
|
258
|
+
return { activeKeys, orphanKeys };
|
|
259
|
+
}
|
|
260
|
+
async function reinspectCandidate(options) {
|
|
261
|
+
const identityDir = path.dirname(options.initial.absolutePath);
|
|
262
|
+
const storeRoot = path.dirname(identityDir);
|
|
263
|
+
const identitySegment = path.basename(identityDir);
|
|
264
|
+
const name = path.basename(options.initial.absolutePath);
|
|
265
|
+
const [storeRootStat, identityStat] = await Promise.all([
|
|
266
|
+
fs.lstat(storeRoot).catch(() => null),
|
|
267
|
+
fs.lstat(identityDir).catch(() => null),
|
|
268
|
+
]);
|
|
269
|
+
if (!storeRootStat?.isDirectory() || storeRootStat.isSymbolicLink()
|
|
270
|
+
|| !identityStat?.isDirectory() || identityStat.isSymbolicLink()
|
|
271
|
+
|| !HEX_SEGMENT.test(identitySegment)) {
|
|
272
|
+
return failedReinspectionEntry(options.initial);
|
|
273
|
+
}
|
|
274
|
+
const evidence = await inspectTree(options.initial.absolutePath, options.nowMs);
|
|
275
|
+
if (options.initial.category === 'entry')
|
|
276
|
+
return inspectFormalEntry({
|
|
277
|
+
identitySegment,
|
|
278
|
+
digestSegment: name,
|
|
279
|
+
entryDir: options.initial.absolutePath,
|
|
280
|
+
activeKeys: options.references.activeKeys,
|
|
281
|
+
orphanKeys: options.references.orphanKeys,
|
|
282
|
+
evidence,
|
|
283
|
+
env: options.env,
|
|
284
|
+
});
|
|
285
|
+
if (options.initial.category === 'deleteClaim')
|
|
286
|
+
return inspectDeleteClaim({
|
|
287
|
+
identitySegment,
|
|
288
|
+
name,
|
|
289
|
+
entryDir: options.initial.absolutePath,
|
|
290
|
+
evidence,
|
|
291
|
+
});
|
|
292
|
+
return inspectTempEntry({
|
|
293
|
+
identitySegment,
|
|
294
|
+
name,
|
|
295
|
+
entryDir: options.initial.absolutePath,
|
|
296
|
+
evidence,
|
|
297
|
+
env: options.env,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
async function inspectCatalogStore(options) {
|
|
301
|
+
const { activeKeys, orphanKeys } = await generationReferenceKeys(options.env);
|
|
302
|
+
const storeRoot = path.join(resolveAwHome(options.env), CATALOG_STORE_DIRECTORY);
|
|
303
|
+
const rootStat = await fs.lstat(storeRoot).catch((error) => {
|
|
304
|
+
if (error.code === 'ENOENT')
|
|
305
|
+
return null;
|
|
306
|
+
throw error;
|
|
307
|
+
});
|
|
308
|
+
if (!rootStat)
|
|
309
|
+
return [];
|
|
310
|
+
if (!rootStat.isDirectory() || rootStat.isSymbolicLink()) {
|
|
311
|
+
return [retainedEntry({
|
|
312
|
+
storeKey: '.', category: 'foreign', absolutePath: storeRoot,
|
|
313
|
+
evidence: {
|
|
314
|
+
ageMs: null, bytes: null, safe: false, reason: 'unsafeStoreRoot', rootIdentity: null,
|
|
315
|
+
},
|
|
316
|
+
reason: 'unsafeStoreRoot',
|
|
317
|
+
})];
|
|
318
|
+
}
|
|
319
|
+
const entries = [];
|
|
320
|
+
const identityNames = await fs.readdir(storeRoot).then((names) => names.sort());
|
|
321
|
+
for (const identityName of identityNames) {
|
|
322
|
+
const identityDir = path.join(storeRoot, identityName);
|
|
323
|
+
const identityStat = await fs.lstat(identityDir).catch(() => null);
|
|
324
|
+
if (!HEX_SEGMENT.test(identityName) || !identityStat?.isDirectory() || identityStat.isSymbolicLink()) {
|
|
325
|
+
const evidence = await inspectTree(identityDir, options.nowMs);
|
|
326
|
+
entries.push(retainedEntry({
|
|
327
|
+
storeKey: opaqueForeignKey('', identityName), category: 'foreign', absolutePath: identityDir,
|
|
328
|
+
evidence, reason: 'unrecognizedIdentityNode',
|
|
329
|
+
}));
|
|
330
|
+
continue;
|
|
331
|
+
}
|
|
332
|
+
const childNames = await fs.readdir(identityDir).then((names) => names.sort()).catch(() => null);
|
|
333
|
+
if (!childNames) {
|
|
334
|
+
entries.push(retainedEntry({
|
|
335
|
+
storeKey: `${identityName}/<unreadable>`, category: 'foreign', absolutePath: identityDir,
|
|
336
|
+
evidence: {
|
|
337
|
+
ageMs: null,
|
|
338
|
+
bytes: null,
|
|
339
|
+
safe: false,
|
|
340
|
+
reason: 'unreadableIdentityDirectory',
|
|
341
|
+
rootIdentity: identityStat ? {
|
|
342
|
+
device: identityStat.dev,
|
|
343
|
+
inode: identityStat.ino,
|
|
344
|
+
mode: identityStat.mode,
|
|
345
|
+
birthtimeMs: identityStat.birthtimeMs,
|
|
346
|
+
} : null,
|
|
347
|
+
},
|
|
348
|
+
reason: 'unreadableIdentityDirectory',
|
|
349
|
+
}));
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
352
|
+
for (const childName of childNames) {
|
|
353
|
+
const entryDir = path.join(identityDir, childName);
|
|
354
|
+
const evidence = await inspectTree(entryDir, options.nowMs);
|
|
355
|
+
if (HEX_SEGMENT.test(childName)) {
|
|
356
|
+
entries.push(await inspectFormalEntry({
|
|
357
|
+
identitySegment: identityName,
|
|
358
|
+
digestSegment: childName,
|
|
359
|
+
entryDir,
|
|
360
|
+
activeKeys,
|
|
361
|
+
orphanKeys,
|
|
362
|
+
evidence,
|
|
363
|
+
env: options.env,
|
|
364
|
+
}));
|
|
365
|
+
}
|
|
366
|
+
else if (TEMP_SEGMENT.test(childName)) {
|
|
367
|
+
entries.push(await inspectTempEntry({
|
|
368
|
+
identitySegment: identityName,
|
|
369
|
+
name: childName,
|
|
370
|
+
entryDir,
|
|
371
|
+
evidence,
|
|
372
|
+
env: options.env,
|
|
373
|
+
}));
|
|
374
|
+
}
|
|
375
|
+
else if (DELETE_CLAIM_SEGMENT.test(childName)) {
|
|
376
|
+
entries.push(await inspectDeleteClaim({
|
|
377
|
+
identitySegment: identityName,
|
|
378
|
+
name: childName,
|
|
379
|
+
entryDir,
|
|
380
|
+
evidence,
|
|
381
|
+
}));
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
entries.push(retainedEntry({
|
|
385
|
+
storeKey: opaqueForeignKey(identityName, childName), category: 'foreign', absolutePath: entryDir,
|
|
386
|
+
evidence, reason: 'unrecognizedStoreNode',
|
|
387
|
+
}));
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
return entries;
|
|
392
|
+
}
|
|
393
|
+
function publicEntries(entries) {
|
|
394
|
+
return entries.map(({ absolutePath: _absolutePath, rootIdentity: _rootIdentity, ...entry }) => entry);
|
|
395
|
+
}
|
|
396
|
+
function reclaimableTotal(entries) {
|
|
397
|
+
if (entries.some((entry) => entry.status === 'error'))
|
|
398
|
+
return null;
|
|
399
|
+
const reclaimable = entries.filter((entry) => entry.status === 'reclaimable');
|
|
400
|
+
if (reclaimable.some((entry) => entry.reclaimableBytes === null))
|
|
401
|
+
return null;
|
|
402
|
+
return reclaimable.reduce((sum, entry) => sum + entry.reclaimableBytes, 0);
|
|
403
|
+
}
|
|
404
|
+
function inspectionErrors(entries) {
|
|
405
|
+
return entries
|
|
406
|
+
.filter((entry) => entry.status === 'error')
|
|
407
|
+
.map((entry) => ({
|
|
408
|
+
storeKey: entry.storeKey,
|
|
409
|
+
code: 'catalogStoreInspectionFailed',
|
|
410
|
+
message: `Could not fully inspect Catalog store item ${entry.storeKey}: ${entry.reason}.`,
|
|
411
|
+
}));
|
|
412
|
+
}
|
|
413
|
+
function sameNodeIdentity(left, right) {
|
|
414
|
+
return left !== null
|
|
415
|
+
&& right !== null
|
|
416
|
+
&& left.device === right.device
|
|
417
|
+
&& left.inode === right.inode
|
|
418
|
+
&& left.mode === right.mode
|
|
419
|
+
&& Object.is(left.birthtimeMs, right.birthtimeMs);
|
|
420
|
+
}
|
|
421
|
+
function sameDeletionEvidence(initial, current) {
|
|
422
|
+
return current.status === 'reclaimable'
|
|
423
|
+
&& current.storeKey === initial.storeKey
|
|
424
|
+
&& current.category === initial.category
|
|
425
|
+
&& current.generationReference === initial.generationReference
|
|
426
|
+
&& current.absolutePath === initial.absolutePath
|
|
427
|
+
&& current.ageMs === initial.ageMs
|
|
428
|
+
&& current.reclaimableBytes === initial.reclaimableBytes
|
|
429
|
+
&& current.reason === initial.reason
|
|
430
|
+
&& sameNodeIdentity(current.rootIdentity, initial.rootIdentity);
|
|
431
|
+
}
|
|
432
|
+
function staleInspectionEntry(initial, current) {
|
|
433
|
+
if (current?.status === 'active' || current?.status === 'error')
|
|
434
|
+
return current;
|
|
435
|
+
return {
|
|
436
|
+
...(current ?? initial),
|
|
437
|
+
status: 'retained',
|
|
438
|
+
ageMs: current?.ageMs ?? null,
|
|
439
|
+
reclaimableBytes: null,
|
|
440
|
+
reason: 'staleBeforeDelete',
|
|
441
|
+
rootIdentity: current?.rootIdentity ?? null,
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
function failedReinspectionEntry(initial) {
|
|
445
|
+
return {
|
|
446
|
+
...initial,
|
|
447
|
+
status: 'error',
|
|
448
|
+
ageMs: null,
|
|
449
|
+
reclaimableBytes: null,
|
|
450
|
+
reason: 'reinspectionFailed',
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
async function readNodeIdentity(target) {
|
|
454
|
+
const stat = await fs.lstat(target).catch(() => null);
|
|
455
|
+
if (!stat)
|
|
456
|
+
return null;
|
|
457
|
+
return {
|
|
458
|
+
device: stat.dev,
|
|
459
|
+
inode: stat.ino,
|
|
460
|
+
mode: stat.mode,
|
|
461
|
+
birthtimeMs: stat.birthtimeMs,
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
async function readDirectoryIdentity(target) {
|
|
465
|
+
const stat = await fs.lstat(target).catch(() => null);
|
|
466
|
+
if (!stat?.isDirectory() || stat.isSymbolicLink())
|
|
467
|
+
return null;
|
|
468
|
+
return {
|
|
469
|
+
device: stat.dev,
|
|
470
|
+
inode: stat.ino,
|
|
471
|
+
mode: stat.mode,
|
|
472
|
+
birthtimeMs: stat.birthtimeMs,
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
async function restoreStaleClaim(claimPath, originalPath) {
|
|
476
|
+
const originalExists = await fs.lstat(originalPath)
|
|
477
|
+
.then(() => true)
|
|
478
|
+
.catch(() => false);
|
|
479
|
+
if (originalExists)
|
|
480
|
+
return false;
|
|
481
|
+
return fs.rename(claimPath, originalPath)
|
|
482
|
+
.then(() => true)
|
|
483
|
+
.catch(() => false);
|
|
484
|
+
}
|
|
485
|
+
async function inspectDeleteClaimAfterFailure(options) {
|
|
486
|
+
const exists = await fs.lstat(options.claimPath)
|
|
487
|
+
.then(() => true)
|
|
488
|
+
.catch((error) => error.code === 'ENOENT' ? false : true);
|
|
489
|
+
if (!exists)
|
|
490
|
+
return null;
|
|
491
|
+
return inspectDeleteClaim({
|
|
492
|
+
identitySegment: path.basename(path.dirname(options.claimPath)),
|
|
493
|
+
name: path.basename(options.claimPath),
|
|
494
|
+
entryDir: options.claimPath,
|
|
495
|
+
evidence: await inspectTree(options.claimPath, options.nowMs),
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
export async function catalogStoreStatus(options = {}) {
|
|
499
|
+
const entries = publicEntries(await inspectCatalogStore({
|
|
500
|
+
env: options.env ?? process.env,
|
|
501
|
+
nowMs: (options.now ?? new Date()).getTime(),
|
|
502
|
+
}));
|
|
503
|
+
const errors = inspectionErrors(entries);
|
|
504
|
+
return {
|
|
505
|
+
catalogStoreSchemaVersion: 2,
|
|
506
|
+
command: 'catalog:store:status',
|
|
507
|
+
ok: errors.length === 0,
|
|
508
|
+
entries,
|
|
509
|
+
totals: {
|
|
510
|
+
entries: entries.length,
|
|
511
|
+
reclaimableEntries: entries.filter((entry) => entry.status === 'reclaimable').length,
|
|
512
|
+
reclaimableBytes: reclaimableTotal(entries),
|
|
513
|
+
},
|
|
514
|
+
errors,
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
async function executePrune(options) {
|
|
518
|
+
const inspected = await inspectCatalogStore({ env: options.env, nowMs: options.nowMs });
|
|
519
|
+
const deleted = [];
|
|
520
|
+
const deleteErrors = [];
|
|
521
|
+
const retainedAfterError = new Set();
|
|
522
|
+
const retainedReasons = new Map();
|
|
523
|
+
const authorizedItemKeys = options.authorizedItems === undefined
|
|
524
|
+
? undefined
|
|
525
|
+
: new Set(options.authorizedItems.map(catalogStorePruneItemKey));
|
|
526
|
+
const unauthorizedReclaimable = new Set();
|
|
527
|
+
if (!options.dryRun) {
|
|
528
|
+
for (const entry of inspected) {
|
|
529
|
+
if (entry.status === 'reclaimable'
|
|
530
|
+
&& authorizedItemKeys !== undefined
|
|
531
|
+
&& !authorizedItemKeys.has(catalogStorePruneItemKey(entry))) {
|
|
532
|
+
unauthorizedReclaimable.add(catalogStorePruneItemKey(entry));
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
const candidates = inspected
|
|
536
|
+
.map((entry, index) => ({ entry, index }))
|
|
537
|
+
.filter(({ entry }) => entry.status === 'reclaimable'
|
|
538
|
+
&& (authorizedItemKeys === undefined
|
|
539
|
+
|| authorizedItemKeys.has(catalogStorePruneItemKey(entry))));
|
|
540
|
+
await options.runtime?.afterInitialInspection?.(publicEntries(inspected));
|
|
541
|
+
for (const { entry: initial, index } of candidates) {
|
|
542
|
+
let current;
|
|
543
|
+
try {
|
|
544
|
+
const references = await generationReferenceKeys(options.env);
|
|
545
|
+
current = await reinspectCandidate({
|
|
546
|
+
initial,
|
|
547
|
+
references,
|
|
548
|
+
env: options.env,
|
|
549
|
+
nowMs: options.nowMs,
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
catch {
|
|
553
|
+
inspected[index] = failedReinspectionEntry(initial);
|
|
554
|
+
retainedReasons.set(initial.storeKey, 'reinspectionFailed');
|
|
555
|
+
continue;
|
|
556
|
+
}
|
|
557
|
+
if (!current || !sameDeletionEvidence(initial, current)) {
|
|
558
|
+
inspected[index] = staleInspectionEntry(initial, current);
|
|
559
|
+
retainedReasons.set(initial.storeKey, current?.status === 'active'
|
|
560
|
+
? 'active'
|
|
561
|
+
: current?.status === 'error' ? current.reason : 'staleBeforeDelete');
|
|
562
|
+
continue;
|
|
563
|
+
}
|
|
564
|
+
inspected[index] = current;
|
|
565
|
+
const parentPath = path.dirname(current.absolutePath);
|
|
566
|
+
const parentIdentity = await readDirectoryIdentity(parentPath);
|
|
567
|
+
if (!parentIdentity) {
|
|
568
|
+
inspected[index] = staleInspectionEntry(initial, current);
|
|
569
|
+
retainedReasons.set(initial.storeKey, 'staleBeforeDelete');
|
|
570
|
+
continue;
|
|
571
|
+
}
|
|
572
|
+
const claimPath = path.join(parentPath, `.delete-${crypto.randomUUID()}.tmp`);
|
|
573
|
+
try {
|
|
574
|
+
await fs.rename(current.absolutePath, claimPath);
|
|
575
|
+
}
|
|
576
|
+
catch {
|
|
577
|
+
inspected[index] = staleInspectionEntry(initial, current);
|
|
578
|
+
retainedReasons.set(initial.storeKey, 'staleBeforeDelete');
|
|
579
|
+
continue;
|
|
580
|
+
}
|
|
581
|
+
try {
|
|
582
|
+
const claimTime = new Date(options.nowMs);
|
|
583
|
+
if (options.runtime?.updateDeleteClaimTime) {
|
|
584
|
+
await options.runtime.updateDeleteClaimTime(claimPath, claimTime);
|
|
585
|
+
}
|
|
586
|
+
else {
|
|
587
|
+
await fs.utimes(claimPath, claimTime, claimTime);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
catch {
|
|
591
|
+
const restored = await restoreStaleClaim(claimPath, current.absolutePath);
|
|
592
|
+
if (restored) {
|
|
593
|
+
inspected[index] = staleInspectionEntry(initial, current);
|
|
594
|
+
retainedReasons.set(initial.storeKey, 'staleBeforeDelete');
|
|
595
|
+
}
|
|
596
|
+
else {
|
|
597
|
+
const failedClaim = await inspectDeleteClaimAfterFailure({
|
|
598
|
+
claimPath,
|
|
599
|
+
nowMs: options.nowMs,
|
|
600
|
+
});
|
|
601
|
+
inspected[index] = staleInspectionEntry(initial, failedClaim ?? undefined);
|
|
602
|
+
retainedReasons.set(inspected[index].storeKey, 'staleBeforeDelete');
|
|
603
|
+
}
|
|
604
|
+
continue;
|
|
605
|
+
}
|
|
606
|
+
await options.runtime?.afterDeleteClaim?.({ storeKey: initial.storeKey, claimPath });
|
|
607
|
+
const [claimedIdentity, currentParentIdentity] = await Promise.all([
|
|
608
|
+
readNodeIdentity(claimPath),
|
|
609
|
+
readDirectoryIdentity(parentPath),
|
|
610
|
+
]);
|
|
611
|
+
if (!sameNodeIdentity(current.rootIdentity, claimedIdentity)
|
|
612
|
+
|| !sameNodeIdentity(parentIdentity, currentParentIdentity)) {
|
|
613
|
+
await restoreStaleClaim(claimPath, current.absolutePath);
|
|
614
|
+
inspected[index] = staleInspectionEntry(initial, current);
|
|
615
|
+
retainedReasons.set(initial.storeKey, 'staleBeforeDelete');
|
|
616
|
+
continue;
|
|
617
|
+
}
|
|
618
|
+
try {
|
|
619
|
+
await options.remove(claimPath);
|
|
620
|
+
deleted.push({ storeKey: initial.storeKey, bytes: current.reclaimableBytes });
|
|
621
|
+
}
|
|
622
|
+
catch {
|
|
623
|
+
const failedClaim = await inspectDeleteClaimAfterFailure({
|
|
624
|
+
claimPath,
|
|
625
|
+
nowMs: options.nowMs,
|
|
626
|
+
});
|
|
627
|
+
if (!failedClaim) {
|
|
628
|
+
deleted.push({ storeKey: initial.storeKey, bytes: current.reclaimableBytes });
|
|
629
|
+
continue;
|
|
630
|
+
}
|
|
631
|
+
inspected[index] = failedClaim;
|
|
632
|
+
retainedAfterError.add(failedClaim.storeKey);
|
|
633
|
+
deleteErrors.push({
|
|
634
|
+
storeKey: failedClaim.storeKey,
|
|
635
|
+
code: 'catalogStoreDeleteFailed',
|
|
636
|
+
message: `Could not safely complete deletion of Catalog store item ${failedClaim.storeKey}. Retry prune.`,
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
const entries = publicEntries(inspected);
|
|
642
|
+
const errors = [...inspectionErrors(entries), ...deleteErrors];
|
|
643
|
+
const deletedKeys = new Set(deleted.map((entry) => entry.storeKey));
|
|
644
|
+
const retained = entries
|
|
645
|
+
.filter((entry) => !deletedKeys.has(entry.storeKey)
|
|
646
|
+
&& (options.dryRun
|
|
647
|
+
|| entry.status !== 'reclaimable'
|
|
648
|
+
|| unauthorizedReclaimable.has(catalogStorePruneItemKey(entry))
|
|
649
|
+
|| retainedAfterError.has(entry.storeKey)
|
|
650
|
+
|| retainedReasons.has(entry.storeKey)))
|
|
651
|
+
.map((entry) => ({
|
|
652
|
+
storeKey: entry.storeKey,
|
|
653
|
+
reason: retainedReasons.get(entry.storeKey) ?? entry.reason,
|
|
654
|
+
}));
|
|
655
|
+
return {
|
|
656
|
+
catalogStoreSchemaVersion: 2,
|
|
657
|
+
command: 'catalog:store:prune',
|
|
658
|
+
ok: errors.length === 0,
|
|
659
|
+
overallState: errors.length === 0 ? 'succeeded' : 'partial',
|
|
660
|
+
dryRun: options.dryRun,
|
|
661
|
+
entries,
|
|
662
|
+
deleted,
|
|
663
|
+
retained,
|
|
664
|
+
errors,
|
|
665
|
+
reclaimableBytes: reclaimableTotal(entries),
|
|
666
|
+
deletedBytes: deleted.reduce((sum, entry) => sum + entry.bytes, 0),
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
export async function catalogStorePrune(options = {}) {
|
|
670
|
+
const env = options.env ?? process.env;
|
|
671
|
+
const nowMs = (options.now ?? new Date()).getTime();
|
|
672
|
+
const dryRun = options.dryRun !== false;
|
|
673
|
+
const action = () => executePrune({
|
|
674
|
+
env,
|
|
675
|
+
nowMs,
|
|
676
|
+
dryRun,
|
|
677
|
+
authorizedItems: options.authorizedItems,
|
|
678
|
+
remove: options.remove ?? ((target) => fs.remove(target)),
|
|
679
|
+
runtime: options.runtime,
|
|
680
|
+
});
|
|
681
|
+
if (dryRun)
|
|
682
|
+
return action();
|
|
683
|
+
return withAwHomeMutationLock({ env, action });
|
|
684
|
+
}
|
|
685
|
+
//# sourceMappingURL=catalog-store.js.map
|