@paradigma-inc/flywheel 0.1.115 → 0.1.134
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 +67 -10
- package/package.json +14 -6
- package/skills/flywheel/SKILL.md +9 -6
- package/skills/flywheel/example-workflows/organizing-exploring-and-iterating-on-a-research-topic.md +38 -46
- package/skills/flywheel/example-workflows/reproducing-papers-on-a-budget.md +34 -36
- package/skills/flywheel/getting-started/flywheel-quickstart.md +2 -5
- package/skills/flywheel/references/INTERFACES.md +2 -2
- package/skills/flywheel/references/experiment-design-protocol.md +32 -25
- package/skills/flywheel/references/flywheel-cli-tool-map.md +120 -76
- package/skills/flywheel/references/flywheel-mcp-tool-map.md +42 -32
- package/skills/flywheel/setting-up-flywheel/claude-code-cli-installation.md +1 -1
- package/skills/flywheel/setting-up-flywheel/codex-cli-installation.md +1 -1
- package/skills/flywheel/setting-up-flywheel/installation-overview.md +2 -6
- package/skills/flywheel/setting-up-flywheel/other-hosts-installation.md +45 -25
- package/skills/flywheel/setting-up-flywheel/updating-flywheel-mcp.md +34 -11
- package/skills/flywheel-auto/SKILL.md +40 -23
- package/skills/flywheel-auto/evals/evals.json +1 -1
- package/skills/flywheel-auto/references/INTERFACES.md +2 -2
- package/skills/flywheel-auto/references/experiment-design-protocol.md +31 -23
- package/skills/flywheel-auto/references/flywheel-cli-tool-map.md +172 -127
- package/skills/flywheel-auto/references/flywheel-mcp-tool-map.md +22 -24
- package/skills/flywheel-lookahead/SKILL.md +47 -28
- package/skills/flywheel-lookahead/agents/openai.yaml +1 -1
- package/skills/flywheel-lookahead/evals/evals.json +6 -6
- package/skills/flywheel-lookahead/references/INTERFACES.md +2 -2
- package/skills/flywheel-lookahead/references/flywheel-cli-tool-map.md +172 -127
- package/skills/flywheel-lookahead/references/flywheel-mcp-tool-map.md +22 -24
- package/skills/flywheel-prove/SKILL.md +2 -2
- package/skills/flywheel-prove/references/workflow.md +21 -2
- package/skills/flywheel-reproduce/SKILL.md +39 -19
- package/skills/flywheel-reproduce/evals/evals.json +1 -1
- package/skills/flywheel-reproduce/references/INTERFACES.md +2 -2
- package/skills/flywheel-reproduce/references/experiment-design-protocol.md +31 -23
- package/skills/flywheel-reproduce/references/flywheel-cli-tool-map.md +172 -127
- package/skills/flywheel-reproduce/references/flywheel-mcp-tool-map.md +22 -24
- package/skills/flywheel-to-graph/SKILL.md +37 -17
- package/skills/flywheel-to-graph/references/INTERFACES.md +2 -2
- package/skills/flywheel-to-graph/references/flywheel-cli-tool-map.md +172 -127
- package/skills/flywheel-to-graph/references/flywheel-mcp-tool-map.md +22 -24
- package/skills/flywheel-tree/references/workflow.md +6 -37
- package/src/cli.mjs +1145 -1141
- package/src/mcp-writer.mjs +413 -435
- package/src/public-command-metadata.mjs +28 -5
- package/src/runtime/delegate.mjs +2 -19
- package/src/runtime/required-runtime-commands.json +80 -28
- package/src/runtime/runtime-config.mjs +39 -60
- package/src/runtime/vendor/flywheel-cli-dist/auth/credentials.js +330 -0
- package/src/runtime/vendor/flywheel-cli-dist/auth/credentials.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/auth/login.js +90 -139
- package/src/runtime/vendor/flywheel-cli-dist/auth/login.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/auth/profiles.js +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/auth/profiles.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/auth/secure-write.js +116 -0
- package/src/runtime/vendor/flywheel-cli-dist/auth/secure-write.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-create.js +248 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-create.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-login.js +65 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-login.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-revoke-api-key.js +17 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-revoke-api-key.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/aliases.js +3 -7
- package/src/runtime/vendor/flywheel-cli-dist/commands/aliases.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-clear.js +12 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-clear.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-set.js +29 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/auth-credentials-set.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/auth-login.js +12 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/auth-login.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/auth-status.js +46 -10
- package/src/runtime/vendor/flywheel-cli-dist/commands/auth-status.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/env.js +17 -40
- package/src/runtime/vendor/flywheel-cli-dist/commands/env.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-resources.js +305 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-resources.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-support.js +72 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation-support.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation.js +286 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/graph-operation.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/help-metadata.js +30 -5
- package/src/runtime/vendor/flywheel-cli-dist/commands/help-metadata.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/help.js +27 -12
- package/src/runtime/vendor/flywheel-cli-dist/commands/help.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-commit-replay.js +284 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-commit-replay.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-graph.js +169 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-graph.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-lineage-list.js +13 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-lineage-list.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-repository-snapshot.js +227 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/hosted-repository-snapshot.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/index.js +21 -51
- package/src/runtime/vendor/flywheel-cli-dist/commands/index.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/node-create-schema.js +25 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/node-create-schema.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/profile-list.js +11 -9
- package/src/runtime/vendor/flywheel-cli-dist/commands/profile-list.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/profile-set.js +38 -45
- package/src/runtime/vendor/flywheel-cli-dist/commands/profile-set.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/profile-show.js +14 -17
- package/src/runtime/vendor/flywheel-cli-dist/commands/profile-show.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/profile-unset.js +13 -8
- package/src/runtime/vendor/flywheel-cli-dist/commands/profile-unset.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/admin.js +34 -3
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/admin.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/auth.js +9 -9
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/auth.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/hosted.js +76 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/hosted.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/lifecycle.js +4 -138
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/lifecycle.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/profile.js +8 -13
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/profile.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/repository.js +362 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/repository.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry.js +45 -183
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/repository-edit.js +47 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/repository-edit.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/repository-operation.js +181 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/repository-operation.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/repository-output.js +163 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/repository-output.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/repository-projection.js +79 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/repository-projection.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/repository-selection.js +80 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/repository-selection.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/retired-command-names.js +78 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/retired-command-names.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/commands/types.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/usage-spec.js +3 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/usage-spec.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/config/index.js +5 -0
- package/src/runtime/vendor/flywheel-cli-dist/config/index.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/config/io.js +139 -0
- package/src/runtime/vendor/flywheel-cli-dist/config/io.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/config/migration.js +299 -0
- package/src/runtime/vendor/flywheel-cli-dist/config/migration.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/config/model.js +214 -0
- package/src/runtime/vendor/flywheel-cli-dist/config/model.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/config/path.js +30 -0
- package/src/runtime/vendor/flywheel-cli-dist/config/path.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/credential-output.js +29 -0
- package/src/runtime/vendor/flywheel-cli-dist/credential-output.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/errors.js +1 -16
- package/src/runtime/vendor/flywheel-cli-dist/errors.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/generatedProductTelemetryContract.js +3 -3
- package/src/runtime/vendor/flywheel-cli-dist/generatedProductTelemetryContract.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/grammar/globals.js +19 -9
- package/src/runtime/vendor/flywheel-cli-dist/grammar/globals.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/grammar/parse.js +33 -4
- package/src/runtime/vendor/flywheel-cli-dist/grammar/parse.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/http/client.js +322 -304
- package/src/runtime/vendor/flywheel-cli-dist/http/client.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/http/debug.js +1 -21
- package/src/runtime/vendor/flywheel-cli-dist/http/debug.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/http/retry.js +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/http/retry.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/local/adapter.js +244 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/adapter.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/errors.js +7 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/errors.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/history.js +35 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/history.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/invariants.js +42 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/invariants.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/artifact-properties.js +179 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/artifact-properties.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/commits.js +152 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/commits.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/constants.js +71 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/constants.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/encoding.js +73 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/encoding.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/imported-artifact-properties.js +82 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/imported-artifact-properties.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/operations.js +345 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/operations.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/tags.js +57 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/models/tags.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/conflicts.js +149 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/conflicts.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/context.js +115 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/context.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/keys.js +44 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/keys.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pull.js +159 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/pull.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/replay.js +346 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/replay.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/resolve.js +37 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/rebase/resolve.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/inverses.js +203 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/inverses.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/plan.js +207 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/plan.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/tag-inverses.js +109 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/revert/tag-inverses.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/commit.js +61 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/commit.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/projection.js +46 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/projection.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/revert.js +203 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/revert.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/staging.js +44 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/staging.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/writes.js +188 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/service/writes.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/cursors.js +54 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/cursors.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/local-pull.js +25 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync/local-pull.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync-models.js +2 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/domain/sync-models.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/fs/native.js +7 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/fs/native.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/fs/state.js +129 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/fs/state.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/fs/writer-lock.js +277 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/fs/writer-lock.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/bootstrap.js +183 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/bootstrap.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/context.js +2 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/context.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/dispatch.js +121 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/dispatch.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/doctor.js +16 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/doctor.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/identity.js +72 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/identity.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/conflicts.js +59 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/conflicts.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/core.js +125 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/core.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/history.js +129 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/history.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/index.js +31 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/index.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/maintenance.js +49 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/maintenance.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/projections.js +30 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/projections.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/shared.js +12 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/operations/shared.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/platform.js +18 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/platform.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/projection.js +125 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/projection.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/clone.js +37 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/clone.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/pull.js +44 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/pull.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/purge.js +58 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/purge.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/push.js +118 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/push.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/transport.js +277 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/runtime/remote/transport.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/apply.js +132 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/apply.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/archive.js +372 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/archive.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/backup.js +210 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/backup.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/restore.js +278 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/restore.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/retained-directory.js +192 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/backup/retained-directory.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/commits.js +114 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/commits.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/contract.js +65 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/contract.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics-worker.js +145 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics-worker.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics.js +218 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/diagnostics.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/gc.js +71 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/gc.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/history-validation.js +298 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/history-validation.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/latest-values.js +121 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/latest-values.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/migrate.js +69 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/migrate.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/provenance.js +49 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/provenance.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/steps.js +424 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/steps.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/versions.js +10 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/migration/versions.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/001_initial.sql +319 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/002_staged_latest_values.sql +8 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/003_remove_cli_editing_lease.sql +21 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/004_hosted_association.sql +7 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations/005_artifact_properties.sql +68 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations.js +12 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/migrations.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/objects.js +410 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/objects.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/apply.js +77 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/apply.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/artifacts.js +240 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/artifacts.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/nodes.js +127 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/nodes.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/relations.js +107 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/relations.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/rules.js +80 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/rules.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/tags.js +219 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/projection/tags.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/hosted.js +164 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/hosted.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/read.js +20 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/read.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/replace.js +41 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/replace.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/schema.js +22 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/schema.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/validate.js +188 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot/validate.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot.js +5 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/snapshot.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/connection.js +214 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/connection.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/errors.js +4 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/errors.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/rows.js +44 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/rows.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/schema.js +38 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/schema.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/store.js +284 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/store.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/verify.js +133 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sqlite/verify.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sync-commits.js +98 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sync-commits.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sync.js +161 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/sync.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace-state.js +97 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace-state.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace.js +69 -0
- package/src/runtime/vendor/flywheel-cli-dist/local/store/workspace.js.map +1 -0
- package/src/runtime/vendor/flywheel-cli-dist/main.js +651 -376
- package/src/runtime/vendor/flywheel-cli-dist/main.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/output/format.js +18 -11
- package/src/runtime/vendor/flywheel-cli-dist/output/format.js.map +1 -1
- package/src/runtime/vendor/flywheel-cli-dist/prebuilds/darwin-arm64/node.napi.node +0 -0
- package/src/runtime/vendor/flywheel-cli-dist/prebuilds/darwin-x64/node.napi.node +0 -0
- package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-arm64/node.napi.glibc.node +0 -0
- package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-arm64/node.napi.musl.node +0 -0
- package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-x64/node.napi.glibc.node +0 -0
- package/src/runtime/vendor/flywheel-cli-dist/prebuilds/linux-x64/node.napi.musl.node +0 -0
- package/src/runtime/vendor/manifest.json +246 -257
- package/src/setup/command.mjs +5 -0
- package/src/setup/io/patchers/json.mjs +1 -1
- package/src/setup/io/patchers/toml.mjs +3 -1
- package/src/setup/io/patchers/yaml.mjs +1 -1
- package/src/setup/modes/cli.mjs +76 -7
- package/src/setup/modes/mcp-command.mjs +802 -793
- package/src/setup/modes/mcp.mjs +7 -3
- package/src/setup/shared/prior-mode-detect.mjs +18 -21
- package/src/setup/test-seams.mjs +25 -0
- package/src/setup-auth.mjs +76 -10
- package/src/toml-lines.mjs +52 -0
- package/src/unified-cli.mjs +31 -16
- package/skills/flywheel-llm-proof-paper/scripts/__pycache__/check_paper.cpython-312.pyc +0 -0
- package/src/runtime/vendor/flywheel-cli-dist/auth/active-key-id.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/auth/baseurl.d.ts +0 -35
- package/src/runtime/vendor/flywheel-cli-dist/auth/config.d.ts +0 -34
- package/src/runtime/vendor/flywheel-cli-dist/auth/config.js +0 -92
- package/src/runtime/vendor/flywheel-cli-dist/auth/config.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/auth/fingerprint.d.ts +0 -5
- package/src/runtime/vendor/flywheel-cli-dist/auth/keychain.d.ts +0 -4
- package/src/runtime/vendor/flywheel-cli-dist/auth/keychain.js +0 -31
- package/src/runtime/vendor/flywheel-cli-dist/auth/keychain.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/auth/login.d.ts +0 -24
- package/src/runtime/vendor/flywheel-cli-dist/auth/profile.d.ts +0 -15
- package/src/runtime/vendor/flywheel-cli-dist/auth/profile.js +0 -150
- package/src/runtime/vendor/flywheel-cli-dist/auth/profile.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/auth/profiles.d.ts +0 -27
- package/src/runtime/vendor/flywheel-cli-dist/commands/_admin-auth.d.ts +0 -27
- package/src/runtime/vendor/flywheel-cli-dist/commands/_artifacts-upload-helpers.d.ts +0 -32
- package/src/runtime/vendor/flywheel-cli-dist/commands/_artifacts-upload-helpers.js +0 -213
- package/src/runtime/vendor/flywheel-cli-dist/commands/_artifacts-upload-helpers.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/_browser-handoff.d.ts +0 -35
- package/src/runtime/vendor/flywheel-cli-dist/commands/_open-url.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/_secret-param.d.ts +0 -7
- package/src/runtime/vendor/flywheel-cli-dist/commands/_stream-file-out.d.ts +0 -39
- package/src/runtime/vendor/flywheel-cli-dist/commands/_stream-writer.d.ts +0 -34
- package/src/runtime/vendor/flywheel-cli-dist/commands/_wait-polling.d.ts +0 -50
- package/src/runtime/vendor/flywheel-cli-dist/commands/account-detach.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/account-emails-add.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/account-emails-remove.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/account-emails-set-primary.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/account-get.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/account-merge-preview.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/account-merge-proof.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/account-merge.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/admin-compute-policy-get.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/admin-compute-policy-set.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/admin-graphs-export-stream.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/admin-graphs-export.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/admin-graphs-list.d.ts +0 -4
- package/src/runtime/vendor/flywheel-cli-dist/commands/admin-nodes-audit-list.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-create.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-delete.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/admin-test-users-login.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/aliases.d.ts +0 -13
- package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-create.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-delete.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-list.d.ts +0 -18
- package/src/runtime/vendor/flywheel-cli-dist/commands/api-keys-rotate.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/approval-sessions-expire.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/approval-sessions-heartbeat.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/approval-sessions-list.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete-bulk.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete-bulk.js +0 -22
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete-bulk.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete.js +0 -8
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-delete.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-get.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-list.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-note-set.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-note-set.js +0 -9
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-note-set.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-finalize.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-finalize.js +0 -7
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-finalize.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-prepare.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-prepare.js +0 -15
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload-prepare.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload.js +0 -5
- package/src/runtime/vendor/flywheel-cli-dist/commands/artifacts-upload.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-clear.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-clear.js +0 -8
- package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-clear.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-set.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-set.js +0 -30
- package/src/runtime/vendor/flywheel-cli-dist/commands/auth-keychain-set.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/auth-login.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/auth-mode.d.ts +0 -4
- package/src/runtime/vendor/flywheel-cli-dist/commands/auth-status.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/blobs-get.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-create.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-list.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-revoke.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-budgets-update.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/campaign-snapshot.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/compute-acquire.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/compute-budgets.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/compute-connection.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/compute-funding.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/compute-grants-list.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/compute-grants-request-approval.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/compute-options.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/compute-release-all.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/compute-release.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/compute-status.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/credits-balance.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/credits-billing-portal.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/credits-purchase.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/credits-referral-claim.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/credits-referral.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/credits-subscribe.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/credits-subscription.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/credits-transactions.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/credits-usage.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/destructive-confirmation.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/enums.d.ts +0 -22
- package/src/runtime/vendor/flywheel-cli-dist/commands/env.d.ts +0 -8
- package/src/runtime/vendor/flywheel-cli-dist/commands/executions-launch.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/executions-list.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/executions-terminate.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/export-history.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/export-subgraph.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary-pdf.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary-render-pdf.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary-stream.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/export-summary.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/feedback-create.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/files-list.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/github-disconnect.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/github-link.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/github-refresh-repos.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/github-status.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/graph-get.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/handler-factory.d.ts +0 -22
- package/src/runtime/vendor/flywheel-cli-dist/commands/help-format.d.ts +0 -31
- package/src/runtime/vendor/flywheel-cli-dist/commands/help-metadata.d.ts +0 -36
- package/src/runtime/vendor/flywheel-cli-dist/commands/help.d.ts +0 -17
- package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-create.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-delete.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-list.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-runs-list.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-create.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-delete.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-list.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-secrets-update.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-set-enabled.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/hooks-update.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/import-subgraph.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/index.d.ts +0 -23
- package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-huggingface-remove.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-huggingface-set.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-status.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-wandb-remove.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/integrations-wandb-set.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/machines-list.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-add-parent.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-add-parent.js +0 -15
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-add-parent.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-branch.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-branch.js +0 -10
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-branch.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-children.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-children.js +0 -8
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-children.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit-new.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit-new.js +0 -6
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit-new.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit.js +0 -7
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-commit.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-create.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-create.js +0 -6
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-create.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete-bulk.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete-bulk.js +0 -16
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete-bulk.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete.js +0 -11
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-delete.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-files.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-get.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-list.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-merge.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-merge.js +0 -33
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-merge.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-parents.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-parents.js +0 -8
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-parents.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-remove-parent.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-remove-parent.js +0 -15
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-remove-parent.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-render-ancestry.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-render-summary.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-render-tree.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-resolve-slug.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-get.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-set-bulk.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-set.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-sharing-summaries.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-stage-lease-acquire.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-stage-lease-heartbeat.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/nodes-stage-lease-release.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/profile-list.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/profile-set.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/profile-show.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/profile-unset.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/account.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/admin.d.ts +0 -8
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/api-keys.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/approval.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/artifacts.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/artifacts.js +0 -140
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/artifacts.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/auth.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/budgets.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/compute.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/credits.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/env.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/executions.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/export.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/github.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/graph.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/hooks.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/integrations.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/lifecycle.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/profile.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/resources.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/sharing.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/tagging.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/tagging.js +0 -98
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/tagging.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry/updates.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/registry.d.ts +0 -27
- package/src/runtime/vendor/flywheel-cli-dist/commands/remote-artifacts-refresh.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/remote-artifacts-resolve.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/tags-assign.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/tags-assign.js +0 -25
- package/src/runtime/vendor/flywheel-cli-dist/commands/tags-assign.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/tags-create.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/tags-create.js +0 -25
- package/src/runtime/vendor/flywheel-cli-dist/commands/tags-create.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/tags-delete.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/tags-delete.js +0 -11
- package/src/runtime/vendor/flywheel-cli-dist/commands/tags-delete.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/tags-update.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/tags-update.js +0 -28
- package/src/runtime/vendor/flywheel-cli-dist/commands/tags-update.js.map +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/types.d.ts +0 -30
- package/src/runtime/vendor/flywheel-cli-dist/commands/updates-hide-all-active.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/commands/updates-hide.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/updates-list.d.ts +0 -2
- package/src/runtime/vendor/flywheel-cli-dist/commands/usage-spec.d.ts +0 -6
- package/src/runtime/vendor/flywheel-cli-dist/commands/utils.d.ts +0 -11
- package/src/runtime/vendor/flywheel-cli-dist/errors.d.ts +0 -86
- package/src/runtime/vendor/flywheel-cli-dist/exit-codes.d.ts +0 -8
- package/src/runtime/vendor/flywheel-cli-dist/generatedFeedbackContract.d.ts +0 -41
- package/src/runtime/vendor/flywheel-cli-dist/generatedProductTelemetryContract.d.ts +0 -13
- package/src/runtime/vendor/flywheel-cli-dist/grammar/globals.d.ts +0 -26
- package/src/runtime/vendor/flywheel-cli-dist/grammar/parse.d.ts +0 -17
- package/src/runtime/vendor/flywheel-cli-dist/http/client.d.ts +0 -91
- package/src/runtime/vendor/flywheel-cli-dist/http/debug.d.ts +0 -5
- package/src/runtime/vendor/flywheel-cli-dist/http/poll.d.ts +0 -18
- package/src/runtime/vendor/flywheel-cli-dist/http/retry.d.ts +0 -30
- package/src/runtime/vendor/flywheel-cli-dist/main.d.ts +0 -33
- package/src/runtime/vendor/flywheel-cli-dist/output/format.d.ts +0 -9
- package/src/runtime/vendor/flywheel-cli-dist/runtime-entry.d.ts +0 -1
- package/src/runtime/vendor/flywheel-cli-dist/version.d.ts +0 -3
- package/src/secure-write.mjs +0 -43
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { artifactReferenceSetDigest, foldArtifactPropertiesOperation, legacyArtifactMetadata, legacyArtifactProperties, parseArtifactProperties, } from "../../domain/models/artifact-properties.js";
|
|
3
|
+
import { canonicalBytes, valueDigest } from "../../domain/models/encoding.js";
|
|
4
|
+
import { RepositoryStoreError } from "../sqlite/errors.js";
|
|
5
|
+
import { getRow, runSql } from "../sqlite/rows.js";
|
|
6
|
+
import { assertLiveNodes } from "./rules.js";
|
|
7
|
+
const LEGACY_FIELDS = ["name", "media_type", "notes", "tags"];
|
|
8
|
+
function stringValue(value) {
|
|
9
|
+
return typeof value === "string" ? value : undefined;
|
|
10
|
+
}
|
|
11
|
+
function legacyField(value) {
|
|
12
|
+
return typeof value === "string" && LEGACY_FIELDS.includes(value)
|
|
13
|
+
? value
|
|
14
|
+
: undefined;
|
|
15
|
+
}
|
|
16
|
+
function projectionDigest(value) {
|
|
17
|
+
return `sha256:${createHash("sha256").update(canonicalBytes(value)).digest("hex")}`;
|
|
18
|
+
}
|
|
19
|
+
function latestValue(latestValues, artifactId, field) {
|
|
20
|
+
return latestValues.get(canonicalBytes(["artifact", artifactId, field]).toString("utf8"));
|
|
21
|
+
}
|
|
22
|
+
function requirePropertiesWrite(latestValues, artifactId, digest) {
|
|
23
|
+
const write = latestValue(latestValues, artifactId, "properties");
|
|
24
|
+
if (!write || write.value === null || write.valueDigest !== digest) {
|
|
25
|
+
throw new RepositoryStoreError("artifact properties latest value is invalid");
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
parseArtifactProperties(write.value);
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
throw new RepositoryStoreError("artifact properties are invalid", { cause: error });
|
|
32
|
+
}
|
|
33
|
+
return write.value;
|
|
34
|
+
}
|
|
35
|
+
function assertOwner(database, repositoryId, kind, ownerId) {
|
|
36
|
+
if (kind === "node") {
|
|
37
|
+
assertLiveNodes(database, repositoryId, [ownerId]);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const edge = getRow(database.prepare("SELECT graph_node_id, source_node_id, target_node_id FROM repository_semantic_edges WHERE repository_id = ? AND edge_id = ?"), repositoryId, ownerId);
|
|
41
|
+
if (!edge)
|
|
42
|
+
throw new RepositoryStoreError("artifact owner edge is missing");
|
|
43
|
+
const ids = [edge.graph_node_id, edge.source_node_id, edge.target_node_id];
|
|
44
|
+
if (!ids.every((value) => typeof value === "string")) {
|
|
45
|
+
throw new RepositoryStoreError("artifact owner edge is not live");
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
assertLiveNodes(database, repositoryId, ids);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
throw new RepositoryStoreError("artifact owner edge is not live", { cause: error });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function referenceSet(database, repositoryId, artifactId) {
|
|
55
|
+
const rows = database.prepare(`
|
|
56
|
+
SELECT owner_kind, owner_id, reference_order
|
|
57
|
+
FROM repository_artifact_references
|
|
58
|
+
WHERE repository_id = ? AND artifact_id = ?
|
|
59
|
+
ORDER BY owner_kind, owner_id
|
|
60
|
+
`, { readBigInts: true }).all(repositoryId, artifactId);
|
|
61
|
+
if (rows.length === 0)
|
|
62
|
+
throw new RepositoryStoreError("artifact has no live references");
|
|
63
|
+
const entries = [];
|
|
64
|
+
for (const row of rows) {
|
|
65
|
+
if ((row.owner_kind !== "node" && row.owner_kind !== "edge") || typeof row.owner_id !== "string" ||
|
|
66
|
+
typeof row.reference_order !== "bigint") {
|
|
67
|
+
throw new RepositoryStoreError("artifact reference is invalid");
|
|
68
|
+
}
|
|
69
|
+
assertOwner(database, repositoryId, row.owner_kind, row.owner_id);
|
|
70
|
+
entries.push({ owner_type: row.owner_kind, owner_id: row.owner_id, order: row.reference_order });
|
|
71
|
+
}
|
|
72
|
+
return entries;
|
|
73
|
+
}
|
|
74
|
+
function attachProperties(operation, artifactId, latestValues) {
|
|
75
|
+
if (operation.type === "artifact.attach.v2") {
|
|
76
|
+
const digest = stringValue(operation.payload.properties_digest);
|
|
77
|
+
if (!digest)
|
|
78
|
+
throw new RepositoryStoreError("invalid artifact attachment");
|
|
79
|
+
return { properties: requirePropertiesWrite(latestValues, artifactId, digest), digest };
|
|
80
|
+
}
|
|
81
|
+
const metadata = {};
|
|
82
|
+
for (const field of LEGACY_FIELDS)
|
|
83
|
+
metadata[field] = latestValue(latestValues, artifactId, field)?.value ?? null;
|
|
84
|
+
const metadataDigest = stringValue(operation.payload.metadata_digest);
|
|
85
|
+
if (!metadataDigest || projectionDigest(metadata) !== metadataDigest) {
|
|
86
|
+
throw new RepositoryStoreError("artifact metadata digest is invalid");
|
|
87
|
+
}
|
|
88
|
+
const properties = legacyArtifactProperties(metadata);
|
|
89
|
+
return { properties, digest: valueDigest(properties) };
|
|
90
|
+
}
|
|
91
|
+
function attach(database, commit, operation, artifactId, kind, ownerId, latestValues) {
|
|
92
|
+
const objectDigest = stringValue(operation.payload.object_digest);
|
|
93
|
+
const order = operation.payload.order;
|
|
94
|
+
if (!objectDigest || typeof order !== "bigint")
|
|
95
|
+
throw new RepositoryStoreError("invalid artifact attachment");
|
|
96
|
+
const artifact = getRow(database.prepare("SELECT object_digest, properties, properties_digest FROM repository_artifacts WHERE repository_id = ? AND artifact_id = ?"), commit.repositoryId, artifactId);
|
|
97
|
+
if (!artifact) {
|
|
98
|
+
const { properties, digest } = attachProperties(operation, artifactId, latestValues);
|
|
99
|
+
runSql(database.prepare(`
|
|
100
|
+
INSERT INTO repository_artifacts (
|
|
101
|
+
repository_id, artifact_id, object_digest, properties, properties_digest, created_by_commit_id
|
|
102
|
+
) VALUES (?, ?, ?, ?, ?, ?)
|
|
103
|
+
`), commit.repositoryId, artifactId, objectDigest, properties, digest, commit.commitId);
|
|
104
|
+
}
|
|
105
|
+
else if (artifact.object_digest !== objectDigest ||
|
|
106
|
+
(operation.type === "artifact.attach.v2"
|
|
107
|
+
? artifact.properties_digest !== operation.payload.properties_digest
|
|
108
|
+
: projectionDigest(legacyArtifactMetadata(String(artifact.properties))) !== operation.payload.metadata_digest)) {
|
|
109
|
+
throw new RepositoryStoreError("artifact object or properties digest precondition failed");
|
|
110
|
+
}
|
|
111
|
+
if (getRow(database.prepare("SELECT 1 AS present FROM repository_artifact_references WHERE repository_id = ? AND artifact_id = ? AND owner_kind = ? AND owner_id = ?"), commit.repositoryId, artifactId, kind, ownerId)) {
|
|
112
|
+
throw new RepositoryStoreError("artifact reference already exists");
|
|
113
|
+
}
|
|
114
|
+
runSql(database.prepare(`
|
|
115
|
+
INSERT INTO repository_artifact_references (
|
|
116
|
+
repository_id, artifact_id, owner_kind, owner_id, node_owner_id, edge_owner_id, reference_order, attached_by_commit_id
|
|
117
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
118
|
+
`), commit.repositoryId, artifactId, kind, ownerId, kind === "node" ? ownerId : null, kind === "edge" ? ownerId : null, order, commit.commitId);
|
|
119
|
+
}
|
|
120
|
+
function referenceDigest(artifactId, objectDigest, kind, ownerId, order) {
|
|
121
|
+
return projectionDigest({ artifact_id: artifactId, object_digest: objectDigest, owner_kind: kind, owner_id: ownerId, reference_order: order });
|
|
122
|
+
}
|
|
123
|
+
function detach(database, commit, operation, artifactId, kind, ownerId) {
|
|
124
|
+
const objectDigest = stringValue(operation.payload.object_digest);
|
|
125
|
+
const expected = stringValue(operation.payload.reference_digest);
|
|
126
|
+
if (!objectDigest || !expected)
|
|
127
|
+
throw new RepositoryStoreError("invalid artifact detachment");
|
|
128
|
+
const row = getRow(database.prepare(`
|
|
129
|
+
SELECT artifact.object_digest, reference.reference_order
|
|
130
|
+
FROM repository_artifacts AS artifact
|
|
131
|
+
JOIN repository_artifact_references AS reference
|
|
132
|
+
ON reference.repository_id = artifact.repository_id AND reference.artifact_id = artifact.artifact_id
|
|
133
|
+
WHERE artifact.repository_id = ? AND artifact.artifact_id = ? AND reference.owner_kind = ? AND reference.owner_id = ?
|
|
134
|
+
`, { readBigInts: true }), commit.repositoryId, artifactId, kind, ownerId);
|
|
135
|
+
if (!row || row.object_digest !== objectDigest || typeof row.reference_order !== "bigint" ||
|
|
136
|
+
expected !== referenceDigest(artifactId, objectDigest, kind, ownerId, row.reference_order)) {
|
|
137
|
+
throw new RepositoryStoreError("artifact reference digest precondition failed");
|
|
138
|
+
}
|
|
139
|
+
rootArtifactHistory(database, commit.repositoryId, commit.commitId, [objectDigest]);
|
|
140
|
+
runSql(database.prepare("DELETE FROM repository_artifact_references WHERE repository_id = ? AND artifact_id = ? AND owner_kind = ? AND owner_id = ?"), commit.repositoryId, artifactId, kind, ownerId);
|
|
141
|
+
}
|
|
142
|
+
function rootArtifactHistory(database, repositoryId, commitId, digests) {
|
|
143
|
+
const statement = database.prepare(`
|
|
144
|
+
INSERT OR IGNORE INTO repository_gc_roots (repository_id, root_kind, root_id, digest)
|
|
145
|
+
VALUES (?, 'artifact_history', ?, ?)
|
|
146
|
+
`);
|
|
147
|
+
for (const digest of new Set(digests))
|
|
148
|
+
runSql(statement, repositoryId, commitId, digest);
|
|
149
|
+
}
|
|
150
|
+
function setSharedValue(database, commit, operation, artifactId, latestValues) {
|
|
151
|
+
const artifact = getRow(database.prepare("SELECT object_digest, properties_digest FROM repository_artifacts WHERE repository_id = ? AND artifact_id = ?"), commit.repositoryId, artifactId);
|
|
152
|
+
if (!artifact || typeof artifact.object_digest !== "string" || typeof artifact.properties_digest !== "string") {
|
|
153
|
+
throw new RepositoryStoreError("artifact is missing");
|
|
154
|
+
}
|
|
155
|
+
const expectedReferences = stringValue(operation.payload.expected_reference_digest);
|
|
156
|
+
if (!expectedReferences || expectedReferences !== artifactReferenceSetDigest(referenceSet(database, commit.repositoryId, artifactId))) {
|
|
157
|
+
throw new RepositoryStoreError("artifact reference digest precondition failed");
|
|
158
|
+
}
|
|
159
|
+
if (operation.type === "artifact.content.set.v1") {
|
|
160
|
+
const expected = stringValue(operation.payload.expected_object_digest);
|
|
161
|
+
const replacement = stringValue(operation.payload.object_digest);
|
|
162
|
+
if (!expected || !replacement || artifact.object_digest !== expected) {
|
|
163
|
+
throw new RepositoryStoreError("artifact object digest precondition failed");
|
|
164
|
+
}
|
|
165
|
+
runSql(database.prepare("UPDATE repository_artifacts SET object_digest = ? WHERE repository_id = ? AND artifact_id = ?"), replacement, commit.repositoryId, artifactId);
|
|
166
|
+
rootArtifactHistory(database, commit.repositoryId, commit.commitId, [artifact.object_digest, replacement]);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const expected = stringValue(operation.payload.expected_digest);
|
|
170
|
+
const replacement = stringValue(operation.payload.new_digest);
|
|
171
|
+
if (!expected || !replacement || artifact.properties_digest !== expected) {
|
|
172
|
+
throw new RepositoryStoreError("artifact properties digest precondition failed");
|
|
173
|
+
}
|
|
174
|
+
const properties = requirePropertiesWrite(latestValues, artifactId, replacement);
|
|
175
|
+
runSql(database.prepare("UPDATE repository_artifacts SET properties = ?, properties_digest = ? WHERE repository_id = ? AND artifact_id = ?"), properties, replacement, commit.repositoryId, artifactId);
|
|
176
|
+
}
|
|
177
|
+
function setLegacyMetadata(database, commit, operation, artifactId, kind, ownerId, latestValues) {
|
|
178
|
+
const field = legacyField(operation.payload.field);
|
|
179
|
+
const expected = stringValue(operation.payload.expected_digest);
|
|
180
|
+
const replacement = stringValue(operation.payload.new_digest);
|
|
181
|
+
if (!field || !expected || !replacement)
|
|
182
|
+
throw new RepositoryStoreError("invalid artifact metadata operation");
|
|
183
|
+
if (!getRow(database.prepare("SELECT 1 AS present FROM repository_artifact_references WHERE repository_id = ? AND artifact_id = ? AND owner_kind = ? AND owner_id = ?"), commit.repositoryId, artifactId, kind, ownerId)) {
|
|
184
|
+
throw new RepositoryStoreError("artifact metadata owner reference is missing");
|
|
185
|
+
}
|
|
186
|
+
const row = getRow(database.prepare("SELECT properties FROM repository_artifacts WHERE repository_id = ? AND artifact_id = ?"), commit.repositoryId, artifactId);
|
|
187
|
+
if (!row || typeof row.properties !== "string")
|
|
188
|
+
throw new RepositoryStoreError("artifact metadata is missing");
|
|
189
|
+
let metadata;
|
|
190
|
+
try {
|
|
191
|
+
metadata = legacyArtifactMetadata(row.properties);
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
throw new RepositoryStoreError("artifact properties are invalid", { cause: error });
|
|
195
|
+
}
|
|
196
|
+
if (valueDigest(metadata[field]) !== expected)
|
|
197
|
+
throw new RepositoryStoreError("artifact metadata digest precondition failed");
|
|
198
|
+
const write = latestValue(latestValues, artifactId, field);
|
|
199
|
+
if (!write || write.valueDigest !== replacement)
|
|
200
|
+
throw new RepositoryStoreError("artifact metadata latest value is invalid");
|
|
201
|
+
let properties;
|
|
202
|
+
try {
|
|
203
|
+
properties = foldArtifactPropertiesOperation(row.properties, operation, latestValues);
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
throw new RepositoryStoreError("artifact properties are invalid", { cause: error });
|
|
207
|
+
}
|
|
208
|
+
if (properties === undefined)
|
|
209
|
+
throw new RepositoryStoreError("artifact properties are invalid");
|
|
210
|
+
runSql(database.prepare("UPDATE repository_artifacts SET properties = ?, properties_digest = ? WHERE repository_id = ? AND artifact_id = ?"), properties, valueDigest(properties), commit.repositoryId, artifactId);
|
|
211
|
+
}
|
|
212
|
+
export function applyArtifact(database, commit, operation, latestValues) {
|
|
213
|
+
const artifactId = stringValue(operation.payload.artifact_id);
|
|
214
|
+
if (!artifactId)
|
|
215
|
+
throw new RepositoryStoreError("invalid artifact projection payload");
|
|
216
|
+
if (operation.type === "artifact.content.set.v1" || operation.type === "artifact.properties.set.v1") {
|
|
217
|
+
setSharedValue(database, commit, operation, artifactId, latestValues);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const owner = operation.payload.owner;
|
|
221
|
+
if (!owner || typeof owner !== "object" || Array.isArray(owner)) {
|
|
222
|
+
throw new RepositoryStoreError("invalid artifact projection payload");
|
|
223
|
+
}
|
|
224
|
+
const kind = owner.owner_type;
|
|
225
|
+
const ownerId = stringValue(owner.owner_id);
|
|
226
|
+
if ((kind !== "node" && kind !== "edge") || !ownerId)
|
|
227
|
+
throw new RepositoryStoreError("invalid artifact owner");
|
|
228
|
+
if (operation.type === "artifact.attach.v1" || operation.type === "artifact.attach.v2") {
|
|
229
|
+
assertOwner(database, commit.repositoryId, kind, ownerId);
|
|
230
|
+
attach(database, commit, operation, artifactId, kind, ownerId, latestValues);
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (operation.type === "artifact.detach.v1") {
|
|
234
|
+
detach(database, commit, operation, artifactId, kind, ownerId);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
assertOwner(database, commit.repositoryId, kind, ownerId);
|
|
238
|
+
setLegacyMetadata(database, commit, operation, artifactId, kind, ownerId, latestValues);
|
|
239
|
+
}
|
|
240
|
+
//# sourceMappingURL=artifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifacts.js","sourceRoot":"","sources":["../../../../src/local/store/projection/artifacts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EACL,0BAA0B,EAC1B,+BAA+B,EAC/B,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,GACxB,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AC;IACxE,CAAC;IACD,MAAM,IAAI,GAAI,KAAiC,CAAC,UAAU,CAAC;IAC3D,MAAM,OAAO,GAAG,WAAW,CAAE,KAAiC,CAAC,QAAQ,CAAC,CAAC;IACzE,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,oBAAoB,CAAC,wBAAwB,CAAC,CAAC;IAC/G,IAAI,SAAS,CAAC,IAAI,KAAK,oBAAoB,IAAI,SAAS,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;QACvF,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,YAAY,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC1D,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;QAC7E,OAAO;IACT,CAAC;IACD,IAAI,SAAS,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;QAC5C,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;QAC/D,OAAO;IACT,CAAC;IACD,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,YAAY,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1D,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { RepositoryCommit } from "../../domain/models/commits.js";
|
|
2
|
+
import { RepositoryStoreError } from "../sqlite/errors.js";
|
|
3
|
+
import { getRow, runSql } from "../sqlite/rows.js";
|
|
4
|
+
const NODE_FIELDS = ["title", "slug_name", "summary", "content", "origin_host", "external_transcript_ref"];
|
|
5
|
+
function stringValue(value) {
|
|
6
|
+
return typeof value === "string" ? value : undefined;
|
|
7
|
+
}
|
|
8
|
+
function nodeField(value) {
|
|
9
|
+
return typeof value === "string" && NODE_FIELDS.includes(value) ? value : undefined;
|
|
10
|
+
}
|
|
11
|
+
export function applyNodeCreate(database, commit, operation) {
|
|
12
|
+
const nodeId = stringValue(operation.payload.node_id);
|
|
13
|
+
const values = operation.payload.initial_values;
|
|
14
|
+
const digests = operation.payload.initial_field_digests;
|
|
15
|
+
if (!nodeId || !values || typeof values !== "object" || Array.isArray(values) || !digests || typeof digests !== "object" || Array.isArray(digests)) {
|
|
16
|
+
throw new RepositoryStoreError("invalid node create projection payload");
|
|
17
|
+
}
|
|
18
|
+
const initial = values;
|
|
19
|
+
const fieldDigests = digests;
|
|
20
|
+
if (NODE_FIELDS.some((field) => (initial[field] !== null && typeof initial[field] !== "string") || typeof fieldDigests[field] !== "string")) {
|
|
21
|
+
throw new RepositoryStoreError("invalid node create projection payload");
|
|
22
|
+
}
|
|
23
|
+
runSql(database.prepare("INSERT INTO repository_nodes VALUES (?, ?, 'live', ?, ?)"), commit.repositoryId, nodeId, commit.commitId, commit.commitId);
|
|
24
|
+
runSql(database.prepare(`INSERT INTO repository_node_latest_values (
|
|
25
|
+
repository_id, node_id, title, slug_name, summary, content, origin_host, external_transcript_ref,
|
|
26
|
+
title_digest, slug_name_digest, summary_digest, content_digest, origin_host_digest, external_transcript_ref_digest,
|
|
27
|
+
updated_by_commit_id
|
|
28
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`), commit.repositoryId, nodeId, initial.title, initial.slug_name, initial.summary, initial.content, initial.origin_host, initial.external_transcript_ref, fieldDigests.title, fieldDigests.slug_name, fieldDigests.summary, fieldDigests.content, fieldDigests.origin_host, fieldDigests.external_transcript_ref, commit.commitId);
|
|
29
|
+
}
|
|
30
|
+
export function applyNodeFieldSet(database, commit, operation, latestValue) {
|
|
31
|
+
const nodeId = stringValue(operation.payload.node_id);
|
|
32
|
+
const field = nodeField(operation.payload.field);
|
|
33
|
+
const expected = stringValue(operation.payload.expected_digest);
|
|
34
|
+
const replacement = stringValue(operation.payload.new_digest);
|
|
35
|
+
if (!nodeId || !field || !expected || !replacement)
|
|
36
|
+
throw new RepositoryStoreError("invalid node field operation");
|
|
37
|
+
const row = getRow(database.prepare(`SELECT ${field}_digest AS digest FROM repository_node_latest_values WHERE repository_id = ? AND node_id = ?`), commit.repositoryId, nodeId);
|
|
38
|
+
if (!row || row.digest !== expected)
|
|
39
|
+
throw new RepositoryStoreError("node field projection precondition failed");
|
|
40
|
+
runSql(database.prepare(`UPDATE repository_node_latest_values
|
|
41
|
+
SET ${field} = ?, ${field}_digest = ?, updated_by_commit_id = ?
|
|
42
|
+
WHERE repository_id = ? AND node_id = ?`), latestValue.value, replacement, commit.commitId, commit.repositoryId, nodeId);
|
|
43
|
+
}
|
|
44
|
+
function structuralDependencyCount(database, repositoryId, nodeId) {
|
|
45
|
+
const row = getRow(database.prepare(`SELECT COUNT(*) AS count FROM (
|
|
46
|
+
SELECT parent_node_id FROM repository_lineage WHERE repository_id = ? AND (parent_node_id = ? OR child_node_id = ?)
|
|
47
|
+
UNION ALL SELECT containment_id FROM repository_containments WHERE repository_id = ? AND (container_node_id = ? OR child_node_id = ?)
|
|
48
|
+
UNION ALL SELECT edge_id FROM repository_semantic_edges WHERE repository_id = ? AND (graph_node_id = ? OR source_node_id = ? OR target_node_id = ?)
|
|
49
|
+
UNION ALL SELECT tag_id FROM repository_tag_definitions WHERE repository_id = ? AND scope_node_id = ? AND state = 'active'
|
|
50
|
+
UNION ALL SELECT tag_id FROM repository_tag_assignments WHERE repository_id = ? AND (scope_node_id = ? OR node_id = ?)
|
|
51
|
+
UNION ALL SELECT artifact_id FROM repository_artifact_references WHERE repository_id = ? AND node_owner_id = ?
|
|
52
|
+
)`, { readBigInts: true }), repositoryId, nodeId, nodeId, repositoryId, nodeId, nodeId, repositoryId, nodeId, nodeId, nodeId, repositoryId, nodeId, repositoryId, nodeId, nodeId, repositoryId, nodeId);
|
|
53
|
+
if (!row || typeof row.count !== "bigint")
|
|
54
|
+
throw new RepositoryStoreError("structural dependency count is invalid");
|
|
55
|
+
return row.count;
|
|
56
|
+
}
|
|
57
|
+
function assertRestoreStructure(database, repositoryId, nodeId) {
|
|
58
|
+
const row = getRow(database.prepare(`SELECT 1 AS present FROM repository_containments AS relation
|
|
59
|
+
JOIN repository_nodes AS counterpart ON counterpart.repository_id = relation.repository_id
|
|
60
|
+
AND counterpart.node_id = CASE WHEN relation.container_node_id = ? THEN relation.child_node_id ELSE relation.container_node_id END
|
|
61
|
+
WHERE relation.repository_id = ? AND (? IN (relation.container_node_id, relation.child_node_id)) AND counterpart.lifecycle_state != 'live'
|
|
62
|
+
UNION ALL
|
|
63
|
+
SELECT 1 AS present FROM repository_lineage AS relation
|
|
64
|
+
JOIN repository_nodes AS counterpart ON counterpart.repository_id = relation.repository_id
|
|
65
|
+
AND counterpart.node_id = CASE WHEN relation.parent_node_id = ? THEN relation.child_node_id ELSE relation.parent_node_id END
|
|
66
|
+
WHERE relation.repository_id = ? AND (? IN (relation.parent_node_id, relation.child_node_id)) AND counterpart.lifecycle_state != 'live'
|
|
67
|
+
UNION ALL
|
|
68
|
+
SELECT 1 AS present FROM repository_semantic_edges AS relation
|
|
69
|
+
JOIN repository_nodes AS counterpart ON counterpart.repository_id = relation.repository_id
|
|
70
|
+
AND counterpart.node_id IN (relation.graph_node_id, relation.source_node_id, relation.target_node_id) AND counterpart.node_id != ?
|
|
71
|
+
WHERE relation.repository_id = ? AND ? IN (relation.graph_node_id, relation.source_node_id, relation.target_node_id) AND counterpart.lifecycle_state != 'live'
|
|
72
|
+
LIMIT 1`), nodeId, repositoryId, nodeId, nodeId, repositoryId, nodeId, nodeId, repositoryId, nodeId);
|
|
73
|
+
if (row)
|
|
74
|
+
throw new RepositoryStoreError("node restore violates structural invariants");
|
|
75
|
+
}
|
|
76
|
+
function revertsNodeCreate(database, commit, nodeId) {
|
|
77
|
+
if (!commit.intent || !/^revert:sha256:[0-9a-f]{64}$/.test(commit.intent))
|
|
78
|
+
return false;
|
|
79
|
+
const targetId = commit.intent.slice("revert:".length);
|
|
80
|
+
const row = getRow(database.prepare("SELECT canonical_bytes FROM repository_commits WHERE repository_id = ? AND commit_id = ?"), commit.repositoryId, targetId);
|
|
81
|
+
if (!row)
|
|
82
|
+
throw new RepositoryStoreError("revert target commit is missing");
|
|
83
|
+
if (!(row.canonical_bytes instanceof Uint8Array))
|
|
84
|
+
throw new RepositoryStoreError("revert target commit is corrupt");
|
|
85
|
+
let target;
|
|
86
|
+
try {
|
|
87
|
+
target = RepositoryCommit.fromCanonicalBytes(targetId, row.canonical_bytes);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
throw new RepositoryStoreError("revert target commit is corrupt", { cause: error });
|
|
91
|
+
}
|
|
92
|
+
return target.operations.some((candidate) => candidate.type === "node.create.v1" && candidate.payload.node_id === nodeId);
|
|
93
|
+
}
|
|
94
|
+
export function applyNodeLifecycle(database, commit, operation) {
|
|
95
|
+
const nodeId = stringValue(operation.payload.node_id);
|
|
96
|
+
const expected = stringValue(operation.payload.expected_lifecycle);
|
|
97
|
+
if (!nodeId || (expected !== "live" && expected !== "tombstoned"))
|
|
98
|
+
throw new RepositoryStoreError("invalid node lifecycle operation");
|
|
99
|
+
if (operation.type === "node.restore.v1")
|
|
100
|
+
assertRestoreStructure(database, commit.repositoryId, nodeId);
|
|
101
|
+
else if (revertsNodeCreate(database, commit, nodeId) && structuralDependencyCount(database, commit.repositoryId, nodeId) !== 0n) {
|
|
102
|
+
throw new RepositoryStoreError("node create revert has new live structural dependencies");
|
|
103
|
+
}
|
|
104
|
+
const next = operation.type === "node.tombstone.v1" ? "tombstoned" : "live";
|
|
105
|
+
if (runSql(database.prepare("UPDATE repository_nodes SET lifecycle_state = ?, lifecycle_commit_id = ? WHERE repository_id = ? AND node_id = ? AND lifecycle_state = ?"), next, commit.commitId, commit.repositoryId, nodeId, expected).changes !== 1)
|
|
106
|
+
throw new RepositoryStoreError("node lifecycle projection precondition failed");
|
|
107
|
+
}
|
|
108
|
+
export function applyNodePurge(database, commit, operation) {
|
|
109
|
+
const nodeId = stringValue(operation.payload.node_id);
|
|
110
|
+
const expectedHead = stringValue(operation.payload.expected_head);
|
|
111
|
+
const confirmation = stringValue(operation.payload.confirmation_node_id);
|
|
112
|
+
const declared = operation.payload.live_dependency_count;
|
|
113
|
+
const acceptedZero = declared === 0 || declared === 0n || declared === false ||
|
|
114
|
+
(JSON.isRawJSON(declared) && Number(declared.rawJSON) === 0);
|
|
115
|
+
if (!nodeId || !expectedHead || !confirmation || !acceptedZero)
|
|
116
|
+
throw new RepositoryStoreError("invalid node purge operation");
|
|
117
|
+
if (nodeId !== confirmation || expectedHead !== commit.expectedHead) {
|
|
118
|
+
throw new RepositoryStoreError("node purge confirmation or head is invalid");
|
|
119
|
+
}
|
|
120
|
+
const dependencies = structuralDependencyCount(database, commit.repositoryId, nodeId);
|
|
121
|
+
if (dependencies !== 0n)
|
|
122
|
+
throw new RepositoryStoreError("node purge has live structural dependencies");
|
|
123
|
+
if (runSql(database.prepare("UPDATE repository_nodes SET lifecycle_state = 'purged', lifecycle_commit_id = ? WHERE repository_id = ? AND node_id = ? AND lifecycle_state = 'tombstoned'"), commit.commitId, commit.repositoryId, nodeId).changes !== 1)
|
|
124
|
+
throw new RepositoryStoreError("node purge projection precondition failed");
|
|
125
|
+
runSql(database.prepare("DELETE FROM repository_node_latest_values WHERE repository_id = ? AND node_id = ?"), commit.repositoryId, nodeId);
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=nodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../../src/local/store/projection/nodes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGlE,OAAO,EAAE,oBAAoB,EAAE,MAAM,q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 -0,0 +1,107 @@
|
|
|
1
|
+
import { canonicalBytes } from "../../domain/models/encoding.js";
|
|
2
|
+
import { RepositoryStoreError } from "../sqlite/errors.js";
|
|
3
|
+
import { getRow, runSql } from "../sqlite/rows.js";
|
|
4
|
+
import { assertAcyclicRelation, assertAllSemanticEdgesValid, assertLiveNodes, assertSemanticEdgeValid } from "./rules.js";
|
|
5
|
+
function stringValue(value) {
|
|
6
|
+
return typeof value === "string" ? value : undefined;
|
|
7
|
+
}
|
|
8
|
+
export function applyLineage(database, commit, operation) {
|
|
9
|
+
const parentId = stringValue(operation.payload.parent_node_id);
|
|
10
|
+
const childId = stringValue(operation.payload.child_node_id);
|
|
11
|
+
if (!parentId || !childId)
|
|
12
|
+
throw new RepositoryStoreError("invalid lineage operation");
|
|
13
|
+
if (operation.type === "lineage.add.v1") {
|
|
14
|
+
assertLiveNodes(database, commit.repositoryId, [parentId, childId]);
|
|
15
|
+
assertAcyclicRelation(database, commit.repositoryId, parentId, childId, "repository_lineage");
|
|
16
|
+
try {
|
|
17
|
+
runSql(database.prepare("INSERT INTO repository_lineage VALUES (?, ?, ?, ?)"), commit.repositoryId, parentId, childId, commit.commitId);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
throw new RepositoryStoreError("lineage relation already exists", { cause: error });
|
|
21
|
+
}
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (runSql(database.prepare("DELETE FROM repository_lineage WHERE repository_id = ? AND parent_node_id = ? AND child_node_id = ?"), commit.repositoryId, parentId, childId).changes !== 1)
|
|
25
|
+
throw new RepositoryStoreError("lineage relation projection precondition failed");
|
|
26
|
+
}
|
|
27
|
+
export function applyContainment(database, commit, operation) {
|
|
28
|
+
const containmentId = stringValue(operation.payload.containment_id);
|
|
29
|
+
const childId = stringValue(operation.payload.child_node_id);
|
|
30
|
+
const relationDigest = stringValue(operation.payload.relation_digest);
|
|
31
|
+
if (!containmentId || !childId || !relationDigest)
|
|
32
|
+
throw new RepositoryStoreError("invalid containment operation");
|
|
33
|
+
if (operation.type === "containment.assign.v1") {
|
|
34
|
+
const containerId = stringValue(operation.payload.container_node_id);
|
|
35
|
+
const ordinal = operation.payload.ordinal;
|
|
36
|
+
const sourceArtifactId = operation.payload.source_artifact_id;
|
|
37
|
+
if (!containerId || (ordinal !== null && typeof ordinal !== "bigint") ||
|
|
38
|
+
(sourceArtifactId !== null && typeof sourceArtifactId !== "string")) {
|
|
39
|
+
throw new RepositoryStoreError("invalid containment assignment");
|
|
40
|
+
}
|
|
41
|
+
assertLiveNodes(database, commit.repositoryId, [containerId, childId]);
|
|
42
|
+
const existing = getRow(database.prepare("SELECT containment_id FROM repository_containments WHERE repository_id = ? AND child_node_id = ?"), commit.repositoryId, childId);
|
|
43
|
+
if (existing)
|
|
44
|
+
throw new RepositoryStoreError("containment relation already has active containment");
|
|
45
|
+
assertAcyclicRelation(database, commit.repositoryId, containerId, childId, "repository_containments");
|
|
46
|
+
try {
|
|
47
|
+
runSql(database.prepare("INSERT INTO repository_containments VALUES (?, ?, ?, ?, ?, ?, ?, ?)"), commit.repositoryId, containmentId, containerId, childId, relationDigest, ordinal, sourceArtifactId, commit.commitId);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
throw new RepositoryStoreError("containment relation already exists", { cause: error });
|
|
51
|
+
}
|
|
52
|
+
assertAllSemanticEdgesValid(database, commit.repositoryId);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (runSql(database.prepare("DELETE FROM repository_containments WHERE repository_id = ? AND containment_id = ? AND child_node_id = ? AND relation_digest = ?"), commit.repositoryId, containmentId, childId, relationDigest).changes !== 1)
|
|
56
|
+
throw new RepositoryStoreError("containment relation projection precondition failed");
|
|
57
|
+
assertAllSemanticEdgesValid(database, commit.repositoryId);
|
|
58
|
+
}
|
|
59
|
+
function latestValue(latestValues, edgeId) {
|
|
60
|
+
const value = latestValues.get(canonicalBytes(["edge", edgeId, "content"]).toString("utf8"));
|
|
61
|
+
if (!value)
|
|
62
|
+
throw new RepositoryStoreError("edge latest value is missing");
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
export function applyEdge(database, commit, operation, latestValues) {
|
|
66
|
+
const edgeId = stringValue(operation.payload.edge_id);
|
|
67
|
+
if (!edgeId)
|
|
68
|
+
throw new RepositoryStoreError("invalid edge operation");
|
|
69
|
+
if (operation.type === "edge.add.v1") {
|
|
70
|
+
const graphId = stringValue(operation.payload.graph_node_id);
|
|
71
|
+
const sourceId = stringValue(operation.payload.source_node_id);
|
|
72
|
+
const targetId = stringValue(operation.payload.target_node_id);
|
|
73
|
+
const relationDigest = stringValue(operation.payload.relation_digest);
|
|
74
|
+
const contentDigest = stringValue(operation.payload.content_digest);
|
|
75
|
+
if (!graphId || !sourceId || !targetId || !relationDigest || !contentDigest) {
|
|
76
|
+
throw new RepositoryStoreError("invalid edge addition");
|
|
77
|
+
}
|
|
78
|
+
assertLiveNodes(database, commit.repositoryId, [graphId, sourceId, targetId]);
|
|
79
|
+
assertSemanticEdgeValid(database, commit.repositoryId, graphId, sourceId, targetId);
|
|
80
|
+
try {
|
|
81
|
+
runSql(database.prepare(`INSERT INTO repository_semantic_edges (
|
|
82
|
+
repository_id, edge_id, graph_node_id, source_node_id, target_node_id,
|
|
83
|
+
relation_digest, content, content_digest, created_by_commit_id, updated_by_commit_id
|
|
84
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`), commit.repositoryId, edgeId, graphId, sourceId, targetId, relationDigest, latestValue(latestValues, edgeId).value, contentDigest, commit.commitId, commit.commitId);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
throw new RepositoryStoreError("semantic edge already exists", { cause: error });
|
|
88
|
+
}
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (operation.type === "edge.field.set.v1") {
|
|
92
|
+
const expected = stringValue(operation.payload.expected_digest);
|
|
93
|
+
const replacement = stringValue(operation.payload.new_digest);
|
|
94
|
+
if (!expected || !replacement)
|
|
95
|
+
throw new RepositoryStoreError("invalid edge field operation");
|
|
96
|
+
if (runSql(database.prepare(`UPDATE repository_semantic_edges SET content = ?, content_digest = ?, updated_by_commit_id = ?
|
|
97
|
+
WHERE repository_id = ? AND edge_id = ? AND content_digest = ?`), latestValue(latestValues, edgeId).value, replacement, commit.commitId, commit.repositoryId, edgeId, expected).changes !== 1)
|
|
98
|
+
throw new RepositoryStoreError("edge field projection precondition failed");
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const relationDigest = stringValue(operation.payload.relation_digest);
|
|
102
|
+
if (!relationDigest)
|
|
103
|
+
throw new RepositoryStoreError("invalid edge removal");
|
|
104
|
+
if (runSql(database.prepare("DELETE FROM repository_semantic_edges WHERE repository_id = ? AND edge_id = ? AND relation_digest = ?"), commit.repositoryId, edgeId, relationDigest).changes !== 1)
|
|
105
|
+
throw new RepositoryStoreError("edge relation projection precondition failed");
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=relations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"relations.js","sourceRoot":"","sources":["../../../../src/local/store/projection/relations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAKjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,eAAe,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1H,SAAS,WAAW,CAAC,KAAc;IAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,QAAsB,EAAE,MAAwB,EAAE,SAA8B;IAC5G,MAAM,QAAQ,GAAG,W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mB,EAAE,CAAC;QAC5C,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QAChE,MAAM,WAAW,GAAG,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAC9D,IAAI,CAAC,QAAQ,IAAI,CAAC,WAAW;YAAE,MAAM,IAAI,oBAAoB,CAAC,8BAA8B,CAAC,CAAC;QAC9F,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;qEACuC,CAAC,EAAE,WAAW,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,KAAK,EAC5G,WAAW,EACX,MAAM,CAAC,QAAQ,EACf,MAAM,CAAC,YAAY,EACnB,MAAM,EACN,QAAQ,CAAE,CAAC,OAAO,KAAK,CAAC;YAAE,MAAM,IAAI,oBAAoB,CAAC,2CAA2C,CAAC,CAAC;QACvG,OAAO;IACR,CAAC;IACD,MAAM,cAAc,GAAG,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACtE,IAAI,CAAC,cAAc;QAAE,MAAM,IAAI,oBAAoB,CAAC,sBAAsB,CAAC,CAAC;IAC5E,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,uGAAuG,CAAC,EAAE,MAAM,CAAC,YAAY,EACxJ,MAAM,EACN,cAAc,CAAE,CAAC,OAAO,KAAK,CAAC;QAAE,MAAM,IAAI,oBAAoB,CAAC,8CAA8C,CAAC,CAAC;AACjH,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { validateAcyclicRelation, validateSemanticEdgeScale } from "../../domain/invariants.js";
|
|
2
|
+
import { RepositoryStoreError } from "../sqlite/errors.js";
|
|
3
|
+
import { allRows, getRow } from "../sqlite/rows.js";
|
|
4
|
+
function asString(value) {
|
|
5
|
+
return typeof value === "string" ? value : undefined;
|
|
6
|
+
}
|
|
7
|
+
export function assertLiveNodes(database, repositoryId, nodeIds) {
|
|
8
|
+
const unique = [...new Set(nodeIds)];
|
|
9
|
+
const rows = allRows(database.prepare(`SELECT node_id FROM repository_nodes
|
|
10
|
+
WHERE repository_id = ? AND lifecycle_state = 'live'
|
|
11
|
+
AND node_id IN (${unique.map(() => "?").join(", ")})`), repositoryId, ...unique);
|
|
12
|
+
if (rows.length !== unique.length) {
|
|
13
|
+
throw new RepositoryStoreError("structural relation requires live repository nodes");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function assertAcyclicRelation(database, repositoryId, parentId, childId, table) {
|
|
17
|
+
if (parentId === childId) {
|
|
18
|
+
throw new RepositoryStoreError(`${table === "repository_lineage" ? "lineage" : "containment"} cycle is invalid`);
|
|
19
|
+
}
|
|
20
|
+
const parentColumn = table === "repository_lineage" ? "parent_node_id" : "container_node_id";
|
|
21
|
+
const cycle = getRow(database.prepare(`WITH RECURSIVE descendants(node_id) AS (
|
|
22
|
+
SELECT child_node_id FROM ${table}
|
|
23
|
+
WHERE repository_id = ? AND ${parentColumn} = ?
|
|
24
|
+
UNION
|
|
25
|
+
SELECT relation.child_node_id FROM ${table} AS relation
|
|
26
|
+
JOIN descendants ON relation.${parentColumn} = descendants.node_id
|
|
27
|
+
WHERE relation.repository_id = ?
|
|
28
|
+
)
|
|
29
|
+
SELECT 1 AS present FROM descendants WHERE node_id = ? LIMIT 1`), repositoryId, childId, repositoryId, parentId);
|
|
30
|
+
try {
|
|
31
|
+
validateAcyclicRelation(parentId, childId, cycle !== undefined, table === "repository_lineage" ? "lineage" : "containment");
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (error instanceof Error)
|
|
35
|
+
throw new RepositoryStoreError(error.message, { cause: error });
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
export function assertSemanticEdgeValid(database, repositoryId, graphId, sourceId, targetId) {
|
|
40
|
+
if (graphId === sourceId || graphId === targetId) {
|
|
41
|
+
throw new RepositoryStoreError("semantic edge endpoints must be descendants");
|
|
42
|
+
}
|
|
43
|
+
if (sourceId === targetId)
|
|
44
|
+
throw new RepositoryStoreError("semantic edge endpoints must be distinct");
|
|
45
|
+
const rows = allRows(database.prepare(`WITH RECURSIVE descendants(node_id, scale) AS (
|
|
46
|
+
SELECT child_node_id, 1 FROM repository_containments
|
|
47
|
+
WHERE repository_id = ? AND container_node_id = ?
|
|
48
|
+
UNION ALL
|
|
49
|
+
SELECT relation.child_node_id, descendants.scale + 1
|
|
50
|
+
FROM repository_containments AS relation
|
|
51
|
+
JOIN descendants ON relation.container_node_id = descendants.node_id
|
|
52
|
+
WHERE relation.repository_id = ?
|
|
53
|
+
)
|
|
54
|
+
SELECT node_id, scale FROM descendants WHERE node_id IN (?, ?)`, { readBigInts: true }), repositoryId, graphId, repositoryId, sourceId, targetId);
|
|
55
|
+
const scales = {};
|
|
56
|
+
for (const row of rows) {
|
|
57
|
+
const nodeId = asString(row.node_id);
|
|
58
|
+
if (nodeId && typeof row.scale === "bigint")
|
|
59
|
+
scales[nodeId] = row.scale;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
validateSemanticEdgeScale(graphId, sourceId, targetId, scales);
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
if (error instanceof Error)
|
|
66
|
+
throw new RepositoryStoreError(error.message, { cause: error });
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export function assertAllSemanticEdgesValid(database, repositoryId) {
|
|
71
|
+
for (const row of allRows(database.prepare("SELECT graph_node_id, source_node_id, target_node_id FROM repository_semantic_edges WHERE repository_id = ?"), repositoryId)) {
|
|
72
|
+
const graphId = asString(row.graph_node_id);
|
|
73
|
+
const sourceId = asString(row.source_node_id);
|
|
74
|
+
const targetId = asString(row.target_node_id);
|
|
75
|
+
if (!graphId || !sourceId || !targetId)
|
|
76
|
+
throw new RepositoryStoreError("semantic edge projection is corrupt");
|
|
77
|
+
assertSemanticEdgeValid(database, repositoryId, graphId, sourceId, targetId);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../../../src/local/store/projection/rules.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEpD,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,QAAsB,EAAE,YAAoB,EAAE,OAA0B;IACvG,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IACrC,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;;wBAEf,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,YAAY,EACxE,GAAG,MAAM,CAAE,CAAC;IACb,IAAI,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;QACnC,MAAM,IAAI,oBAAoB,CAAC,oDAAoD,CAAC,CAAC;IACtF,CAAC;AACF,CAAC;AAED,MAAM,UAAU,qBAAqB,CACpC,QAAsB,EACtB,YAAoB,EACpB,QAAgB,EAChB,OAAe,EACf,KAAuD;IAEvD,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;QAC1B,MAAM,IAAI,oBAAoB,CAAC,GAAG,KAAK,KAAK,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,a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