@unbrained/pm-cli 2026.11.21 → 2026.11.23
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/.agents/skills/pm-developer/SKILL.md +1 -1
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/cli/after-command-context-usage.js +1 -1
- package/dist/cli/argv-utils.js +1 -1
- package/dist/cli/bootstrap-args.js +1 -1
- package/dist/cli/bundle-integrity.js +2 -2
- package/dist/cli/command-namespaces.js +1 -1
- package/dist/cli/commander-usage.js +11 -11
- package/dist/cli/commands/annotations/comments.js +1 -1
- package/dist/cli/commands/annotations/docs.js +1 -1
- package/dist/cli/commands/annotations/files.js +1 -1
- package/dist/cli/commands/annotations/learnings.js +1 -1
- package/dist/cli/commands/annotations/notes.js +1 -1
- package/dist/cli/commands/extension/describe.js +1 -1
- package/dist/cli/commands/extension/extension.js +1 -1
- package/dist/cli/commands/extension/scaffold.js +1 -1
- package/dist/cli/commands/extension/shared.js +1 -1
- package/dist/cli/commands/governance/gc.js +1 -1
- package/dist/cli/commands/governance/health.js +1 -1
- package/dist/cli/commands/governance/telemetry.js +1 -1
- package/dist/cli/commands/governance/validate.js +1 -1
- package/dist/cli/commands/history/activity.js +1 -1
- package/dist/cli/commands/history/history-compact.js +1 -1
- package/dist/cli/commands/history/history-redact.js +1 -1
- package/dist/cli/commands/history/history-repair.js +1 -1
- package/dist/cli/commands/history/history.js +1 -1
- package/dist/cli/commands/history/restore.js +1 -1
- package/dist/cli/commands/lifecycle/append.js +1 -1
- package/dist/cli/commands/lifecycle/claim.js +1 -1
- package/dist/cli/commands/lifecycle/close-many.js +1 -1
- package/dist/cli/commands/lifecycle/close.js +1 -1
- package/dist/cli/commands/lifecycle/copy.js +1 -1
- package/dist/cli/commands/lifecycle/create.js +1 -1
- package/dist/cli/commands/lifecycle/delete.js +1 -1
- package/dist/cli/commands/lifecycle/focus.js +1 -1
- package/dist/cli/commands/lifecycle/plan.js +1 -1
- package/dist/cli/commands/lifecycle/update-many.js +1 -1
- package/dist/cli/commands/lifecycle/update.js +1 -1
- package/dist/cli/commands/query/aggregate.js +1 -1
- package/dist/cli/commands/query/context.js +1 -1
- package/dist/cli/commands/query/deps.js +1 -1
- package/dist/cli/commands/query/duplicates.js +1 -1
- package/dist/cli/commands/query/eval.js +1 -1
- package/dist/cli/commands/query/get.js +1 -1
- package/dist/cli/commands/query/graph.js +1 -1
- package/dist/cli/commands/query/list.js +1 -1
- package/dist/cli/commands/query/next.js +1 -1
- package/dist/cli/commands/query/search.js +1 -1
- package/dist/cli/commands/query/stats.js +1 -1
- package/dist/cli/commands/test/test-all.js +1 -1
- package/dist/cli/commands/test/test-runs.js +1 -1
- package/dist/cli/commands/test/test.js +1 -1
- package/dist/cli/commands/workspace/config.js +1 -1
- package/dist/cli/commands/workspace/contracts.js +1 -1
- package/dist/cli/commands/workspace/init.js +1 -1
- package/dist/cli/commands/workspace/merge.js +1 -1
- package/dist/cli/commands/workspace/profile.js +1 -1
- package/dist/cli/commands/workspace/schema.js +1 -1
- package/dist/cli/commands/workspace/upgrade.js +1 -1
- package/dist/cli/context-intent-invocation.js +1 -1
- package/dist/cli/description-stdin.js +1 -1
- package/dist/cli/error-guidance.js +5 -5
- package/dist/cli/expected-revisions.js +1 -1
- package/dist/cli/extension-command-help.js +6 -6
- package/dist/cli/extension-recovery.js +1 -1
- package/dist/cli/help-content.js +5 -5
- package/dist/cli/help-json-payload.js +7 -7
- package/dist/cli/invocation-profile.js +2 -2
- package/dist/cli/main.js +5 -5
- package/dist/cli/migration-gates.js +1 -1
- package/dist/cli/option-values.js +1 -1
- package/dist/cli/preflight-warnings.js +3 -3
- package/dist/cli/public.js +1 -1
- package/dist/cli/register-annotations.js +1 -1
- package/dist/cli/register-assurance.js +1 -1
- package/dist/cli/register-files-lookup.js +1 -1
- package/dist/cli/register-history-activity.js +1 -1
- package/dist/cli/register-history-author.js +1 -1
- package/dist/cli/register-history-maintenance.js +2 -2
- package/dist/cli/register-list-query.js +10 -10
- package/dist/cli/register-mutation-options.js +0 -1
- package/dist/cli/register-mutation.js +6 -6
- package/dist/cli/register-operations.js +1 -1
- package/dist/cli/register-setup.js +1 -1
- package/dist/cli/register-structured-mutation.js +1 -1
- package/dist/cli/registration-helpers.js +1 -1
- package/dist/cli/runtime/activation.js +1 -1
- package/dist/cli/runtime/annotation-option-retry.js +1 -1
- package/dist/cli/runtime/close-fields-retry.js +1 -1
- package/dist/cli/runtime/field-route-retry.js +1 -1
- package/dist/cli/runtime/invocation-options.js +1 -1
- package/dist/cli/runtime/invocation-rewrites.js +1 -1
- package/dist/cli/runtime/projection-retry.js +1 -1
- package/dist/cli/runtime/read-output-mutation-retry.js +1 -1
- package/dist/cli/runtime/refusal-credential-redaction.js +1 -1
- package/dist/cli/runtime/selection.js +1 -1
- package/dist/cli/runtime/telemetry-outcome.js +1 -1
- package/dist/cli/runtime-compatibility-boundary.js +4 -4
- package/dist/cli/schema/registration.js +15 -15
- package/dist/cli/schema-registration-helpers.js +1 -1
- package/dist/cli/search-refresh.js +1 -1
- package/dist/cli/stats-analytics-json.js +1 -1
- package/dist/cli/telemetry-flush.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/chunk-2UQU7HRR.js +9 -0
- package/dist/cli-bundle/chunks/chunk-5DUP4AZA.js +2 -0
- package/dist/cli-bundle/chunks/chunk-5WZZ5XEN.js +3 -0
- package/dist/cli-bundle/chunks/chunk-6H36ZHMI.js +2 -0
- package/dist/cli-bundle/chunks/chunk-6MYJLOSG.js +2 -0
- package/dist/cli-bundle/chunks/chunk-AA52P34H.js +3 -0
- package/dist/cli-bundle/chunks/chunk-AEOHUSUI.js +2289 -0
- package/dist/cli-bundle/chunks/chunk-BSRIVYTM.js +8 -0
- package/dist/cli-bundle/chunks/chunk-CFWLQFJM.js +71 -0
- package/dist/cli-bundle/chunks/chunk-D6PDUKUG.js +9 -0
- package/dist/cli-bundle/chunks/chunk-ENKXRSFZ.js +31 -0
- package/dist/cli-bundle/chunks/chunk-F2Z6XLZB.js +3 -0
- package/dist/cli-bundle/chunks/chunk-FJOEL75F.js +2 -0
- package/dist/cli-bundle/chunks/chunk-GDXCAC52.js +2 -0
- package/dist/cli-bundle/chunks/chunk-H7JEXRIN.js +6 -0
- package/dist/cli-bundle/chunks/chunk-J2PDAVBC.js +2 -0
- package/dist/cli-bundle/chunks/chunk-KE7HMBEW.js +2 -0
- package/dist/cli-bundle/chunks/chunk-KZHIBEJL.js +33 -0
- package/dist/cli-bundle/chunks/chunk-NGJ5ERBF.js +115 -0
- package/dist/cli-bundle/chunks/chunk-NQ54T7T2.js +2 -0
- package/dist/cli-bundle/chunks/chunk-O7JHS64G.js +3 -0
- package/dist/cli-bundle/chunks/chunk-OKEZF7HU.js +2 -0
- package/dist/cli-bundle/chunks/chunk-OKIKF4FD.js +2 -0
- package/dist/cli-bundle/chunks/chunk-OPJF254V.js +9 -0
- package/dist/cli-bundle/chunks/chunk-PZA7QECY.js +1 -0
- package/dist/cli-bundle/chunks/chunk-RWA5YZ5X.js +2 -0
- package/dist/cli-bundle/chunks/chunk-S32NGRQM.js +2 -0
- package/dist/cli-bundle/chunks/chunk-SLFRSZK6.js +1 -0
- package/dist/cli-bundle/chunks/chunk-TZY5MVJF.js +125 -0
- package/dist/cli-bundle/chunks/chunk-YYT3MIRF.js +3 -0
- package/dist/cli-bundle/chunks/chunk-ZPS4B6SI.js +8 -0
- package/dist/cli-bundle/chunks/context-budget-recovery-M5RFUEFG.js +2 -0
- package/dist/cli-bundle/chunks/indexed-receipt-blobs-BPYKN5Q7.js +4 -0
- package/dist/cli-bundle/chunks/{item-revision-R5SZPJZ5.js → item-revision-FMD4KWBB.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-SEHTH7N2.js +2 -0
- package/dist/cli-bundle/chunks/mutation-actor-SFGYIRPW.js +2 -0
- package/dist/cli-bundle/chunks/mutation-admission-57LBSKQI.js +2 -0
- package/dist/cli-bundle/chunks/{register-list-query-SPGPS3OS.js → register-list-query-L4IBU64P.js} +11 -11
- package/dist/cli-bundle/chunks/register-mutation-6NUOPHZ3.js +21 -0
- package/dist/cli-bundle/chunks/register-operations-JGYVORNN.js +2 -0
- package/dist/cli-bundle/chunks/register-setup-C44SIXEH.js +2 -0
- package/dist/cli-bundle/chunks/settlement-hook-6MR32OOC.js +7 -0
- package/dist/cli-bundle/chunks/stage-PQ7AB63N.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-6LKTEKHS.js +6 -0
- package/dist/cli-bundle/focused-chunks/chunk-6LPXMFLM.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-A6VEMCRR.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-AIDL2ZNT.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-BKPUUW5O.js +1 -0
- package/dist/cli-bundle/focused-chunks/chunk-BWOVFE5B.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-HMDQDRV2.js +8 -0
- package/dist/cli-bundle/focused-chunks/chunk-I66IKYKP.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-IIP6LZ5E.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-IR2J3NOT.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-IROZDIDX.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-ITKDHSBR.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-K53OIT5J.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-LQYYPXUK.js +26 -0
- package/dist/cli-bundle/focused-chunks/chunk-NQTEE66P.js +13 -0
- package/dist/cli-bundle/focused-chunks/chunk-O7Z73ALG.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-OTMMOKPM.js +91 -0
- package/dist/cli-bundle/focused-chunks/chunk-OXOCZJC6.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-QLAHEDT6.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-QQIIMMFU.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-RIE3SJSE.js +9 -0
- package/dist/cli-bundle/focused-chunks/chunk-TD544C74.js +8 -0
- package/dist/cli-bundle/focused-chunks/chunk-UFTUNBMY.js +27 -0
- package/dist/cli-bundle/focused-chunks/chunk-X6CXWWNB.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-XRS3VNC6.js +44 -0
- package/dist/cli-bundle/focused-chunks/chunk-XYPEZGTR.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-Y2ESLKCF.js +8 -0
- package/dist/cli-bundle/focused-chunks/chunk-YSJKQLFR.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-Z2X7HH3C.js +102 -0
- package/dist/cli-bundle/focused-chunks/chunk-ZHWPCVQL.js +78 -0
- package/dist/cli-bundle/focused-chunks/context-budget-recovery-CSJV3TY3.js +2 -0
- package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-EGEJMG3G.js +4 -0
- package/dist/cli-bundle/focused-chunks/{item-revision-3V3UIP5X.js → item-revision-YDACCDVY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/item-transaction-UKEQCTKB.js +2 -0
- package/dist/cli-bundle/focused-chunks/mutation-actor-AS465LRX.js +2 -0
- package/dist/cli-bundle/focused-chunks/mutation-admission-E5UHJZFE.js +2 -0
- package/dist/cli-bundle/focused-chunks/settlement-hook-FMLGKG7J.js +7 -0
- package/dist/cli-bundle/focused-chunks/stage-36J7YLGI.js +2 -0
- package/dist/cli-bundle/main.js +27 -27
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +5 -5
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +72 -60
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +13 -13
- package/dist/cli.js +1 -1
- package/dist/core/checkpoint/checkpoint-gc.js +1 -1
- package/dist/core/checkpoint/mutation-checkpoint.js +2 -2
- package/dist/core/checkpoint/mutation-context.js +1 -1
- package/dist/core/config/nested-settings.js +1 -1
- package/dist/core/config/positional-value.js +1 -1
- package/dist/core/diagnostics/remediation.js +1 -1
- package/dist/core/extensions/activation-summary-markdown.js +2 -2
- package/dist/core/extensions/activation-summary.js +1 -1
- package/dist/core/extensions/activation-transaction.js +1 -1
- package/dist/core/extensions/capability-usage.js +1 -1
- package/dist/core/extensions/command-hook-context.js +1 -1
- package/dist/core/extensions/command-metadata-contract.js +1 -1
- package/dist/core/extensions/command-visibility-tier.js +1 -1
- package/dist/core/extensions/contribution-inventory.js +1 -1
- package/dist/core/extensions/exporter-output-contract.js +1 -1
- package/dist/core/extensions/extension-candidate.js +1 -1
- package/dist/core/extensions/extension-capability-aliases.js +1 -1
- package/dist/core/extensions/extension-hook-runtime.js +1 -1
- package/dist/core/extensions/extension-policy.js +1 -1
- package/dist/core/extensions/extension-registries.js +1 -1
- package/dist/core/extensions/extension-runtime-helpers.js +1 -1
- package/dist/core/extensions/extension-types.js +1 -1
- package/dist/core/extensions/flag-definition-validation.js +1 -1
- package/dist/core/extensions/flag-value-types.js +1 -1
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/extensions/item-field-types.js +1 -1
- package/dist/core/extensions/item-fields.js +1 -1
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/extensions/manifest-parser.js +1 -1
- package/dist/core/extensions/manifest-schema.js +1 -1
- package/dist/core/extensions/module-graph-snapshot.js +1 -1
- package/dist/core/extensions/mutation-actor-snapshot.js +1 -1
- package/dist/core/extensions/mutation-actor.js +1 -1
- package/dist/core/extensions/preflight-ownership.js +1 -1
- package/dist/core/extensions/read-output-contract.js +1 -1
- package/dist/core/extensions/registration-contracts.js +1 -1
- package/dist/core/extensions/registration-validation.js +1 -1
- package/dist/core/extensions/registration-values.js +1 -1
- package/dist/core/extensions/reserved-host-flags.js +1 -1
- package/dist/core/extensions/runtime-registrations.js +1 -1
- package/dist/core/extensions/service-ownership.js +1 -1
- package/dist/core/extensions/version-compat.js +1 -1
- package/dist/core/extensions/version-diagnostics.js +1 -1
- package/dist/core/fs/atomic-create.js +1 -1
- package/dist/core/fs/file-glob.js +1 -1
- package/dist/core/fs/fs-utils.js +2 -2
- package/dist/core/fs/host-environment-errors.js +1 -1
- package/dist/core/fs/index.js +1 -1
- package/dist/core/fs/path-utils.js +1 -1
- package/dist/core/governance/content-fields.js +1 -1
- package/dist/core/governance/issue-codes.js +1 -1
- package/dist/core/governance/metadata-coverage.js +1 -1
- package/dist/core/history/bridge.js +2 -0
- package/dist/core/history/digest.js +1 -1
- package/dist/core/history/drift-cache.js +3 -3
- package/dist/core/history/drift-scan.js +1 -1
- package/dist/core/history/event-classification.js +1 -1
- package/dist/core/history/event-index.js +11 -11
- package/dist/core/history/history-compact-bulk.js +1 -1
- package/dist/core/history/history-diff.js +1 -1
- package/dist/core/history/history-rewrite.js +1 -1
- package/dist/core/history/history-storage-stats.js +1 -1
- package/dist/core/history/history-stream-policy.js +1 -1
- package/dist/core/history/history.d.ts +12 -0
- package/dist/core/history/history.js +2 -2
- package/dist/core/history/identity.js +1 -1
- package/dist/core/history/index.js +1 -1
- package/dist/core/history/operation-contract.js +1 -1
- package/dist/core/history/projection.js +1 -1
- package/dist/core/history/read.d.ts +9 -0
- package/dist/core/history/read.js +1 -1
- package/dist/core/history/replay.d.ts +46 -5
- package/dist/core/history/replay.js +2 -2
- package/dist/core/history/stream-summary.js +2 -2
- package/dist/core/history/tombstone.js +1 -1
- package/dist/core/history/version-address.js +1 -1
- package/dist/core/history/workspace-history.js +2 -2
- package/dist/core/io/body-file.js +1 -1
- package/dist/core/io/bulk-ids-input.js +2 -2
- package/dist/core/item/actionability.js +1 -1
- package/dist/core/item/deferred-fields.js +1 -1
- package/dist/core/item/dependency-reference.js +1 -1
- package/dist/core/item/id.js +1 -1
- package/dist/core/item/index.js +1 -1
- package/dist/core/item/item-format-version.js +1 -1
- package/dist/core/item/item-format.js +7 -7
- package/dist/core/item/item-record.js +1 -1
- package/dist/core/item/item-type-definition.js +1 -1
- package/dist/core/item/literal-mutation-input.js +1 -1
- package/dist/core/item/parent-reference-policy.js +1 -1
- package/dist/core/item/parse.js +8 -8
- package/dist/core/item/plan-lifecycle.js +1 -1
- package/dist/core/item/priority.js +1 -1
- package/dist/core/item/sprint-release-format.js +1 -1
- package/dist/core/item/status-filter.js +1 -1
- package/dist/core/item/status.js +1 -1
- package/dist/core/item/toon-decode.js +1 -1
- package/dist/core/item/type-registry.js +1 -1
- package/dist/core/item/type-synonyms.js +1 -1
- package/dist/core/lock/index.js +1 -1
- package/dist/core/lock/lock-confinement.js +1 -1
- package/dist/core/lock/lock-gc.js +1 -1
- package/dist/core/lock/lock-owner.js +1 -1
- package/dist/core/lock/lock.js +4 -4
- package/dist/core/output/linked-test-projection.js +5 -5
- package/dist/core/output/mutation-projection.js +1 -1
- package/dist/core/output/output-control.js +1 -1
- package/dist/core/output/output.js +19 -19
- package/dist/core/output/query-summary.js +1 -1
- package/dist/core/output/tabular.js +3 -3
- package/dist/core/packages/manifest.js +1 -1
- package/dist/core/packages/root.js +1 -1
- package/dist/core/policy/workflow-policy-schema.js +1 -1
- package/dist/core/policy/workflow-policy-store.js +1 -1
- package/dist/core/policy/workflow-policy.js +1 -1
- package/dist/core/profile/profile-describe.js +1 -1
- package/dist/core/profile/profile-lint.d.ts +1 -1
- package/dist/core/profile/profile-lint.js +1 -1
- package/dist/core/profile/profile-plan.js +1 -1
- package/dist/core/profile/profile-presets.js +4 -4
- package/dist/core/reproducibility/context.js +1 -1
- package/dist/core/schema/fields-file.js +2 -2
- package/dist/core/schema/item-types-file.js +2 -2
- package/dist/core/schema/runtime-field-filters.js +1 -1
- package/dist/core/schema/runtime-field-values.js +1 -1
- package/dist/core/schema/runtime-schema.js +2 -2
- package/dist/core/schema/status-defs-file.js +2 -2
- package/dist/core/schema/status-token.js +1 -1
- package/dist/core/schema/type-inference.js +1 -1
- package/dist/core/schema/type-presets.js +1 -1
- package/dist/core/schema/type-workflows.js +1 -1
- package/dist/core/search/background-refresh.js +2 -2
- package/dist/core/search/bm25.js +1 -1
- package/dist/core/search/cache.js +2 -2
- package/dist/core/search/corpus.js +1 -1
- package/dist/core/search/embedding-batches.js +1 -1
- package/dist/core/search/eval-thresholds.js +1 -1
- package/dist/core/search/eval.js +1 -1
- package/dist/core/search/http-client.js +1 -1
- package/dist/core/search/providers.js +1 -1
- package/dist/core/search/relevance.js +1 -1
- package/dist/core/search/semantic-defaults.js +1 -1
- package/dist/core/search/staleness.js +1 -1
- package/dist/core/search/vector-stores.js +2 -2
- package/dist/core/search/vectorization-metadata.js +1 -1
- package/dist/core/sentry/helpers.js +1 -1
- package/dist/core/sentry/instrument.js +1 -1
- package/dist/core/sentry/sensitive-assignments.js +1 -1
- package/dist/core/session/session-state.js +1 -1
- package/dist/core/shared/agent-session-context.js +1 -1
- package/dist/core/shared/author.js +5 -5
- package/dist/core/shared/command-line.js +1 -1
- package/dist/core/shared/command-types.js +0 -1
- package/dist/core/shared/conflict-markers.js +1 -1
- package/dist/core/shared/constants.js +1 -1
- package/dist/core/shared/error-details.js +1 -1
- package/dist/core/shared/errors.js +1 -1
- package/dist/core/shared/html-entity-decode.js +1 -1
- package/dist/core/shared/index.js +1 -1
- package/dist/core/shared/item-metadata-contract.js +1 -1
- package/dist/core/shared/lazy-module.js +1 -1
- package/dist/core/shared/levenshtein.js +1 -1
- package/dist/core/shared/memo.js +1 -1
- package/dist/core/shared/numeric-parsers.js +1 -1
- package/dist/core/shared/option-alias-visibility.js +1 -1
- package/dist/core/shared/output-unicode.js +1 -1
- package/dist/core/shared/primitives.js +1 -1
- package/dist/core/shared/process-tree.js +2 -2
- package/dist/core/shared/secret-rules.js +5 -5
- package/dist/core/shared/serial-queue.js +1 -1
- package/dist/core/shared/serialization.js +1 -1
- package/dist/core/shared/split-comma-list.js +1 -1
- package/dist/core/shared/text-normalization.js +1 -1
- package/dist/core/shared/time.js +2 -2
- package/dist/core/shared/url-credentials.js +1 -1
- package/dist/core/store/index.js +1 -1
- package/dist/core/store/item-format-migration.js +1 -1
- package/dist/core/store/item-metadata-cache.js +1 -1
- package/dist/core/store/item-metadata-query-index.js +11 -11
- package/dist/core/store/item-metadata-read-work.js +1 -1
- package/dist/core/store/item-mutation-precondition.js +1 -1
- package/dist/core/store/item-store.js +1 -1
- package/dist/core/store/paths.js +1 -1
- package/dist/core/store/settings-concurrency.js +1 -1
- package/dist/core/store/settings-read-cache.js +1 -1
- package/dist/core/store/settings-sections.js +2 -2
- package/dist/core/store/settings-validator.js +1 -1
- package/dist/core/store/settings.d.ts +3 -1
- package/dist/core/store/settings.js +6 -6
- package/dist/core/store/sqlite-runtime.js +1 -1
- package/dist/core/store/tracker-preflight.js +1 -1
- package/dist/core/store/transaction-coordinator-scope.js +1 -1
- package/dist/core/telemetry/consent.js +3 -3
- package/dist/core/telemetry/observability.js +1 -1
- package/dist/core/telemetry/policy.js +1 -1
- package/dist/core/telemetry/read-sampling.js +2 -2
- package/dist/core/telemetry/runtime.js +9 -9
- package/dist/core/test/background-runs.js +4 -4
- package/dist/core/test/item-test-run-tracking.js +1 -1
- package/dist/core/test/run-selectors.js +1 -1
- package/dist/core/validate/estimate-defaults.js +1 -1
- package/dist/core/validate/fix-planning.js +1 -1
- package/dist/core/validate/linked-artifact-reference.js +1 -1
- package/dist/core/validate/missing-by-type.js +1 -1
- package/dist/core/validate/missing-link-owners.js +1 -1
- package/dist/core/validate/stale-file-classification.js +1 -1
- package/dist/mcp/http-server.js +5 -5
- package/dist/mcp/legacy-adapter.js +1 -1
- package/dist/mcp/runtime-capabilities.js +1 -1
- package/dist/mcp/server.js +4 -4
- package/dist/mcp/tool-definitions.js +1 -1
- package/dist/sdk/actionability.js +1 -1
- package/dist/sdk/agent/closed-domain-contracts.js +1 -1
- package/dist/sdk/agent/command-recovery.js +1 -1
- package/dist/sdk/agent/command-suggestions.js +1 -1
- package/dist/sdk/agent/create-option-policy.js +1 -1
- package/dist/sdk/agent/identity-config.js +1 -1
- package/dist/sdk/agent/item-addressing.js +1 -1
- package/dist/sdk/agent/linked-resource-recovery.js +1 -1
- package/dist/sdk/agent/refusal-closure-census.js +2 -2
- package/dist/sdk/agent/refusal-corpus-contracts.js +1 -1
- package/dist/sdk/agent/subcommand-recovery.js +1 -1
- package/dist/sdk/agent-capability-contracts.js +3 -3
- package/dist/sdk/agent-session-context.js +1 -1
- package/dist/sdk/annotations.js +1 -1
- package/dist/sdk/author-attribution.js +1 -1
- package/dist/sdk/cli-bootstrap.js +1 -1
- package/dist/sdk/cli-contracts/agent-output-contracts.js +5 -5
- package/dist/sdk/cli-contracts/bootstrap-command-scanner.js +1 -1
- package/dist/sdk/cli-contracts/command-aliases.js +1 -1
- package/dist/sdk/cli-contracts/command-exit-contracts.js +1 -1
- package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1
- package/dist/sdk/cli-contracts/commander-types.js +1 -1
- package/dist/sdk/cli-contracts/completeness.js +1 -1
- package/dist/sdk/cli-contracts/enum-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +2 -2
- package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
- package/dist/sdk/cli-contracts/registration-helpers.js +7 -7
- package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
- package/dist/sdk/cli-contracts/schemas/assurance-definition.js +1 -1
- package/dist/sdk/cli-contracts/string-lists.js +1 -1
- package/dist/sdk/cli-contracts/tool-option-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/cli-contracts/typed-action-inputs.d.ts +2 -2
- package/dist/sdk/cli-contracts/typed-action-inputs.js +0 -1
- package/dist/sdk/cli-contracts.js +1 -1
- package/dist/sdk/cli-program.js +1 -1
- package/dist/sdk/command-line.js +1 -1
- package/dist/sdk/comments.js +1 -1
- package/dist/sdk/compile-cache.js +1 -1
- package/dist/sdk/completion/bash.js +2 -2
- package/dist/sdk/completion/fish.js +74 -73
- package/dist/sdk/completion/shared.js +1 -1
- package/dist/sdk/completion/zsh.js +77 -76
- package/dist/sdk/completion.js +1 -1
- package/dist/sdk/config.js +1 -1
- package/dist/sdk/context/recency.js +1 -1
- package/dist/sdk/context/semantic-session-attribution.js +1 -1
- package/dist/sdk/context/usage-egress.js +1 -1
- package/dist/sdk/context/usage-ledger.js +6 -6
- package/dist/sdk/context-intent-contracts.js +1 -1
- package/dist/sdk/context-intent-runtime.js +1 -1
- package/dist/sdk/context-packing.js +1 -1
- package/dist/sdk/context-relevance.js +1 -1
- package/dist/sdk/context-signal-store.js +2 -2
- package/dist/sdk/context-usage.js +1 -1
- package/dist/sdk/dependencies/context-budget-recovery.js +1 -1
- package/dist/sdk/dependencies.js +1 -1
- package/dist/sdk/dependency-flag-validation.js +1 -1
- package/dist/sdk/dependency-provenance.js +1 -1
- package/dist/sdk/docs.js +1 -1
- package/dist/sdk/duplicates.js +1 -1
- package/dist/sdk/environment/host-environment-errors.js +1 -1
- package/dist/sdk/environment/project-runtime-compatibility.js +2 -2
- package/dist/sdk/environment/source-context.js +1 -1
- package/dist/sdk/environment/tracker-preflight.js +1 -1
- package/dist/sdk/error-code-catalog.js +1 -1
- package/dist/sdk/error-runtime.js +1 -1
- package/dist/sdk/errors.js +1 -1
- package/dist/sdk/eval.js +1 -1
- package/dist/sdk/extension/author-manifest.js +1 -1
- package/dist/sdk/extension/bundled-catalog.js +1 -1
- package/dist/sdk/extension/command-options.js +1 -1
- package/dist/sdk/extension/concurrency.js +1 -1
- package/dist/sdk/extension/copy-scope.js +1 -1
- package/dist/sdk/extension/custom-field-collisions.js +1 -1
- package/dist/sdk/extension/describe.js +3 -3
- package/dist/sdk/extension/doctor.js +1 -1
- package/dist/sdk/extension/install-plan.js +1 -1
- package/dist/sdk/extension/install-receipts.js +1 -1
- package/dist/sdk/extension/install-runtime.js +3 -3
- package/dist/sdk/extension/install-snapshot.js +1 -1
- package/dist/sdk/extension/install-sources.js +5 -5
- package/dist/sdk/extension/managed-state.js +2 -2
- package/dist/sdk/extension/managed-update-status.js +1 -1
- package/dist/sdk/extension/migrations.js +2 -2
- package/dist/sdk/extension/native-command-options.js +1 -1
- package/dist/sdk/extension/output-ownership.js +1 -1
- package/dist/sdk/extension/runtime-summary.js +1 -1
- package/dist/sdk/extension/scaffold.js +11 -11
- package/dist/sdk/extension/shared.js +1 -1
- package/dist/sdk/extension/source-resolution.js +1 -1
- package/dist/sdk/extension/static-inventory.js +1 -1
- package/dist/sdk/extension/update-check.js +1 -1
- package/dist/sdk/extension-command-context.js +2 -2
- package/dist/sdk/extension-contracts.js +1 -1
- package/dist/sdk/extension.js +1 -1
- package/dist/sdk/files.js +1 -1
- package/dist/sdk/flag-invocation-contracts.js +1 -1
- package/dist/sdk/generated/error-code-catalog-rows.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/generated-error-code-catalog.js +1 -1
- package/dist/sdk/governance/assurance-action-contracts.js +0 -1
- package/dist/sdk/governance/assurance-action.js +1 -1
- package/dist/sdk/governance/assurance-limits.js +1 -1
- package/dist/sdk/governance/assurance-mutation-error.js +1 -1
- package/dist/sdk/governance/assurance-presets.js +1 -1
- package/dist/sdk/governance/assurance-runtime.js +1 -1
- package/dist/sdk/governance/assurance.js +4 -4
- package/dist/sdk/governance/boundary-fixtures.js +1 -1
- package/dist/sdk/governance/closure-timestamps.js +1 -1
- package/dist/sdk/governance/defect-recurrence-coverage.js +1 -1
- package/dist/sdk/governance/defect-recurrence-graph.js +1 -1
- package/dist/sdk/governance/defect-recurrence-signals.js +1 -1
- package/dist/sdk/governance/defect-recurrence.js +2 -2
- package/dist/sdk/governance/extension-host-version.js +1 -1
- package/dist/sdk/governance/gc.js +1 -1
- package/dist/sdk/governance/health/history-drift-remedies.js +2 -0
- package/dist/sdk/governance/health/projection.js +1 -1
- package/dist/sdk/governance/health-merge-evidence.js +1 -1
- package/dist/sdk/governance/health.js +2 -2
- package/dist/sdk/governance/hierarchy-validation.js +1 -1
- package/dist/sdk/governance/in-progress-work-health.js +1 -1
- package/dist/sdk/governance/lifecycle-dependency-cycles.js +1 -1
- package/dist/sdk/governance/linked-file-report.js +1 -1
- package/dist/sdk/governance/merge-receipt-history.js +1 -1
- package/dist/sdk/governance/provenance-health.js +4 -4
- package/dist/sdk/governance/reindex.js +5 -5
- package/dist/sdk/governance/stale-work.js +1 -1
- package/dist/sdk/governance/status-role-diagnostics.js +1 -1
- package/dist/sdk/governance/storage-integrity.js +1 -1
- package/dist/sdk/governance/tracked-runtime-cache.js +1 -1
- package/dist/sdk/governance/upgrade.js +2 -2
- package/dist/sdk/governance/validate-deferred-fields.js +1 -1
- package/dist/sdk/governance/validate-history-drift.js +1 -1
- package/dist/sdk/governance/validate-item-reader.js +1 -1
- package/dist/sdk/governance/validate-normalization.js +1 -1
- package/dist/sdk/governance/validate.js +1 -1
- package/dist/sdk/governance/workflow-completeness.js +1 -1
- package/dist/sdk/governance/workflow-policy.js +3 -3
- package/dist/sdk/governance/workspace-position.js +2 -2
- package/dist/sdk/graph/analytics.js +1 -1
- package/dist/sdk/graph/assembly.js +1 -1
- package/dist/sdk/graph/cache.js +1 -1
- package/dist/sdk/graph/cardinality-integrity.js +1 -1
- package/dist/sdk/graph/centrality.js +1 -1
- package/dist/sdk/graph/deadline-scheduling.js +1 -1
- package/dist/sdk/graph/durable-cache.js +1 -1
- package/dist/sdk/graph/governance-contracts.js +1 -1
- package/dist/sdk/graph/governance.js +1 -1
- package/dist/sdk/graph/hierarchy-integrity.js +1 -1
- package/dist/sdk/graph/lifecycle-coverage.js +1 -1
- package/dist/sdk/graph/mutation-advisory.js +1 -1
- package/dist/sdk/graph/query-contracts.js +1 -1
- package/dist/sdk/graph/remediation.js +1 -1
- package/dist/sdk/graph/run.js +1 -1
- package/dist/sdk/graph/scheduling.js +1 -1
- package/dist/sdk/graph/traversal.js +1 -1
- package/dist/sdk/graph/workspace-relationship-kind-registry.js +1 -1
- package/dist/sdk/guide-topics.js +1 -1
- package/dist/sdk/guide.js +7 -7
- package/dist/sdk/history/append-only-repair.d.ts +30 -0
- package/dist/sdk/history/append-only-repair.js +6 -0
- package/dist/sdk/history/attestation-command.js +2 -2
- package/dist/sdk/history/attestation-contract.js +1 -1
- package/dist/sdk/history/attestation-scan.js +1 -1
- package/dist/sdk/history/attestation.js +1 -1
- package/dist/sdk/history/maintenance.d.ts +8 -2
- package/dist/sdk/history/maintenance.js +1 -1
- package/dist/sdk/history/reanchor-refusal.js +2 -0
- package/dist/sdk/history/reseed.d.ts +15 -0
- package/dist/sdk/history/reseed.js +2 -0
- package/dist/sdk/history/salvage.d.ts +19 -8
- package/dist/sdk/history/salvage.js +5 -3
- package/dist/sdk/history/subject.js +1 -1
- package/dist/sdk/history-analytics.js +1 -1
- package/dist/sdk/history-compact.js +1 -1
- package/dist/sdk/history-mcp.js +1 -1
- package/dist/sdk/history-provenance.js +1 -1
- package/dist/sdk/history-read.js +1 -1
- package/dist/sdk/history-redact.js +1 -1
- package/dist/sdk/history-repair.d.ts +8 -2
- package/dist/sdk/history-repair.js +1 -1
- package/dist/sdk/improvement-ledger-validation.js +1 -1
- package/dist/sdk/improvement-ledger.js +2 -2
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/init-agent-guidance.js +10 -10
- package/dist/sdk/init.js +14 -14
- package/dist/sdk/invocation-author.js +1 -1
- package/dist/sdk/item-children.js +1 -1
- package/dist/sdk/item-metadata-index.js +1 -1
- package/dist/sdk/item-schedule.js +1 -1
- package/dist/sdk/item-transaction.d.ts +33 -1
- package/dist/sdk/item-transaction.js +1 -1
- package/dist/sdk/learnings.js +1 -1
- package/dist/sdk/lifecycle/append.js +3 -3
- package/dist/sdk/lifecycle/checkpoint-rollback.js +1 -1
- package/dist/sdk/lifecycle/claim.js +1 -1
- package/dist/sdk/lifecycle/cli-input.js +1 -1
- package/dist/sdk/lifecycle/close-many.js +1 -1
- package/dist/sdk/lifecycle/close.js +1 -1
- package/dist/sdk/lifecycle/copy.js +1 -1
- package/dist/sdk/lifecycle/core-field-recovery.js +1 -1
- package/dist/sdk/lifecycle/core-item-fields.js +1 -1
- package/dist/sdk/lifecycle/create-deferrals.js +1 -1
- package/dist/sdk/lifecycle/create.js +1 -1
- package/dist/sdk/lifecycle/delete.js +1 -1
- package/dist/sdk/lifecycle/dependency-removal.js +1 -1
- package/dist/sdk/lifecycle/event-validation-messages.js +1 -1
- package/dist/sdk/lifecycle/focus.js +1 -1
- package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +1 -1
- package/dist/sdk/lifecycle/item-revision.js +1 -1
- package/dist/sdk/lifecycle/legacy-none-tokens.js +1 -1
- package/dist/sdk/lifecycle/lifecycle-transitions.js +1 -1
- package/dist/sdk/lifecycle/mcp-actions.js +1 -1
- package/dist/sdk/lifecycle/metadata-normalizers.js +1 -1
- package/dist/sdk/lifecycle/mutation-command-options.js +0 -1
- package/dist/sdk/lifecycle/mutation-facet-contracts.js +1 -1
- package/dist/sdk/lifecycle/mutation-option-validation.js +1 -1
- package/dist/sdk/lifecycle/plan-mutation-receipt.js +1 -1
- package/dist/sdk/lifecycle/plan.js +1 -1
- package/dist/sdk/lifecycle/recurrence-parsers.js +1 -1
- package/dist/sdk/lifecycle/release-handoff.js +1 -1
- package/dist/sdk/lifecycle/reopen.js +1 -1
- package/dist/sdk/lifecycle/repeatable-metadata-parsers.js +2 -2
- package/dist/sdk/lifecycle/repeated-terminal-state.js +1 -1
- package/dist/sdk/lifecycle/restore.js +1 -1
- package/dist/sdk/lifecycle/shared-unset-fields.js +1 -1
- package/dist/sdk/lifecycle/start-blockers.js +1 -1
- package/dist/sdk/lifecycle/structured-mutation-plan.js +1 -1
- package/dist/sdk/lifecycle/task-composition.js +1 -1
- package/dist/sdk/lifecycle/update-many.js +1 -1
- package/dist/sdk/lifecycle/update.js +2 -2
- package/dist/sdk/lifecycle/workflow-transition.js +1 -1
- package/dist/sdk/lifecycle-completion.js +1 -1
- package/dist/sdk/lifecycle-policy.js +1 -1
- package/dist/sdk/linked-artifacts.js +2 -2
- package/dist/sdk/mcp/apps.js +5 -5
- package/dist/sdk/mcp/authorization.js +1 -1
- package/dist/sdk/mcp/discovery.js +1 -1
- package/dist/sdk/mcp/executable.js +4 -4
- package/dist/sdk/mcp/interactions.js +1 -1
- package/dist/sdk/mcp/protocol.js +1 -1
- package/dist/sdk/mcp/skills.js +3 -3
- package/dist/sdk/mcp/subscriptions.js +1 -1
- package/dist/sdk/mcp/tasks.js +2 -2
- package/dist/sdk/mcp/transport.js +1 -1
- package/dist/sdk/merge/abandoned-receipts.js +1 -1
- package/dist/sdk/merge/driver.js +7 -7
- package/dist/sdk/merge/history-scalar-rebase.js +1 -1
- package/dist/sdk/merge/ignored-artifacts.js +1 -1
- package/dist/sdk/merge/index.js +1 -1
- package/dist/sdk/merge/indexed-receipt-blobs.js +2 -2
- package/dist/sdk/merge/install.js +6 -6
- package/dist/sdk/merge/receipt-file-boundary.js +1 -1
- package/dist/sdk/merge/receipt-operation.js +1 -1
- package/dist/sdk/merge/receipt-schema.js +1 -1
- package/dist/sdk/merge/receipts.js +4 -4
- package/dist/sdk/merge/reconcile.js +1 -1
- package/dist/sdk/merge/settlement-hook.js +4 -4
- package/dist/sdk/merge/stage.js +1 -1
- package/dist/sdk/merge/three-way.d.ts +22 -3
- package/dist/sdk/merge/three-way.js +9 -3
- package/dist/sdk/merge/worktree-config.js +2 -2
- package/dist/sdk/merge.js +1 -1
- package/dist/sdk/mutation-events.js +1 -1
- package/dist/sdk/mutation-guard.js +1 -1
- package/dist/sdk/notes.js +1 -1
- package/dist/sdk/output/fit-envelope.js +1 -1
- package/dist/sdk/output/list-envelope.js +1 -1
- package/dist/sdk/output/table-rows.js +1 -1
- package/dist/sdk/output-contracts.js +1 -1
- package/dist/sdk/output-projection.js +1 -1
- package/dist/sdk/output-token-accounting.js +1 -1
- package/dist/sdk/output.js +2 -2
- package/dist/sdk/ownership-source.js +1 -1
- package/dist/sdk/package-import-adapters.js +1 -1
- package/dist/sdk/package-migrations.js +1 -1
- package/dist/sdk/package-runtime-options.js +1 -1
- package/dist/sdk/pagination.js +1 -1
- package/dist/sdk/profile.js +5 -5
- package/dist/sdk/provenance.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/activity.js +1 -1
- package/dist/sdk/query/aggregate.js +1 -1
- package/dist/sdk/query/calendar.js +4 -4
- package/dist/sdk/query/complete-list.js +1 -1
- package/dist/sdk/query/context.js +2 -2
- package/dist/sdk/query/declared-blockers.js +1 -1
- package/dist/sdk/query/duplicate-candidates.js +1 -1
- package/dist/sdk/query/get-facet-roots.js +1 -1
- package/dist/sdk/query/get.js +1 -1
- package/dist/sdk/query/history.js +1 -1
- package/dist/sdk/query/item-filter-options.js +0 -1
- package/dist/sdk/query/light-metadata.js +1 -1
- package/dist/sdk/query/list-filter-shared.js +1 -1
- package/dist/sdk/query/list.js +1 -1
- package/dist/sdk/query/multi-value-filters.js +1 -1
- package/dist/sdk/query/next-ranking-policy.js +1 -1
- package/dist/sdk/query/next-ready-budget.js +1 -1
- package/dist/sdk/query/next.js +2 -2
- package/dist/sdk/query/parsers.js +1 -1
- package/dist/sdk/query/projection-contracts.js +1 -1
- package/dist/sdk/query/search/corpus.js +2 -2
- package/dist/sdk/query/search/filters.js +1 -1
- package/dist/sdk/query/search/input.js +1 -1
- package/dist/sdk/query/search/lexical.js +1 -1
- package/dist/sdk/query/search/response.js +1 -1
- package/dist/sdk/query/search/semantic.js +3 -3
- package/dist/sdk/query/search/types.js +0 -1
- package/dist/sdk/query/search-contracts.js +1 -1
- package/dist/sdk/query/search-pagination.js +1 -1
- package/dist/sdk/query/search-rendering.js +1 -1
- package/dist/sdk/query/search.js +1 -1
- package/dist/sdk/query/window-pagination.js +1 -1
- package/dist/sdk/query/workspace-contracts.js +1 -1
- package/dist/sdk/read-output/continuation.js +1 -1
- package/dist/sdk/read-output/extension.js +1 -1
- package/dist/sdk/read-output/options.js +1 -1
- package/dist/sdk/read-output/positional-rows.js +1 -1
- package/dist/sdk/read-output/provenance.js +1 -1
- package/dist/sdk/read-output/session-result.js +0 -1
- package/dist/sdk/read-output/surfaces.js +1 -1
- package/dist/sdk/read-output/tail-retention.js +1 -1
- package/dist/sdk/read-output-budget.js +1 -1
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/read-output-rows.js +1 -1
- package/dist/sdk/read-output-session.js +1 -1
- package/dist/sdk/relationship-analytics.js +1 -1
- package/dist/sdk/relationship-context.js +1 -1
- package/dist/sdk/relationship-history.js +6 -6
- package/dist/sdk/relationship-kinds/contract.js +1 -1
- package/dist/sdk/relationships.js +1 -1
- package/dist/sdk/reproducibility/process.js +1 -1
- package/dist/sdk/runtime/actions.js +1 -1
- package/dist/sdk/runtime/context.js +1 -1
- package/dist/sdk/runtime/mutation-admission.js +1 -1
- package/dist/sdk/runtime/mutation-value-validation.js +1 -1
- package/dist/sdk/runtime/schema-preview.js +1 -1
- package/dist/sdk/runtime/schema.js +1 -1
- package/dist/sdk/runtime-action-aliases.js +1 -1
- package/dist/sdk/runtime-extended-actions.js +1 -1
- package/dist/sdk/runtime-input.d.ts +8 -2
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/runtime-primitives.d.ts +1 -1
- package/dist/sdk/runtime-primitives.js +1 -1
- package/dist/sdk/runtime-public-contracts.js +0 -1
- package/dist/sdk/runtime-stats-options.js +1 -1
- package/dist/sdk/runtime.d.ts +9 -0
- package/dist/sdk/runtime.js +1 -1
- package/dist/sdk/scheduling-shortcuts.js +1 -1
- package/dist/sdk/schema/field-option-collisions.js +2 -0
- package/dist/sdk/schema-migration.js +4 -4
- package/dist/sdk/schema.js +7 -7
- package/dist/sdk/search-refresh-worker.js +1 -1
- package/dist/sdk/similarity-scoring.js +1 -1
- package/dist/sdk/similarity.js +1 -1
- package/dist/sdk/start-task-status.js +1 -1
- package/dist/sdk/stats.js +1 -1
- package/dist/sdk/structured-mutations.d.ts +5 -5
- package/dist/sdk/structured-mutations.js +1 -1
- package/dist/sdk/telemetry-flush.js +1 -1
- package/dist/sdk/telemetry.js +4 -4
- package/dist/sdk/templates.js +3 -3
- package/dist/sdk/test/batch.js +2 -2
- package/dist/sdk/test/command-args.js +1 -1
- package/dist/sdk/test/command-resolution.js +2 -2
- package/dist/sdk/test/entry.js +2 -2
- package/dist/sdk/test/execution-receipts.js +2 -2
- package/dist/sdk/test/execution.js +5 -5
- package/dist/sdk/test/json-path.js +1 -1
- package/dist/sdk/test/linked-command-detection.js +1 -1
- package/dist/sdk/test/measurements.js +1 -1
- package/dist/sdk/test/parsers.js +1 -1
- package/dist/sdk/test/prerequisites.js +1 -1
- package/dist/sdk/test/receipt-index-snapshot.js +1 -1
- package/dist/sdk/test/run-phases.js +1 -1
- package/dist/sdk/test/runs.js +1 -1
- package/dist/sdk/test/trust.js +2 -2
- package/dist/sdk/test/update.js +1 -1
- package/dist/sdk/test/workspace-snapshot.js +1 -1
- package/dist/sdk/traceability/runtime-files-lookup.js +1 -1
- package/dist/sdk/traceability/source-traceability.js +2 -2
- package/dist/sdk/tracker-root-discovery.js +1 -1
- package/dist/sdk/transactions/item-finalization.js +2 -0
- package/dist/sdk/workspace-contracts-cache.js +1 -1
- package/dist/sdk/workspace-contracts.js +1 -1
- package/dist/sdk/workspace-memory.js +2 -2
- package/dist/sdk/workspace-snapshot.js +5 -5
- package/dist/sdk/workspace-transaction-gc.js +1 -1
- package/dist/sdk/workspace-transaction.js +2 -2
- package/dist/sdk/workspace.js +6 -6
- package/dist/types/index.js +1 -1
- package/dist/types.d.ts +20 -0
- package/dist/types.js +1 -1
- package/docs/AGENT_GUIDE.md +1 -1
- package/docs/AGENT_RUNTIME_PRIMITIVES.md +1 -1
- package/docs/COMMANDS.md +7 -3
- package/docs/EXTENSIONS.md +1 -1
- package/docs/HISTORY_RECOVERY.md +229 -5
- package/docs/README.md +2 -2
- package/docs/SDK.md +174 -5
- package/docs/SDK_CONTEXT_COORDINATION.md +3 -2
- package/marketplace.json +1 -1
- package/node_modules/tar/package.json +2 -3
- package/package.json +31 -2
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/scripts/finalize-build.mjs +63 -24
- package/scripts/prepare-build-cache.mjs +28 -1
- package/dist/cli-bundle/chunks/chunk-2DXRTIC6.js +0 -21
- package/dist/cli-bundle/chunks/chunk-5647LU3A.js +0 -2287
- package/dist/cli-bundle/chunks/chunk-6QLEXRUG.js +0 -9
- package/dist/cli-bundle/chunks/chunk-AHQB7W2H.js +0 -3
- package/dist/cli-bundle/chunks/chunk-BKSVHOWI.js +0 -2
- package/dist/cli-bundle/chunks/chunk-CASX6SFI.js +0 -2
- package/dist/cli-bundle/chunks/chunk-CIKGG34F.js +0 -2
- package/dist/cli-bundle/chunks/chunk-D6ILFXZY.js +0 -2
- package/dist/cli-bundle/chunks/chunk-DEZPZOQ7.js +0 -2
- package/dist/cli-bundle/chunks/chunk-IB7UB5TE.js +0 -2
- package/dist/cli-bundle/chunks/chunk-IUIOTAF6.js +0 -9
- package/dist/cli-bundle/chunks/chunk-JVGRFU5H.js +0 -3
- package/dist/cli-bundle/chunks/chunk-KQIZ34SF.js +0 -3
- package/dist/cli-bundle/chunks/chunk-KVBIMFUG.js +0 -6
- package/dist/cli-bundle/chunks/chunk-LQBWLNZJ.js +0 -3
- package/dist/cli-bundle/chunks/chunk-NCFCBKIP.js +0 -2
- package/dist/cli-bundle/chunks/chunk-NT5AKFE5.js +0 -31
- package/dist/cli-bundle/chunks/chunk-PJXKA4QU.js +0 -125
- package/dist/cli-bundle/chunks/chunk-RMIRNYRG.js +0 -71
- package/dist/cli-bundle/chunks/chunk-RULHZRFN.js +0 -2
- package/dist/cli-bundle/chunks/chunk-S6HB3WL2.js +0 -2
- package/dist/cli-bundle/chunks/chunk-SA4BNP3Q.js +0 -2
- package/dist/cli-bundle/chunks/chunk-SPPHDVZE.js +0 -2
- package/dist/cli-bundle/chunks/chunk-SRVTCYAU.js +0 -2
- package/dist/cli-bundle/chunks/chunk-WELSVDPU.js +0 -2
- package/dist/cli-bundle/chunks/chunk-XHJ3H5PL.js +0 -3
- package/dist/cli-bundle/chunks/chunk-XWHJIRNV.js +0 -8
- package/dist/cli-bundle/chunks/chunk-YJEBK7HU.js +0 -8
- package/dist/cli-bundle/chunks/chunk-YKJKQ7DM.js +0 -115
- package/dist/cli-bundle/chunks/chunk-YMUSRWV4.js +0 -9
- package/dist/cli-bundle/chunks/chunk-YR2KEBHP.js +0 -2
- package/dist/cli-bundle/chunks/context-budget-recovery-L2WP5S26.js +0 -2
- package/dist/cli-bundle/chunks/indexed-receipt-blobs-ITTXIN4K.js +0 -4
- package/dist/cli-bundle/chunks/item-transaction-7DFCG73I.js +0 -2
- package/dist/cli-bundle/chunks/mutation-actor-3TG636XG.js +0 -2
- package/dist/cli-bundle/chunks/mutation-admission-LICSDNNO.js +0 -2
- package/dist/cli-bundle/chunks/register-mutation-WWVECKFQ.js +0 -21
- package/dist/cli-bundle/chunks/register-operations-L6HFJNWD.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-K7UFG5TD.js +0 -2
- package/dist/cli-bundle/chunks/settlement-hook-BXN5LEQD.js +0 -7
- package/dist/cli-bundle/chunks/stage-57KH3KAC.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-3IRCYJI5.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-3V53UBHN.js +0 -9
- package/dist/cli-bundle/focused-chunks/chunk-532WZV65.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-7A4QWNZX.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-C3O6JJPO.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-CR7CGEB2.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-CU2BRAOX.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-CWWKRI5P.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-EGN2HFRU.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-GHQVM6K6.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-HGFNL5XI.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-I5LGPUWH.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-IQK5NPMG.js +0 -13
- package/dist/cli-bundle/focused-chunks/chunk-J63D6QST.js +0 -6
- package/dist/cli-bundle/focused-chunks/chunk-JMQJBZQ5.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-LNHUE4VV.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-MKM5NKD7.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-NP72ZDXE.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-OSLQD5VH.js +0 -102
- package/dist/cli-bundle/focused-chunks/chunk-QGKLRXP7.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-QSJW6NSQ.js +0 -66
- package/dist/cli-bundle/focused-chunks/chunk-RPE6IX26.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-SRDQSA6M.js +0 -91
- package/dist/cli-bundle/focused-chunks/chunk-SVOOGGAK.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-UOC6257J.js +0 -26
- package/dist/cli-bundle/focused-chunks/chunk-URJ2E6AS.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-WXMI4AV5.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-XCJSHNXK.js +0 -27
- package/dist/cli-bundle/focused-chunks/chunk-XQQSSKJI.js +0 -44
- package/dist/cli-bundle/focused-chunks/chunk-YOAYY3HE.js +0 -2
- package/dist/cli-bundle/focused-chunks/context-budget-recovery-5MKOCGY5.js +0 -2
- package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-AF4U3F3D.js +0 -4
- package/dist/cli-bundle/focused-chunks/item-transaction-HLBW7B3J.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-actor-62HKR5IO.js +0 -2
- package/dist/cli-bundle/focused-chunks/mutation-admission-X4PF2SG3.js +0 -2
- package/dist/cli-bundle/focused-chunks/settlement-hook-ARYCZQY4.js +0 -7
- package/dist/cli-bundle/focused-chunks/stage-O7T7CXBB.js +0 -2
- package/dist/sdk/agent/refusal-closure.js +0 -2
- package/dist/sdk/agent/refusal-reachability.js +0 -4
- package/dist/sdk/agent/task-transcript-contracts.js +0 -2
- package/dist/sdk/agent/tracker-preflight-contracts.js +0 -2
- package/dist/sdk/authoring.js +0 -2
- package/dist/sdk/compose.js +0 -2
- package/dist/sdk/contracts.js +0 -2
- package/dist/sdk/core-governance.js +0 -2
- package/dist/sdk/core.js +0 -2
- package/dist/sdk/corpus-shape.js +0 -2
- package/dist/sdk/define.js +0 -2
- package/dist/sdk/environment/agent-environment.js +0 -2
- package/dist/sdk/governance/artifact-ledgers.js +0 -2
- package/dist/sdk/governance/coverage-assurance.js +0 -2
- package/dist/sdk/governance/reliability.js +0 -2
- package/dist/sdk/governance.js +0 -2
- package/dist/sdk/graph/adapter.js +0 -2
- package/dist/sdk/graph/conformance.js +0 -2
- package/dist/sdk/graph/index.js +0 -2
- package/dist/sdk/graph.js +0 -2
- package/dist/sdk/index.js +0 -2
- package/dist/sdk/query.js +0 -2
- package/dist/sdk/relationship-migration.js +0 -2
- package/dist/sdk/testing.js +0 -8
- package/dist/sdk/workspace-recipe.js +0 -2
- package/docs/AGENT_PROVENANCE_ADR.md +0 -206
- package/docs/DEFECT_RECURRENCE.md +0 -257
- package/docs/PERFORMANCE.md +0 -204
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import R from"node:fs/promises";import{readFileIfExists as _,writeFileAtomic as I}from"../fs/fs-utils.js";import{acquireLock as k}from"../lock/lock.js";import{EMPTY_CANONICAL_DOCUMENT as d,EXIT_CODE as n}from"../shared/constants.js";import{PmCliError as r}from"../shared/errors.js";import{locateItem as c,readLocatedItem as s}from"../store/item-store.js";import{advanceItemMutationPreconditions as b,assertItemMutationPreconditions as l,hasActiveItemRevisionScope as u}from"../store/item-mutation-precondition.js";import{resolveGovernanceKnobs as L}from"../store/settings.js";import{invalidateHistoryDriftCacheForPath as h}from"./drift-cache.js";import{redactOptionalIdentityCredentials as j}from"../shared/url-credentials.js";function C(t){if(!t.itemDocument||t.force)return[];const o=t.itemDocument.metadata?.assignee?.trim();if(!o||o===t.author)return[];const e=j(o),i=L(t.settings);if(i.ownership_enforcement==="strict")throw new r(`Item ${t.subjectId} is assigned to ${e}. Use --force to override.`,n.CONFLICT);return i.ownership_enforcement==="warn"?[`ownership_warning:assignee_conflict:${t.subjectId}:${e}`]:[]}async function y(t){if(!u(t.pmRoot))return;const o=await c(t.pmRoot,t.subject.id,t.settings.id_prefix,t.settings.item_format,t.typeRegistry.type_to_folder),e=o===null?d:(await s(o,{schema:t.settings.schema}).catch(()=>null))?.document;e!==void 0&&l(t.pmRoot,e,t.subject.id)}async function P(t){const o=await _(t.subject.historyPath);if(o!==t.historyRawBeforeLock)throw await y(t),new r(`History for ${t.subject.id} changed while waiting for lock; retry ${t.operation}.`,n.CONFLICT);const e=await c(t.pmRoot,t.subject.id,t.settings.id_prefix,t.settings.item_format,t.typeRegistry.type_to_folder),i=e?t.readItem?await t.readItem(e):await s(e,{schema:t.settings.schema}):null;if((i?.raw??null)!==(t.currentItemRawBeforeLock??null))throw await y(t),new r(`Item ${t.subject.id} changed while waiting for lock; retry ${t.operation}.`,n.CONFLICT);return{historyRawUnderLock:o,locatedUnderLock:e,loadedItemUnderLock:i}}async function N(t){const o=t.writeHistoryRaw??I;try{await o(t.historyPath,t.nextHistoryRaw),await h(t.historyPath)}catch(e){try{t.historyRawUnderLock===null?await R.rm(t.historyPath,{force:!0}):await o(t.historyPath,t.historyRawUnderLock),await h(t.historyPath)}catch(i){throw new AggregateError([e,i],`History rewrite failed and rollback also failed: ${String(e)}`)}throw e}}async function F(t){const o=[...C({itemDocument:t.itemDocument,subjectId:t.subject.id,author:t.author,force:t.force,settings:t.settings})],e=await k(t.pmRoot,t.subject.id,t.settings.locks.ttl_seconds,t.author,!!t.force,t.settings.governance.force_required_for_stale_lock,t.settings.locks.wait_ms);try{const i=await P({pmRoot:t.pmRoot,subject:t.subject,settings:t.settings,typeRegistry:t.typeRegistry,historyRawBeforeLock:t.historyRawBeforeLock,currentItemRawBeforeLock:t.currentItemRawBeforeLock,operation:t.operation}),w=d;if(l(t.pmRoot,i.loadedItemUnderLock?.document??w,t.subject.id),await t.applyRewrite(i),u(t.pmRoot)){const f=await c(t.pmRoot,t.subject.id,t.settings.id_prefix,t.settings.item_format,t.typeRegistry.type_to_folder),g=f===null?w:(await s(f,{schema:t.settings.schema})).document;b(t.pmRoot,g,t.subject.id)}return t.applyPostRewrite&&o.push(...await t.applyPostRewrite(i)),o}finally{await e()}}export{C as checkHistoryRewriteOwnership,F as executeHistoryRewrite,P as verifyHistoryRewriteNoDrift,N as writeHistoryRawWithRollback};
|
|
2
2
|
//# sourceMappingURL=history-rewrite.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
function y(r,c,o,e,l,i="min"){const a=l==="min"?r-c:c-r,m=i==="min"?o.localeCompare(e??o):(e??o).localeCompare(o);return a<0||a===0&&e!==null&&m<0}function _(r,c){const o=Buffer.byteLength(c,"utf8");let e=0,l=null,i=null,a=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY;for(const f of c.split(/\r?\n/)){const N=f.trim();if(N==="")continue;e+=1;let n;try{n=JSON.parse(N)}catch{continue}if(n===null||typeof n!="object"||!("ts"in n)||typeof n.ts!="string")continue;const u=n.ts,p=Date.parse(u);Number.isNaN(p)||(y(p,a,u,l,"min")&&(a=p,l=u),y(p,m,u,i,"max","max")&&(m=p,i=u))}return{id:r,bytes:o,lines:e,oldest_ts:l,newest_ts:i}}function d(r,c){const o=c?.topN??5,e=Math.max(0,Math.floor(o)),l=r.map(({id:t,raw:s})=>_(t,s));let i=0,a=0,m=null,f=null,N=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(const t of l){if(i+=t.lines,a+=t.bytes,t.oldest_ts!==null){const s=Date.parse(t.oldest_ts);y(s,N,t.id,m?.id??null,"min")&&(N=s,m={id:t.id,ts:t.oldest_ts})}if(t.newest_ts!==null){const s=Date.parse(t.newest_ts);y(s,n,t.id,f?.id??null,"max")&&(n=s,f={id:t.id,ts:t.newest_ts})}}const u=e===0?[]:[...l].sort((t,s)=>s.bytes-t.bytes||t.id.localeCompare(s.id)).slice(0,e),p=e===0?[]:[...l].sort((t,s)=>s.lines-t.lines||t.id.localeCompare(s.id)).slice(0,e);return{total_streams:r.length,total_lines:i,total_bytes:a,largest_by_bytes:u,deepest_by_lines:p,oldest_entry:m,newest_entry:f}}export{d as computeHistoryStorageStats};
|
|
2
2
|
//# sourceMappingURL=history-storage-stats.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import h from"node:fs/promises";import l from"node:path";import{hasActiveOnWriteHooks as p,runActiveOnWriteHooks as d}from"../extensions/index.js";import{ensureDir as g,pathExists as m}from"../fs/fs-utils.js";import{EXIT_CODE as y}from"../shared/constants.js";import{PmCliError as _}from"../shared/errors.js";import{getHistoryPath as u}from"../store/paths.js";const f=64;function w(t){return[...new Set(t.filter(r=>r.trim().length>0))].sort((r,o)=>r.localeCompare(o))}function E(t,r){return new _(`Missing history stream for ${t}. ${r} requires history streams when settings.history.missing_stream is strict_error.`,y.NOT_FOUND)}async function I(t,r){return await g(l.dirname(t)),await(await h.open(t,"a")).close(),d({path:t,scope:"project",op:`${r}:history:auto_create`})}async function C(t,r,o){const i=[];for(let n=0;n<r.length;n+=f){const c=r.slice(n,n+f),a=await Promise.all(c.map(e=>{let s;try{s=u(t,e)}catch{return!1}return m(s)}));if(c.forEach((e,s)=>{a[s]||i.push(e)}),o&&i.length>0)break}return i}async function L(t){return S({pmRoot:t.pmRoot,settings:t.settings,itemIds:[t.itemId],commandLabel:t.commandLabel})}async function S(t){const r=w(t.itemIds),o=[],i=[],n=p(),c=t.settings.history.missing_stream==="strict_error",a=n?r:await C(t.pmRoot,r,c);for(const e of a.length===0?[]:r){const s=u(t.pmRoot,e);if(!await m(s)){if(c)throw E(e,t.commandLabel);i.push(...await I(s,t.commandLabel)),i.push(`history_stream_auto_created:${e}`),o.push(e)}}return{auto_created_ids:o,warnings:i}}export{L as enforceHistoryStreamPolicyForItem,S as enforceHistoryStreamPolicyForItems};
|
|
2
2
|
//# sourceMappingURL=history-stream-policy.js.map
|
|
@@ -19,10 +19,22 @@ export declare function hashHistoryPatch(patch:readonly HistoryPatchOp[]):string
|
|
|
19
19
|
export declare function hashHistoryStream(entries:readonly HistoryEntry[]):string;
|
|
20
20
|
/** Attach the current immutable-record integrity envelope to one history event. */
|
|
21
21
|
export declare function sealHistoryRecord(entry:HistoryEntry):HistoryEntry;
|
|
22
|
+
/**
|
|
23
|
+
* Whether a record carries a complete seal in a numeric record format newer
|
|
24
|
+
* than this runtime reads. A malformed or incomplete seal is damage, not a
|
|
25
|
+
* newer format, so it never qualifies (pm-3os5p6).
|
|
26
|
+
*/
|
|
27
|
+
export declare function hasNewerRecordSealFormat(entry:HistoryEntry):boolean;
|
|
22
28
|
/** Verify record-level attribution coverage while accepting explicit legacy item-state-only entries. */
|
|
23
29
|
export declare function verifyHistoryRecordHash(entry:HistoryEntry):{ok:true;coverage:"record_and_item_state"|"item_state_only";}|{ok:false;error:"incomplete_record_hash_envelope"|"record_hash_mismatch"|"unsupported_record_hash_version"|"unsupported_history_hash_algorithm";};
|
|
24
30
|
/** Reseal a maintenance rewrite and retain the anchors and patch digest it replaced. */
|
|
25
31
|
export declare function resealHistoryRewrite(original:HistoryEntry,rewritten:HistoryEntry,options?:Readonly<{retainOriginalPatch?:boolean;retainPriorRecord?:boolean;retainPriorRecordHash?:boolean;}>):HistoryEntry;
|
|
32
|
+
/**
|
|
33
|
+
* Whether an entry carries every field replay and chain verification read:
|
|
34
|
+
* string ts, author, op and anchors, and a well-formed patch. Bridged segments
|
|
35
|
+
* check recorded links instead of replayed states, so they require this.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isCompleteHistoryRecord(entry:HistoryEntry):boolean;
|
|
26
38
|
/** Verify that retained rewrite evidence reconstructs every available prior record envelope. */
|
|
27
39
|
export declare function verifyHistoryRewriteEvidence(entry:HistoryEntry):{ok:true;coverage:"complete"|"digest_only"|"legacy_anchor_only"|"none";}|{ok:false;error:"rewrite_evidence_invalid"|"rewrite_evidence_patch_hash_mismatch"|"rewrite_evidence_record_hash_mismatch";};declare function decodeJsonPointer(path:string):string[];declare function isDefinedPointerPath(document:unknown,path:string):boolean;
|
|
28
40
|
/** Implements hash document for the public runtime surface of this module. */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4a3c3c82-0398-549c-8910-fdc69d971cb2")}catch{}})();import jsonPatch from"fast-json-patch";import{normalizeHistoryOperationForWrite}from"./operation-contract.js";import{CURRENT_HISTORY_HASH_ALGORITHM,historyDigest,resolveHistoryHashAlgorithm}from"./digest.js";import fs from"node:fs/promises";import path from"node:path";import{EXIT_CODE,ITEM_METADATA_KEY_ORDER}from"../shared/constants.js";import{runActiveServiceOverride}from"../extensions/index.js";import{appendLineAtomic}from"../fs/fs-utils.js";import{canonicalDocument}from"../item/item-format.js";import{toItemRecord}from"../item/item-record.js";import{orderObject,sha256Hex,stableStringify}from"../shared/serialization.js";import{isMillisecondPrecisionRfc3339DateTime,nowIso}from"../shared/time.js";import{diagnoseAgentIdentity,resolveHistoryAgentIdentity,resolveHistoryAuthorSource}from"../shared/author.js";import{appendHistoryEntryWithEventIndex,removeHistoryEventIndexForHistoryPath}from"./event-index.js";import{classifyHistoryEvent}from"./event-classification.js";import{invalidateHistoryDriftCacheForPath}from"./drift-cache.js";import{PmCliError}from"../shared/errors.js";const EMPTY_LEGACY_HASH_DOCUMENT={front_matter:{},body:""},CURRENT_HISTORY_ITEM_HASH_VERSION=3,SUPPORTED_HISTORY_ITEM_HASH_VERSIONS=[1,2,3],CURRENT_HISTORY_RECORD_HASH_VERSION=1,SUPPORTED_HISTORY_RECORD_HASH_VERSIONS=[1];function hashHistoryRecord(entry){return historyDigest(stableStringify(entry),entry.hash_algorithm)}function hashHistoryPatch(patch){return sha256Hex(stableStringify(patch))}function hashHistoryStream(entries){return sha256Hex(stableStringify(entries))}function sealHistoryRecord(entry){const sealed={...entry,record_hash_version:CURRENT_HISTORY_RECORD_HASH_VERSION},{record_hash:_recordHash,...canonical}=sealed;return{...sealed,record_hash:hashHistoryRecord(canonical)}}function verifyHistoryRecordHash(entry){try{resolveHistoryHashAlgorithm(entry.hash_algorithm)}catch{return{ok:!1,error:"unsupported_history_hash_algorithm"}}if(entry.record_hash_version===void 0&&entry.record_hash===void 0)return{ok:!0,coverage:"item_state_only"};if(entry.record_hash_version===void 0||entry.record_hash===void 0)return{ok:!1,error:"incomplete_record_hash_envelope"};if(!SUPPORTED_HISTORY_RECORD_HASH_VERSIONS.includes(entry.record_hash_version))return{ok:!1,error:"unsupported_record_hash_version"};const{record_hash:_recordHash,...canonical}=entry;return hashHistoryRecord(canonical)===entry.record_hash?{ok:!0,coverage:"record_and_item_state"}:{ok:!1,error:"record_hash_mismatch"}}function createHistoryRewriteEvidence(original,options){const evidence={before_hash:original.before_hash,after_hash:original.after_hash,patch_hash:hashHistoryPatch(original.patch)};return original.hash_algorithm!==void 0&&(evidence.hash_algorithm=original.hash_algorithm),original.item_hash_version!==void 0&&(evidence.item_hash_version=original.item_hash_version),options.retainOriginalPatch&&(evidence.patch=structuredClone(original.patch)),options.retainPriorRecordHash!==!1&&original.record_hash_version!==void 0&&original.record_hash!==void 0&&(evidence.record_hash_version=original.record_hash_version,evidence.record_hash=original.record_hash,evidence.record=structuredClone(original)),evidence}function resealHistoryRewrite(original,rewritten,options={}){const originalRecordVerification=verifyHistoryRecordHash(original);if(!originalRecordVerification.ok)throw new TypeError(originalRecordVerification.error);const originalPatchHash=hashHistoryPatch(original.patch),retainsRewriteEvidence=options.retainPriorRecord===!0||original.before_hash!==rewritten.before_hash||original.after_hash!==rewritten.after_hash||original.item_hash_version!==rewritten.item_hash_version||original.hash_algorithm!==rewritten.hash_algorithm||originalPatchHash!==hashHistoryPatch(rewritten.patch),sealed=sealHistoryRecord({...rewritten,...retainsRewriteEvidence?{reanchor_evidence:[...rewritten.reanchor_evidence??[],createHistoryRewriteEvidence(original,options)]}:{}}),evidenceVerification=verifyHistoryRewriteEvidence(sealed);if(!evidenceVerification.ok)throw new TypeError(evidenceVerification.error);return sealed}function isHistoryPatch(value){return!Array.isArray(value)||Object.keys(value).length!==value.length?!1:value.every(operation=>!isRecord(operation)||typeof operation.path!="string"?!1:operation.op==="move"||operation.op==="copy"?typeof operation.from=="string":["add","replace","test"].includes(operation.op)?Object.hasOwn(operation,"value"):operation.op==="remove")}function isRetainedHistoryRecordShape(value){return isRecord(value)&&typeof value.ts=="string"&&typeof value.author=="string"&&typeof value.op=="string"&&typeof value.before_hash=="string"&&typeof value.after_hash=="string"&&isHistoryPatch(value.patch)}function hasCompleteRetainedRecordHashEnvelope(evidence){const hasVersion=evidence.record_hash_version!==void 0,hasHash=evidence.record_hash!==void 0;return hasVersion===hasHash}function isHistoryReanchorEvidence(evidence){return!isRecord(evidence)||!hasCompleteRetainedRecordHashEnvelope(evidence)||typeof evidence.before_hash!="string"||typeof evidence.after_hash!="string"||typeof evidence.patch_hash!="string"||!/^[a-f0-9]{64}$/u.test(evidence.patch_hash)||evidence.patch!==void 0&&!isHistoryPatch(evidence.patch)||evidence.record_hash_version!==void 0&&typeof evidence.record_hash_version!="number"||evidence.record_hash!==void 0&&(typeof evidence.record_hash!="string"||!/^(?:[a-f0-9]{64}|[a-f0-9]{128})$/u.test(evidence.record_hash))?!1:evidence.record===void 0||isRetainedHistoryRecordShape(evidence.record)}function isHistoryRewriteEvidenceList(evidenceEntries){try{for(const evidence of evidenceEntries){if(!isHistoryReanchorEvidence(evidence))return!1;resolveHistoryHashAlgorithm(evidence.hash_algorithm)}return!0}catch{return!1}}function matchesRetainedHistoryRecord(evidence){const record=evidence.record;return record!==void 0&&record.before_hash===evidence.before_hash&&record.after_hash===evidence.after_hash&&record.item_hash_version===evidence.item_hash_version&&record.hash_algorithm===evidence.hash_algorithm&&record.record_hash_version===evidence.record_hash_version&&record.record_hash===evidence.record_hash&&hashHistoryPatch(record.patch)===evidence.patch_hash}function reconstructPriorHistoryRecord(current,evidence,priorEvidence){if(evidence.patch&&hashHistoryPatch(evidence.patch)!==evidence.patch_hash)return{kind:"patch_hash_mismatch"};if(evidence.record)return matchesRetainedHistoryRecord(evidence)?{kind:"record",entry:evidence.record}:{kind:"record_hash_mismatch"};const priorPatch=evidence.patch??current.patch;if(hashHistoryPatch(priorPatch)!==evidence.patch_hash)return{kind:"digest_only"};const priorRecord={...current,before_hash:evidence.before_hash,after_hash:evidence.after_hash,patch:priorPatch,hash_algorithm:evidence.hash_algorithm,...evidence.item_hash_version===void 0?{}:{item_hash_version:evidence.item_hash_version},...evidence.record_hash_version===void 0?{}:{record_hash_version:evidence.record_hash_version},...evidence.record_hash===void 0?{}:{record_hash:evidence.record_hash},...priorEvidence.length===0?{}:{reanchor_evidence:priorEvidence}};return evidence.hash_algorithm===void 0&&delete priorRecord.hash_algorithm,priorEvidence.length===0&&delete priorRecord.reanchor_evidence,evidence.item_hash_version===void 0&&delete priorRecord.item_hash_version,evidence.record_hash_version===void 0||evidence.record_hash===void 0?{kind:"legacy",entry:priorRecord}:{kind:"record",entry:priorRecord}}function verifyHistoryRewriteEvidence(entry){const evidenceEntries=entry.reanchor_evidence;if(evidenceEntries===void 0)return{ok:!0,coverage:"none"};if(!Array.isArray(evidenceEntries)||!isHistoryRewriteEvidenceList(evidenceEntries))return{ok:!1,error:"rewrite_evidence_invalid"};if(evidenceEntries.length===0)return{ok:!0,coverage:"none"};let reconstructed=entry;for(let index=evidenceEntries.length-1;index>=0;index-=1){const evidence=evidenceEntries[index],prior=reconstructPriorHistoryRecord(reconstructed,evidence,evidenceEntries.slice(0,index));if(prior.kind==="patch_hash_mismatch")return{ok:!1,error:"rewrite_evidence_patch_hash_mismatch"};if(prior.kind==="record_hash_mismatch")return{ok:!1,error:"rewrite_evidence_record_hash_mismatch"};if(prior.kind==="digest_only")return{ok:!0,coverage:"digest_only"};if(prior.kind==="legacy")return{ok:!0,coverage:"legacy_anchor_only"};if(!verifyHistoryRecordHash(prior.entry).ok)return{ok:!1,error:"rewrite_evidence_record_hash_mismatch"};reconstructed=prior.entry}return{ok:!0,coverage:"complete"}}function compareOptionalStrings(left,right){return(left??"").localeCompare(right??"")}function compareOptionalNumbers(left,right){return(left??0)-(right??0)}function compareJsonValues(left,right,fallback){return JSON.stringify(left??fallback).localeCompare(JSON.stringify(right??fallback))}function compareLegacyLinkedTests(left,right){return[left.scope.localeCompare(right.scope),compareOptionalStrings(left.path,right.path),compareOptionalStrings(left.command,right.command),compareOptionalNumbers(left.timeout_seconds,right.timeout_seconds),compareOptionalStrings(left.pm_context_mode,right.pm_context_mode),+!!left.shared_host_safe-+!!right.shared_host_safe,compareJsonValues(left.env_clear,right.env_clear,[]),compareJsonValues(left.env_set,right.env_set,{}),compareJsonValues(left.assert_stdout_contains,right.assert_stdout_contains,[]),compareJsonValues(left.assert_stdout_regex,right.assert_stdout_regex,[]),compareJsonValues(left.assert_stderr_contains,right.assert_stderr_contains,[]),compareJsonValues(left.assert_stderr_regex,right.assert_stderr_regex,[]),compareOptionalNumbers(left.assert_stdout_min_lines,right.assert_stdout_min_lines),compareJsonValues(left.assert_json_field_equals,right.assert_json_field_equals,{}),compareJsonValues(left.assert_json_field_gte,right.assert_json_field_gte,{}),compareOptionalStrings(left.note,right.note)].find(comparison=>comparison!==0)??0}function decodeJsonPointer(path2){return!path2||path2==="/"?[]:path2.startsWith("/")?path2.slice(1).split("/").map(segment=>segment.replaceAll("~1","/").replaceAll("~0","~")):[]}function isDefinedPointerPath(document,path2){const segments=decodeJsonPointer(path2);if(segments.length===0)return!0;let cursor=document;for(const segment of segments){const arrayIndex=/^(0|[1-9]\d*)$/.test(segment)?Number(segment):-1,next=Array.isArray(cursor)?arrayIndex>=0&&arrayIndex<cursor.length?cursor[arrayIndex]:void 0:isRecord(cursor)&&Object.prototype.hasOwnProperty.call(cursor,segment)?cursor[segment]:void 0;if(next===void 0)return!1;cursor=next}return!0}function normalizeHistoryPatchOps(beforeDocument,patch){const normalized=[];let replayCursor=structuredClone(beforeDocument);for(const operation of patch){const normalizedOperation=operation.op==="replace"&&!isDefinedPointerPath(replayCursor,operation.path)?{...operation,op:"add"}:operation;normalized.push(normalizedOperation),replayCursor=jsonPatch.applyPatch(replayCursor,[normalizedOperation],!0,!0).newDocument}return normalized}function canonicalHashDocument(document,version,legacyV2Fields=!1){if(!(document.metadata&&Object.keys(document.metadata).length>0))return{front_matter:{},body:document.body??""};const canonical=canonicalDocument(document),epochMetadata=version===1||version===2&&legacyV2Fields?{...canonical.metadata,...canonical.metadata.dependencies===void 0?{}:{dependencies:canonical.metadata.dependencies.map(dependency=>({...dependency,id:dependency.id.toLowerCase()}))},...canonical.metadata.tests===void 0?{}:{tests:canonical.metadata.tests.map(({workspace_context_mode:_workspaceContextMode,provenance:_provenance,provenance_invalid:_provenanceInvalid,...test})=>test)},...canonical.metadata.test_runs===void 0?{}:{test_runs:canonical.metadata.test_runs.map(({executions:_executions,...testRun})=>testRun)}}:canonical.metadata,metadata=version===1&&epochMetadata.tests?{...epochMetadata,tests:[...epochMetadata.tests].sort(compareLegacyLinkedTests)}:epochMetadata;return{front_matter:orderObject(toItemRecord(metadata),ITEM_METADATA_KEY_ORDER),body:canonical.body}}function canonicalPatchDocument(document){if(!(document.metadata&&Object.keys(document.metadata).length>0))return{metadata:{},body:document.body??""};const canonical=canonicalDocument(document);return{metadata:orderObject(toItemRecord(canonical.metadata),ITEM_METADATA_KEY_ORDER),body:canonical.body}}function hashDocument(document){return hashDocumentForVersion(document,CURRENT_HISTORY_ITEM_HASH_VERSION)}function hashDocumentForVersion(document,version,algorithm){if(!SUPPORTED_HISTORY_ITEM_HASH_VERSIONS.some(supportedVersion=>supportedVersion===version))throw new TypeError(`unsupported_item_hash_version:${String(version)}`);return historyDigest(stableStringify(canonicalHashDocument(document,version)),algorithm)}function hashDocumentVerificationCandidates(document,version,algorithm){const canonicalHash=hashDocumentForVersion(document,version,algorithm);return version===2?[canonicalHash,historyDigest(stableStringify(canonicalHashDocument(document,version,!0)),algorithm)]:[canonicalHash]}function hashEmptyDocument(){return sha256Hex(stableStringify(EMPTY_LEGACY_HASH_DOCUMENT))}function createHistoryEntry(params){const operation=normalizeHistoryOperationForWrite(params.op),beforeHashCanonical=canonicalHashDocument(params.before,CURRENT_HISTORY_ITEM_HASH_VERSION),afterHashCanonical=canonicalHashDocument(params.after,CURRENT_HISTORY_ITEM_HASH_VERSION),beforePatchCanonical=canonicalPatchDocument(params.before),afterPatchCanonical=canonicalPatchDocument(params.after),rawPatch=jsonPatch.compare(beforePatchCanonical,afterPatchCanonical),patch=normalizeHistoryPatchOps(beforePatchCanonical,rawPatch),agentIdentity=resolveHistoryAgentIdentity(params.author),provenanceOutcomes=agentIdentity.harness?Object.fromEntries(Object.entries(diagnoseAgentIdentity().provenance_outcomes).filter(([dimension,outcome])=>outcome.resolver!==void 0&&(outcome.status!=="resolved"||agentIdentity.provenance?.[dimension]?.source==="probe"))):void 0,context=provenanceOutcomes===void 0||Object.keys(provenanceOutcomes).length===0?params.context:{...params.context,agent_provenance_outcomes:provenanceOutcomes},algorithm=params.hashAlgorithm??CURRENT_HISTORY_HASH_ALGORITHM,entry={hash_algorithm:algorithm,ts:params.nowIso,author:params.author,author_source:params.authorSource??resolveHistoryAuthorSource(params.author),...agentIdentity.harness?{agent_harness:agentIdentity.harness}:{},...agentIdentity.model?{agent_model:agentIdentity.model}:{},...agentIdentity.model_source?{agent_model_source:agentIdentity.model_source}:{},...agentIdentity.instance?{agent_instance:agentIdentity.instance}:{},...agentIdentity.provenance?{agent_provenance:agentIdentity.provenance}:{},...agentIdentity.episode?{agent_episode:agentIdentity.episode}:{},op:operation,patch,before_hash:historyDigest(stableStringify(beforeHashCanonical),algorithm),after_hash:historyDigest(stableStringify(afterHashCanonical),algorithm),item_hash_version:CURRENT_HISTORY_ITEM_HASH_VERSION,message:params.message===void 0?void 0:params.message,...context===void 0?{}:{context}};return sealHistoryRecord({...entry,event_class:classifyHistoryEvent(entry)})}function isRecord(value){return typeof value=="object"&&value!==null&&!Array.isArray(value)}function invalidHistoryTimestamp(message){return new PmCliError(message,EXIT_CODE.GENERIC_FAILURE,{code:"history_timestamp_invalid"})}function fallbackHistoryTimestamp(entry){const ts=entry.ts.trim();if(ts.length===0)return nowIso();if(!isMillisecondPrecisionRfc3339DateTime(ts))throw invalidHistoryTimestamp("History timestamp must be a valid RFC 3339 date-time with millisecond precision");if(ts!==entry.ts)throw invalidHistoryTimestamp("History timestamp must not contain surrounding whitespace");return entry.ts}function withHistoryTimestamp(value,fallbackTs){const ts=value.ts;if(typeof ts=="string"&&ts.trim().length>0){if(!isMillisecondPrecisionRfc3339DateTime(ts))throw invalidHistoryTimestamp("History timestamp must be a valid RFC 3339 date-time with millisecond precision");return value}return{...value,ts:fallbackTs}}function serializeHistoryLine(value,fallbackEntry){const fallbackTs=fallbackHistoryTimestamp(fallbackEntry);if(typeof value=="string"){let parsed;try{parsed=JSON.parse(value)}catch{return value}return isRecord(parsed)?JSON.stringify(withHistoryTimestamp(parsed,fallbackTs)):value}return isRecord(value)?JSON.stringify(withHistoryTimestamp(value,fallbackTs)):JSON.stringify(value)}async function applyHistoryAppendOverride(historyPath,entry,result){if(result===!1)return!0;if(typeof result=="string"){const line2=serializeHistoryLine(result,entry);return await appendHistoryLineWithIdentityReservation(historyPath,line2),await invalidateHistoryDriftCacheForPath(historyPath),await removeHistoryEventIndexForHistoryPath(historyPath),!0}if(typeof result!="object"||result===null)return!1;const record=result;if(record.skip===!0)return!0;const nextHistoryPath=typeof record.history_path=="string"?record.history_path:historyPath,line=serializeHistoryLine(typeof record.line=="string"?record.line:record.entry??entry,entry);return await appendHistoryLineWithIdentityReservation(nextHistoryPath,line),await invalidateHistoryDriftCacheForPath(nextHistoryPath),await removeHistoryEventIndexForHistoryPath(nextHistoryPath),!0}async function appendHistoryLineWithIdentityReservation(historyPath,line){let record;try{record=JSON.parse(line)}catch{record=null}if(!isRecord(record)||record.op!=="create"){await appendLineAtomic(historyPath,line);return}await fs.mkdir(path.dirname(historyPath),{recursive:!0});try{await fs.writeFile(historyPath,`${line}
|
|
2
|
-
`,{encoding:"utf8",flag:"wx"})}catch(
|
|
1
|
+
import C from"fast-json-patch";import{normalizeHistoryOperationForWrite as Z}from"./operation-contract.js";import{CURRENT_HISTORY_HASH_ALGORITHM as ee,historyDigest as p,resolveHistoryHashAlgorithm as b}from"./digest.js";import I from"node:fs/promises";import re from"node:path";import{EXIT_CODE as T,ITEM_METADATA_KEY_ORDER as A}from"../shared/constants.js";import{runActiveServiceOverride as te}from"../extensions/index.js";import{appendLineAtomic as oe}from"../fs/fs-utils.js";import{canonicalDocument as N}from"../item/item-format.js";import{toItemRecord as D}from"../item/item-record.js";import{orderObject as P,sha256Hex as w,stableStringify as c}from"../shared/serialization.js";import{isMillisecondPrecisionRfc3339DateTime as M,nowIso as ne}from"../shared/time.js";import{diagnoseAgentIdentity as se,resolveHistoryAgentIdentity as ae,resolveHistoryAuthorSource as ie}from"../shared/author.js";import{appendHistoryEntryWithEventIndex as he,removeHistoryEventIndexForHistoryPath as j}from"./event-index.js";import{classifyHistoryEvent as L}from"./event-classification.js";import{invalidateHistoryDriftCacheForPath as E}from"./drift-cache.js";import{PmCliError as F}from"../shared/errors.js";const ce={front_matter:{},body:""},g=3,de=[1,2,3],_e=1,V=[1];function J(e){return p(c(e),e.hash_algorithm)}function u(e){return w(c(e))}function Fe(e){return w(c(e))}function O(e){const r={...e,record_hash_version:_e},{record_hash:t,...o}=r;return{...r,record_hash:J(o)}}function Ve(e){const r=e.record_hash_version;return typeof r=="number"&&Number.isInteger(r)&&r>Math.max(...V)&&typeof e.record_hash=="string"&&e.record_hash.length>0}function Y(e){try{b(e.hash_algorithm)}catch{return{ok:!1,error:"unsupported_history_hash_algorithm"}}if(e.record_hash_version===void 0&&e.record_hash===void 0)return{ok:!0,coverage:"item_state_only"};if(e.record_hash_version===void 0||e.record_hash===void 0)return{ok:!1,error:"incomplete_record_hash_envelope"};if(!V.includes(e.record_hash_version))return{ok:!1,error:"unsupported_record_hash_version"};const{record_hash:r,...t}=e;return J(t)===e.record_hash?{ok:!0,coverage:"record_and_item_state"}:{ok:!1,error:"record_hash_mismatch"}}function fe(e,r){const t={before_hash:e.before_hash,after_hash:e.after_hash,patch_hash:u(e.patch)};return e.hash_algorithm!==void 0&&(t.hash_algorithm=e.hash_algorithm),e.item_hash_version!==void 0&&(t.item_hash_version=e.item_hash_version),r.retainOriginalPatch&&(t.patch=structuredClone(e.patch)),r.retainPriorRecordHash!==!1&&e.record_hash_version!==void 0&&e.record_hash!==void 0&&(t.record_hash_version=e.record_hash_version,t.record_hash=e.record_hash,t.record=structuredClone(e)),t}function Je(e,r,t={}){const o=Y(e);if(!o.ok)throw new TypeError(o.error);const n=u(e.patch),s=t.retainPriorRecord===!0||e.before_hash!==r.before_hash||e.after_hash!==r.after_hash||e.item_hash_version!==r.item_hash_version||e.hash_algorithm!==r.hash_algorithm||n!==u(r.patch),i=O({...r,...s?{reanchor_evidence:[...r.reanchor_evidence??[],fe(e,t)]}:{}}),f=ge(i);if(!f.ok)throw new TypeError(f.error);return i}function U(e){return!Array.isArray(e)||Object.keys(e).length!==e.length?!1:e.every(r=>!_(r)||typeof r.path!="string"?!1:r.op==="move"||r.op==="copy"?typeof r.from=="string":["add","replace","test"].includes(r.op)?Object.hasOwn(r,"value"):r.op==="remove")}function z(e){return _(e)&&typeof e.ts=="string"&&typeof e.author=="string"&&typeof e.op=="string"&&typeof e.before_hash=="string"&&typeof e.after_hash=="string"&&U(e.patch)}function Ye(e){return z(e)}function ue(e){const r=e.record_hash_version!==void 0,t=e.record_hash!==void 0;return r===t}function me(e){return!_(e)||!ue(e)||typeof e.before_hash!="string"||typeof e.after_hash!="string"||typeof e.patch_hash!="string"||!/^[a-f0-9]{64}$/u.test(e.patch_hash)||e.patch!==void 0&&!U(e.patch)||e.record_hash_version!==void 0&&typeof e.record_hash_version!="number"||e.record_hash!==void 0&&(typeof e.record_hash!="string"||!/^(?:[a-f0-9]{64}|[a-f0-9]{128})$/u.test(e.record_hash))?!1:e.record===void 0||z(e.record)}function pe(e){try{for(const r of e){if(!me(r))return!1;b(r.hash_algorithm)}return!0}catch{return!1}}function le(e){const r=e.record;return r!==void 0&&r.before_hash===e.before_hash&&r.after_hash===e.after_hash&&r.item_hash_version===e.item_hash_version&&r.hash_algorithm===e.hash_algorithm&&r.record_hash_version===e.record_hash_version&&r.record_hash===e.record_hash&&u(r.patch)===e.patch_hash}function ye(e,r,t){if(r.patch&&u(r.patch)!==r.patch_hash)return{kind:"patch_hash_mismatch"};if(r.record)return le(r)?{kind:"record",entry:r.record}:{kind:"record_hash_mismatch"};const o=r.patch??e.patch;if(u(o)!==r.patch_hash)return{kind:"digest_only"};const n={...e,before_hash:r.before_hash,after_hash:r.after_hash,patch:o,hash_algorithm:r.hash_algorithm,...r.item_hash_version===void 0?{}:{item_hash_version:r.item_hash_version},...r.record_hash_version===void 0?{}:{record_hash_version:r.record_hash_version},...r.record_hash===void 0?{}:{record_hash:r.record_hash},...t.length===0?{}:{reanchor_evidence:t}};return r.hash_algorithm===void 0&&delete n.hash_algorithm,t.length===0&&delete n.reanchor_evidence,r.item_hash_version===void 0&&delete n.item_hash_version,r.record_hash_version===void 0||r.record_hash===void 0?{kind:"legacy",entry:n}:{kind:"record",entry:n}}function ge(e){const r=e.reanchor_evidence;if(r===void 0)return{ok:!0,coverage:"none"};if(!Array.isArray(r)||!pe(r))return{ok:!1,error:"rewrite_evidence_invalid"};if(r.length===0)return{ok:!0,coverage:"none"};let t=e;for(let o=r.length-1;o>=0;o-=1){const n=r[o],s=ye(t,n,r.slice(0,o));if(s.kind==="patch_hash_mismatch")return{ok:!1,error:"rewrite_evidence_patch_hash_mismatch"};if(s.kind==="record_hash_mismatch")return{ok:!1,error:"rewrite_evidence_record_hash_mismatch"};if(s.kind==="digest_only")return{ok:!0,coverage:"digest_only"};if(s.kind==="legacy")return{ok:!0,coverage:"legacy_anchor_only"};if(!Y(s.entry).ok)return{ok:!1,error:"rewrite_evidence_record_hash_mismatch"};t=s.entry}return{ok:!0,coverage:"complete"}}function H(e,r){return(e??"").localeCompare(r??"")}function $(e,r){return(e??0)-(r??0)}function d(e,r,t){return JSON.stringify(e??t).localeCompare(JSON.stringify(r??t))}function He(e,r){return[e.scope.localeCompare(r.scope),H(e.path,r.path),H(e.command,r.command),$(e.timeout_seconds,r.timeout_seconds),H(e.pm_context_mode,r.pm_context_mode),+!!e.shared_host_safe-+!!r.shared_host_safe,d(e.env_clear,r.env_clear,[]),d(e.env_set,r.env_set,{}),d(e.assert_stdout_contains,r.assert_stdout_contains,[]),d(e.assert_stdout_regex,r.assert_stdout_regex,[]),d(e.assert_stderr_contains,r.assert_stderr_contains,[]),d(e.assert_stderr_regex,r.assert_stderr_regex,[]),$(e.assert_stdout_min_lines,r.assert_stdout_min_lines),d(e.assert_json_field_equals,r.assert_json_field_equals,{}),d(e.assert_json_field_gte,r.assert_json_field_gte,{}),H(e.note,r.note)].find(o=>o!==0)??0}function W(e){return!e||e==="/"?[]:e.startsWith("/")?e.slice(1).split("/").map(r=>r.replaceAll("~1","/").replaceAll("~0","~")):[]}function q(e,r){const t=W(r);if(t.length===0)return!0;let o=e;for(const n of t){const s=/^(0|[1-9]\d*)$/.test(n)?Number(n):-1,i=Array.isArray(o)?s>=0&&s<o.length?o[s]:void 0:_(o)&&Object.prototype.hasOwnProperty.call(o,n)?o[n]:void 0;if(i===void 0)return!1;o=i}return!0}function Re(e,r){const t=[];let o=structuredClone(e);for(const n of r){const s=n.op==="replace"&&!q(o,n.path)?{...n,op:"add"}:n;t.push(s),o=C.applyPatch(o,[s],!0,!0).newDocument}return t}function R(e,r,t=!1){if(!(e.metadata&&Object.keys(e.metadata).length>0))return{front_matter:{},body:e.body??""};const n=N(e),i=r===1||r===2&&t?{...n.metadata,...n.metadata.dependencies===void 0?{}:{dependencies:n.metadata.dependencies.map(h=>({...h,id:h.id.toLowerCase()}))},...n.metadata.tests===void 0?{}:{tests:n.metadata.tests.map(({workspace_context_mode:h,provenance:m,provenance_invalid:l,...y})=>y)},...n.metadata.test_runs===void 0?{}:{test_runs:n.metadata.test_runs.map(({executions:h,...m})=>m)}}:n.metadata,f=r===1&&i.tests?{...i,tests:[...i.tests].sort(He)}:i;return{front_matter:P(D(f),A),body:n.body}}function G(e){if(!(e.metadata&&Object.keys(e.metadata).length>0))return{metadata:{},body:e.body??""};const t=N(e);return{metadata:P(D(t.metadata),A),body:t.body}}function Ue(e){return B(e,g)}function B(e,r,t){if(!de.some(o=>o===r))throw new TypeError(`unsupported_item_hash_version:${String(r)}`);return p(c(R(e,r)),t)}function ze(e,r,t){const o=B(e,r,t);return r===2?[o,p(c(R(e,r,!0)),t)]:[o]}function $e(){return w(c(ce))}function We(e){const r=Z(e.op),t=R(e.before,g),o=R(e.after,g),n=G(e.before),s=G(e.after),i=C.compare(n,s),f=Re(n,i),a=ae(e.author),h=a.harness?Object.fromEntries(Object.entries(se().provenance_outcomes).filter(([Q,S])=>S.resolver!==void 0&&(S.status!=="resolved"||a.provenance?.[Q]?.source==="probe"))):void 0,m=h===void 0||Object.keys(h).length===0?e.context:{...e.context,agent_provenance_outcomes:h},l=e.hashAlgorithm??ee,y={hash_algorithm:l,ts:e.nowIso,author:e.author,author_source:e.authorSource??ie(e.author),...a.harness?{agent_harness:a.harness}:{},...a.model?{agent_model:a.model}:{},...a.model_source?{agent_model_source:a.model_source}:{},...a.instance?{agent_instance:a.instance}:{},...a.provenance?{agent_provenance:a.provenance}:{},...a.episode?{agent_episode:a.episode}:{},op:r,patch:f,before_hash:p(c(t),l),after_hash:p(c(o),l),item_hash_version:g,message:e.message===void 0?void 0:e.message,...m===void 0?{}:{context:m}};return O({...y,event_class:L(y)})}function _(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function x(e){return new F(e,T.GENERIC_FAILURE,{code:"history_timestamp_invalid"})}function X(e){const r=e.ts.trim();if(r.length===0)return ne();if(!M(r))throw x("History timestamp must be a valid RFC 3339 date-time with millisecond precision");if(r!==e.ts)throw x("History timestamp must not contain surrounding whitespace");return e.ts}function K(e,r){const t=e.ts;if(typeof t=="string"&&t.trim().length>0){if(!M(t))throw x("History timestamp must be a valid RFC 3339 date-time with millisecond precision");return e}return{...e,ts:r}}function v(e,r){const t=X(r);if(typeof e=="string"){let o;try{o=JSON.parse(e)}catch{return e}return _(o)?JSON.stringify(K(o,t)):e}return _(e)?JSON.stringify(K(e,t)):JSON.stringify(e)}async function be(e,r,t){if(t===!1)return!0;if(typeof t=="string"){const i=v(t,r);return await k(e,i),await E(e),await j(e),!0}if(typeof t!="object"||t===null)return!1;const o=t;if(o.skip===!0)return!0;const n=typeof o.history_path=="string"?o.history_path:e,s=v(typeof o.line=="string"?o.line:o.entry??r,r);return await k(n,s),await E(n),await j(n),!0}async function k(e,r){let t;try{t=JSON.parse(r)}catch{t=null}if(!_(t)||t.op!=="create"){await oe(e,r);return}await I.mkdir(re.dirname(e),{recursive:!0});try{await I.writeFile(e,`${r}
|
|
2
|
+
`,{encoding:"utf8",flag:"wx"})}catch(o){throw o.code!=="EEXIST"?o:new F("This item identity is reserved by an existing history stream.",T.CONFLICT,{code:"item_identity_reserved",required:"Choose a new item ID or restore the original item from its history.",nextSteps:["Run pm history <id> --full, then pm restore <id> <version> to recover the original item."]})}}async function qe(e,r){const t=await te("history_append",{history_path:e,entry:r});if(t.handled&&await be(e,r,t.result))return;const o=r.ts.trim().length>0?r:{...r,ts:X(r)},n=O({...o,hash_algorithm:b(o.hash_algorithm),event_class:L(o)});await he(e,n,async()=>{await k(e,v(n,n))}),await E(e)}const Ge={decodeJsonPointer:W,isDefinedPointerPath:q};export{g as CURRENT_HISTORY_ITEM_HASH_VERSION,_e as CURRENT_HISTORY_RECORD_HASH_VERSION,de as SUPPORTED_HISTORY_ITEM_HASH_VERSIONS,V as SUPPORTED_HISTORY_RECORD_HASH_VERSIONS,Ge as _testOnly,qe as appendHistoryEntry,We as createHistoryEntry,Ve as hasNewerRecordSealFormat,Ue as hashDocument,B as hashDocumentForVersion,ze as hashDocumentVerificationCandidates,$e as hashEmptyDocument,u as hashHistoryPatch,J as hashHistoryRecord,Fe as hashHistoryStream,Ye as isCompleteHistoryRecord,Je as resealHistoryRewrite,O as sealHistoryRecord,Y as verifyHistoryRecordHash,ge as verifyHistoryRewriteEvidence};
|
|
3
3
|
//# sourceMappingURL=history.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
function r(n){const i=[],c=n[0]?.op==="history_compact_baseline";let e=c?1:void 0,t=!1;for(const[o,s]of n.entries())s.op==="delete"&&(t=!0),s.op==="create"&&(e!==void 0&&i.push({prior_genesis_index:e,repeated_create_index:o+1,sequence:t?"delete_then_create":c?"checkpoint_then_create":"multiple_creates"}),e??=o+1,t=!1);return i}export{r as findHistoryIdentityDiscontinuities};
|
|
2
2
|
//# sourceMappingURL=identity.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export*from"./history.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
const o=["append","cancel","claim","close","comment_add","comment_edit","comment_delete","create","delete","docs_add","docs_remove","files_add","files_remove","files_discover","history_author_acknowledge","history_compact","history_compact_baseline","history_redact","history_repair","history_salvage","import","improvement_observe","learning_add","learning_edit","learning_delete","normalize","note_add","note_edit","note_delete","plan_create_metadata","plan_create_initial_step","plan_add_step","plan_reorder_step","plan_remove_step","plan_link_step","plan_unlink_step","plan_append_decision","plan_append_discovery","plan_append_validation","plan_resume","plan_approve","plan_materialize","plan_update_step","plan_complete_step","plan_block_step","policy_approve","policy_refused","release","reopen","restore","schema_migration","schema_migration_reference","test_run_track","tests_add","tests_remove","tests_update","update","update_audit","update_ownership_bypass","workspace_snapshot_restore","extension_migrations_apply","merge_reconcile"],s=["history:author-acknowledge","settings:write","init:type_preset","templates:save","profile:apply-types","profile:apply-statuses","profile:apply-fields","profile:apply-config","schema:add-type","schema:remove-type","schema:add-status","schema:remove-status","schema:add-field","schema:remove-field","schema:apply-preset","schema:infer-types","schema:policy-put","schema:policy-remove","schema:policy-mode","assurance:bundle:apply","assurance:gate:verdict","telemetry:install_id","telemetry:first_run_prompt","telemetry:clear","item_format:auto_select_default","transaction_abandon"],r={"init:type-preset":"init:type_preset"},n=["^config:(?:set|unset):[a-z][a-z0-9_.:-]*$","^assurance:(?:measurement|invariant|gate):(?:put|remove)$","^schema_(?:rename_type|rename_status|remap_status|rename_field|remove_type|remove_status|remove_field)(?:_compensate)?$","^extension:[a-z][a-z0-9_-]*:[a-z][a-z0-9_]*$"],m={version:1,item:o,workspace:s,aliases:r,patterns:n,read_policy:"preserve_original_operation",custom_operation_grammar:"extension:<package_name>:<snake_case_operation>",legacy_custom_operation_grammar:"lowercase segments separated by underscore, hyphen, colon, or dot; optional opaque colon-suffixed retry key",excluded_surfaces:["json_patch","on_write_hook","telemetry_span"]},c=new Set([...o,...s]),l=n.map(t=>new RegExp(t,"u"));function p(t){return Object.hasOwn(r,t)?r[t]:t}function d(t){const e=p(t);if(c.has(e)||l.some(a=>a.test(e)))return e;throw new TypeError("Undeclared history operation; use a native contract identity or extension:<package_name>:<snake_case_operation>.")}function u(t){const e=p(t),a=e.indexOf(":"),i=a<0?e:e.slice(0,a),_=a<0||a<e.length-1&&!/[\s\p{C}]/u.test(e.slice(a+1));if(/^[a-z][a-z0-9]*(?:[_.-][a-z0-9]+)*$/u.test(i)&&_)return e;throw new TypeError("History operation must use lowercase alphanumeric segments with an optional non-whitespace colon-suffixed retry key.")}export{r as PM_HISTORY_OPERATION_ALIASES,m as PM_HISTORY_OPERATION_CONTRACT,n as PM_HISTORY_OPERATION_PATTERNS,o as PM_ITEM_HISTORY_OPERATIONS,s as PM_WORKSPACE_HISTORY_OPERATIONS,u as normalizeHistoryOperationForWrite,d as requireHistoryOperation,p as resolveHistoryOperation};
|
|
2
2
|
//# sourceMappingURL=operation-contract.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{EXIT_CODE as a}from"../shared/constants.js";import{PmCliError as c}from"../shared/errors.js";import{historyVersionOffset as f}from"./version-address.js";import{EMPTY_REPLAY_DOCUMENT as h,verifyHistoryChain as v,verifyHistoryChainWithVersion as g,tryApplyReplayPatch as y}from"./replay.js";function w(i,e){let o=-1;return i.forEach((r,t)=>{const s=Date.parse(r.ts);if(!Number.isFinite(s))throw new c(`History for this item contains invalid timestamp at entry ${t+1}.`,a.GENERIC_FAILURE);s<=e&&(o=t)}),o}function _(i,e){const o=i[0]?.ts??null,r=i.at(-1)?.ts??null,t={code:"history_target_out_of_range",required:"Choose a target within the available item history.",why:"Point-in-time reads and restores can only reconstruct recorded versions.",examples:[],nextSteps:["Run pm history <id> to inspect available versions and timestamps."],valid_range:{first_version:null,last_version:null,first_timestamp:o,last_timestamp:r}};return r!==null&&(t.examples=[r],e!==null&&(t.examples.unshift(String(e+1),String(e+i.length)),t.valid_range.first_version=e+1,t.valid_range.last_version=e+i.length)),{guidance:t,lastTimestamp:r}}function E(i,e){const o={};if(e instanceof Error&&e.message.trim().length>0&&(o.reason=e.message.trim()),typeof e!="object"||e===null)return o;const r=e;if(typeof r.index=="number"&&Number.isInteger(r.index)&&r.index>=0&&(o.patchIndex=r.index),typeof r.operation=="object"&&r.operation!==null){const t=r.operation;Object.assign(o,Object.fromEntries(["op","path","from"].flatMap(s=>{const n=t[s];return typeof n=="string"?[[s,n]]:[]})))}if(o.patchIndex!==void 0){const t=i[o.patchIndex];t&&(o.op??=t.op,o.path??=t.path,o.from??=t.from)}return o}function A(i,e,o={}){const r=i.trim(),t=o.errorSubject??"history",s=t==="restore"?"Restore":"History",{guidance:n,lastTimestamp:l}=_(e,f(e,!0));if(!r)throw new c(`Missing ${t} target. Use a timestamp or version number.`,a.USAGE,n);if(/^\d+$/.test(r)){const d=f(e),p=Number(r);if(p>=1&&p<=d)throw new c(`History version ${p} was pruned by compaction.`,a.USAGE,{...n,code:"history_version_pruned"});if(!Number.isSafeInteger(p)||p<1||p>d+e.length)throw new c(`${s} version must be between ${d+1} and ${d+e.length} for this item.`,a.USAGE,n);return{kind:"version",raw:r,historyIndex:p-d-1}}const m=Date.parse(r);if(!Number.isFinite(m))throw new c(`Invalid ${t} target "${i}". Use a positive version number or ISO timestamp.`,a.USAGE,n);const u=w(e,m);if(u<0||o.allowFutureTimestamp!==!0&&m>Date.parse(l))throw new c(t==="restore"?`No history entries exist at or before timestamp ${r}.`:`No history entry exists at timestamp ${r}.`,a.USAGE,n);return{kind:"timestamp",raw:r,historyIndex:u}}function x(i,e,o,r){const t=y(i,e);if(t.ok)return t.document;const s=E(e,t.error),n=[`history_op=${r}`,s.patchIndex===void 0?null:`patch_index=${s.patchIndex}`,s.op?`op=${s.op}`:null,s.path?`path=${s.path}`:null,s.from?`from=${s.from}`:null].filter(l=>l!==null);throw new c(`Failed to apply history patch at entry ${o} (${n.join(", ")}). ${s.reason??String(t.error)}`,a.GENERIC_FAILURE)}function b(i,e){return new c(`History entry ${i+1} lies between an unrecorded change and the record that repaired it, so its historical state cannot be reconstructed.`,a.USAGE,{code:"history_version_unreconstructable",required:e?"Choose a version before the bridged break or from its bridge onward.":"Choose a version whose record is not marked replay_inexact.",nextSteps:[e?"Run pm history <id> --full to find the bridge record and the versions around it.":"Run pm history <id> --full and pick a version whose record has no replay_inexact marker."]})}function H(i,e){const o=i[0];if(o&&o.op!=="create"&&o.op!=="history_compact_baseline"){const n=y(h,o.patch);if(!n.ok||typeof n.document.metadata.id!="string")throw new c("History starts without a reconstructable item baseline.",a.GENERIC_FAILURE,{code:"history_baseline_unavailable",required:"Recover the original create entry or a complete checkpoint from version control.",nextSteps:["Run pm history <id> --full to inspect the missing baseline."]})}if(i[e]?.replay_inexact===!0)throw b(e,!1);const r=i.slice(0,e+1),t=v([...r]);let s=structuredClone(h);for(let n=0;n<=e;n+=1){const l=i[n];if(!l)throw new c(`History target entry ${n+1} does not exist.`,a.USAGE);s=x(s,l.patch,n+1,l.op)}if(!t.ok){const n=g([...i]);throw n.ok&&n.bridged_segments?.some(l=>l.start<=e&&e<l.end)?b(e,!0):new c(`History cannot be replayed: ${t.errors.join(", ")}.`,a.GENERIC_FAILURE,{code:"history_replay_invalid",verification_errors:t.errors,required:"Inspect the history integrity findings before attempting recovery.",nextSteps:["Run pm history <id> --verify --full."]})}return s}function T(i,e){if(Object.keys(i.metadata).length>0){if(typeof i.metadata.id!="string"||!Array.isArray(i.metadata.tags))throw new c("History has no complete item baseline for this target.",a.GENERIC_FAILURE,{code:"history_baseline_unavailable",required:"Recover the original create entry or a complete checkpoint from version control.",nextSteps:["Run pm history <id> --full to inspect the first recorded state."]});return i}throw new c(`History target ${e.raw} resolves to a deleted state; choose a version or timestamp where the item exists.`,a.USAGE)}export{x as applyHistoryPatch,T as ensureMaterializedHistoryTarget,E as extractPatchFailureContext,H as replayHistoryToTarget,A as resolveHistoryTarget};
|
|
2
2
|
//# sourceMappingURL=projection.js.map
|
|
@@ -19,5 +19,14 @@ source:BigIntStats|null;}
|
|
|
19
19
|
* that supplied the bytes, whatever happens to the path meanwhile.
|
|
20
20
|
*/
|
|
21
21
|
export declare function readIdentifiedHistorySnapshot(historyPath:string,itemId:string):Promise<IdentifiedHistoryStreamSnapshot>;
|
|
22
|
+
/**
|
|
23
|
+
* Describe why one decoded JSONL value cannot be a history record, or return
|
|
24
|
+
* null for an object. Readers dereference every line as an object, so a JSON
|
|
25
|
+
* null, boolean, number, string or array refuses here with a typed error
|
|
26
|
+
* instead of crashing a reader; objects keep each reader's legacy tolerance.
|
|
27
|
+
*/
|
|
28
|
+
export declare function describeHistoryRecordDefect(value:unknown):string|null;
|
|
29
|
+
/** Whether one decoded JSON value is a scalar that cannot encode or hide a record. */
|
|
30
|
+
export declare function isNonRecordScalar(value:unknown):boolean;
|
|
22
31
|
/** Read and validate one item's JSONL history stream without mutating it. */
|
|
23
32
|
export declare function readHistoryEntries(historyPath:string,itemId:string):Promise<HistoryEntry[]>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import y from"node:fs/promises";import{isFileAbsentError as p}from"../fs/fs-utils.js";import{runActiveOnReadHooks as m}from"../extensions/index.js";import{EXIT_CODE as c}from"../shared/constants.js";import{findFirstMergeConflictMarker as w}from"../shared/conflict-markers.js";import{PmCliError as l}from"../shared/errors.js";async function b(r,e){const n=await y.readFile(r).catch(t=>{if(p(t))return null;throw t});return f(r,e,n)}async function N(r,e){const n=await y.open(r,"r").catch(t=>{if(p(t))return null;throw t});if(n===null)return{...await f(r,e,null),source:null};try{const t=await n.stat({bigint:!0}),o=await n.readFile();return{...await f(r,e,o),source:t}}finally{await n.close()}}async function f(r,e,n){const t=n?.toString("utf8")??null;if(t===null)return{raw:t,raw_bytes:n,entries:[]};if(await m({path:r,scope:"project"}),t.trim()==="")return{raw:t,raw_bytes:n,entries:[]};const o=w(t);if(o)throw new l(`History for ${e} contains merge conflict markers at line ${o.line} (${o.marker}). Resolve <<<<<<< ======= >>>>>>> markers and retry.`,c.GENERIC_FAILURE,{code:"history_merge_conflict_markers_detected",required:"Repair the history stream by resolving merge-conflict markers.",why:"Conflict markers break JSONL parsing and invalidate deterministic audit history.",examples:[`pm history ${e}`,`pm restore ${e} <timestamp-or-version>`],nextSteps:["Resolve or restore the history file, then rerun the command."]});const u=[];for(const[i,h]of t.split(/\r?\n/).entries()){const d=h.trim();if(!d)continue;let a;try{a=JSON.parse(d)}catch{throw new l(`History for ${e} contains invalid JSON at line ${i+1}. Repair or restore the history stream and retry.`,c.GENERIC_FAILURE,{code:"history_json_invalid",nextSteps:[`Run pm history-repair ${e} --salvage-tail --dry-run to check whether only an invalid suffix is damaged.`]})}const s=R(a);if(s!==null)throw new l(`History for ${e} holds ${s} at line ${i+1}, which is not a history record. Remove or restore the line and retry.`,c.GENERIC_FAILURE,{code:"history_record_invalid",item_id:e,reason:s,details:{line:i+1},required:"Every history line must be one JSON object record.",nextSteps:[`Run pm history-repair ${e} --salvage-tail --dry-run: it removes a line that cannot hold a record (a JSON null, boolean or number) and keeps every record.`,"Otherwise recover the line from version control or a backup."]});u.push(a)}return{raw:t,raw_bytes:n,entries:u}}function R(r){return r===null?"a JSON null":Array.isArray(r)?"a JSON array":typeof r=="object"?null:`a JSON ${typeof r}`}function g(r){return r===null||typeof r=="boolean"||typeof r=="number"}async function x(r,e){return(await b(r,e)).entries}export{R as describeHistoryRecordDefect,g as isNonRecordScalar,x as readHistoryEntries,b as readHistorySnapshot,N as readIdentifiedHistorySnapshot};
|
|
2
2
|
//# sourceMappingURL=read.js.map
|
|
@@ -38,8 +38,22 @@ export declare function normalizeReplayPatchOps(patch:HistoryPatchOp[]|unknown):
|
|
|
38
38
|
export type ReplayApplyResult={ok:true;document:ReplayDocument;}|{ok:false;error:unknown;};
|
|
39
39
|
/** Strictly apply a history patch (front_matter->metadata normalized) to a replay document. Returns a result envelope rather than throwing so each caller can format its own error contract. */
|
|
40
40
|
export declare function tryApplyReplayPatch(current:ReplayDocument,patch:HistoryPatchOp[]):ReplayApplyResult;
|
|
41
|
+
/**
|
|
42
|
+
* Whether one operation can never change state: a test, a move onto its own
|
|
43
|
+
* path, or a copy onto its own path unless that path may be an array element
|
|
44
|
+
* (copying onto an index inserts a second element there).
|
|
45
|
+
*/
|
|
46
|
+
declare function isEffectFreeOperation(operation:HistoryPatchOp):boolean;
|
|
47
|
+
/** Zero-based inclusive range of entries closed by one verified bridge. */
|
|
48
|
+
export interface HistoryBridgedSegment{
|
|
49
|
+
/** First entry after the first named break. */
|
|
50
|
+
start:number;
|
|
51
|
+
/** The bridge record that closes the segment. */
|
|
52
|
+
end:number;}
|
|
41
53
|
/** Verify a chain and report the explicit or auto-detected item hash epoch. */
|
|
42
|
-
export declare function verifyHistoryChainWithVersion(entries:HistoryEntry[]):{ok:boolean;errors:string[];item_hash_version?:HistoryItemHashVersion;
|
|
54
|
+
export declare function verifyHistoryChainWithVersion(entries:HistoryEntry[]):{ok:boolean;errors:string[];item_hash_version?:HistoryItemHashVersion;
|
|
55
|
+
/** Segments closed by an append-only bridge, in stream order; absent when none. */
|
|
56
|
+
bridged_segments?:HistoryBridgedSegment[];};
|
|
43
57
|
/** Deterministically verify a history chain while preserving the legacy result shape. */
|
|
44
58
|
export declare function verifyHistoryChain(entries:HistoryEntry[]):{ok:boolean;errors:string[];};
|
|
45
59
|
/** Documents the lenient apply result payload exchanged by command, SDK, and package integrations. */
|
|
@@ -50,8 +64,8 @@ document:ReplayDocument;
|
|
|
50
64
|
convertedReplaceToAdd:number;
|
|
51
65
|
/** Value that configures or reports skipped ops for this contract. */
|
|
52
66
|
skippedOps:number;}
|
|
53
|
-
/** Apply a legacy patch op-by-op, recovering from drift that strict replay rejects: a `replace` whose path no longer exists is retried as `add`, and any op that still cannot apply against the current replay state is skipped. The resulting document is what the repaired entry's recomputed patch should target. */
|
|
54
|
-
export declare function lenientApplyReplayPatch(current:ReplayDocument,patch:HistoryPatchOp[]):LenientApplyResult;
|
|
67
|
+
/** Apply a legacy patch op-by-op, recovering from drift that strict replay rejects: a `replace` whose path no longer exists is retried as `add`, and any op that still cannot apply against the current replay state is skipped. A patch may pass through a non-object root and restore the item. One that ends without an item root records a deletion when it belongs to a `delete` entry, which replays as the canonical empty document; any other is replayed again without its root transitions, so the ops that did apply are kept and no empty state is invented. The resulting document is what the repaired entry's recomputed patch should target. */
|
|
68
|
+
export declare function lenientApplyReplayPatch(current:ReplayDocument,patch:HistoryPatchOp[],operation?:string):LenientApplyResult;
|
|
55
69
|
/** Documents the reanchor entry detail payload exchanged by command, SDK, and package integrations. */
|
|
56
70
|
export interface ReanchorEntryDetail{
|
|
57
71
|
/** Value that configures or reports index for this contract. */
|
|
@@ -78,6 +92,8 @@ entriesPatchRepaired:number;
|
|
|
78
92
|
convertedReplaceToAdd:number;
|
|
79
93
|
/** Value that configures or reports skipped ops for this contract. */
|
|
80
94
|
skippedOps:number;
|
|
95
|
+
/** Entries resealed to dissolve a bridge or add a replay_inexact marker, or for any reason when the input failed verification; an epoch label alone on a verified input does not count. */
|
|
96
|
+
entriesResealed:number;
|
|
81
97
|
/** Value that configures or reports details for this contract. */
|
|
82
98
|
details:ReanchorEntryDetail[];
|
|
83
99
|
/** Hash epoch retained while rebuilding the stream. */
|
|
@@ -89,7 +105,9 @@ export interface ReanchorHistoryOptions{
|
|
|
89
105
|
/** Keep one semantic hash candidate for the complete rewritten stream so adjacent stored endpoints are identical. */
|
|
90
106
|
continuousHashSurface?:boolean;
|
|
91
107
|
/** Rebase an entry's patch onto its new replay position, retaining the original patch as immutable rewrite evidence. */
|
|
92
|
-
projectPatch?:(entry:HistoryEntry,current:ReplayDocument)=> HistoryPatchOp[];
|
|
108
|
+
projectPatch?:(entry:HistoryEntry,current:ReplayDocument)=> HistoryPatchOp[];
|
|
109
|
+
/** The caller already marked every record a dissolved bridge covers (a merge union marks each original branch before it interleaves them), so re-anchoring adds no markers of its own. */
|
|
110
|
+
callerMarksBridgeCoverage?:boolean;}
|
|
93
111
|
/**
|
|
94
112
|
* Resolve the hash epoch a repair must retain.
|
|
95
113
|
*
|
|
@@ -99,7 +117,30 @@ projectPatch?:(entry:HistoryEntry,current:ReplayDocument)=> HistoryPatchOp[];}
|
|
|
99
117
|
* irreconcilably mixed stream falls forward to the current epoch.
|
|
100
118
|
*/
|
|
101
119
|
export declare function resolveHistoryRepairItemHashVersion(entries:HistoryEntry[]):HistoryItemHashVersion;
|
|
120
|
+
/**
|
|
121
|
+
* Indexes of the entries a bridged segment covers before its bridge, plus the
|
|
122
|
+
* bridge record itself when no intact commitment proved the segment: its
|
|
123
|
+
* recorded state then rests on records that cannot be trusted either.
|
|
124
|
+
*/
|
|
125
|
+
export declare function collectBridgedInteriorIndexes(segments:ReadonlyArray<HistoryBridgedSegment&{exact?:boolean;}>):Set<number>;
|
|
126
|
+
/**
|
|
127
|
+
* Reseal one record with replay_inexact. The evidence keeps only digests of
|
|
128
|
+
* the prior record, never its values: a following provenance normalization
|
|
129
|
+
* or redaction must not find the removed values preserved in this evidence.
|
|
130
|
+
*/
|
|
131
|
+
export declare function markHistoryEntryInexact(entry:HistoryEntry):HistoryEntry;
|
|
132
|
+
/**
|
|
133
|
+
* Write the unreconstructable knowledge a verified bridge carries onto the
|
|
134
|
+
* records it covers, before any rewrite that may dissolve the bridge: each
|
|
135
|
+
* covered entry is resealed with replay_inexact (its prior record kept as
|
|
136
|
+
* rewrite evidence). Rewrites that reseal, interleave or re-anchor entries
|
|
137
|
+
* before they can see the segment (provenance normalization, merge unions)
|
|
138
|
+
* call this first, so the marker survives whatever they do to the bridge.
|
|
139
|
+
*/
|
|
140
|
+
export declare function materializeBridgedSegments(entries:HistoryEntry[]):HistoryEntry[];
|
|
102
141
|
/** Re-anchor a drifted history chain: replay every entry from empty, recompute the before/after hashes, and only rewrite a patch when the original op set no longer strictly applies (legacy drift). Clean entries keep their patch verbatim so the on-disk diff stays minimal. The returned chain verifies via verifyHistoryChain. */
|
|
103
142
|
export declare function reanchorHistoryEntries(entries:HistoryEntry[],itemHashVersion?:HistoryItemHashVersion,options?:ReanchorHistoryOptions):ReanchorResult;
|
|
104
143
|
/** Implements history entries to raw for the public runtime surface of this module. */
|
|
105
|
-
export declare function historyEntriesToRaw(entries:HistoryEntry[]):string;
|
|
144
|
+
export declare function historyEntriesToRaw(entries:HistoryEntry[]):string;
|
|
145
|
+
/** Internal helpers exposed for focused specs only. */
|
|
146
|
+
export declare const _testOnly:{isEffectFreeOperation:typeof isEffectFreeOperation;};export{};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0c0cb8c7-4d7d-53f8-8ec2-d6dc98fc6dc5")}catch{}})();import jsonPatch from"fast-json-patch";import{historyDigest,resolveHistoryHashAlgorithm}from"./digest.js";import{findHistoryIdentityDiscontinuities}from"./identity.js";import{ITEM_METADATA_KEY_ORDER}from"../shared/constants.js";import{canonicalDocument}from"../item/item-format.js";import{toItemRecord}from"../item/item-record.js";import{orderObject,stableStringify}from"../shared/serialization.js";import{CURRENT_HISTORY_ITEM_HASH_VERSION,SUPPORTED_HISTORY_ITEM_HASH_VERSIONS,hashDocumentVerificationCandidates,resealHistoryRewrite,verifyHistoryRecordHash,verifyHistoryRewriteEvidence}from"./history.js";const EMPTY_REPLAY_DOCUMENT={metadata:{},body:""};function cloneEmptyReplayDocument(){return structuredClone(EMPTY_REPLAY_DOCUMENT)}function replayHash(document,version=CURRENT_HISTORY_ITEM_HASH_VERSION,algorithm){return replayHashVerificationCandidates(document,version,algorithm)[0]}function replayHashVerificationCandidates(document,version,algorithm){if(Object.keys(document.metadata).length===0||Array.isArray(document.metadata.tags))try{return hashDocumentVerificationCandidates(replayToItemDocument(document),version,algorithm)}catch{}const fallback=historyDigest(stableStringify({replay_fallback:!0,metadata:document.metadata,body:document.body}),algorithm);return version===2?[fallback,fallback]:[fallback]}function matchReplayHashCandidates(before,after,version,entry,memo){const algorithm=resolveHistoryHashAlgorithm(entry.hash_algorithm),memoKey=`${version}:${algorithm}`,beforeHashes=memo?.before.get(memoKey)??replayHashVerificationCandidates(before,version,algorithm),afterHashes=replayHashVerificationCandidates(after,version,algorithm);return memo?.after.set(memoKey,afterHashes),{beforeHashes,afterHashes,pairIndex:beforeHashes.findIndex((beforeHash,hashIndex)=>beforeHash===entry.before_hash&&afterHashes[hashIndex]===entry.after_hash),beforeIndex:beforeHashes.indexOf(entry.before_hash),afterIndex:afterHashes.indexOf(entry.after_hash)}}function replayToItemDocument(document){return{metadata:document.metadata,body:document.body}}function replayToCanonicalItemDocument(document,options={}){return canonicalDocument(replayToItemDocument(document),options)}function toReplayDocument(document){if(!document.metadata||Object.keys(document.metadata).length===0)return{metadata:{},body:document.body??""};const canonical=canonicalDocument(document);return{metadata:orderObject(toItemRecord(canonical.metadata),ITEM_METADATA_KEY_ORDER),body:canonical.body}}function normalizeReplayPatchPath(path){return path==="/front_matter"?"/metadata":path.startsWith("/front_matter/")?`/metadata/${path.slice(14)}`:path}function isHistoryPatchOp(value){return typeof value=="object"&&value!==null&&typeof value.op=="string"&&typeof value.path=="string"}function normalizeReplayPatchOps(patch){return Array.isArray(patch)?patch.filter(isHistoryPatchOp).map(operation=>({...operation,path:normalizeReplayPatchPath(operation.path),from:typeof operation.from=="string"?normalizeReplayPatchPath(operation.from):void 0})):[]}function isReplayDocumentShape(value){return typeof value=="object"&&value!==null&&"metadata"in value&&"body"in value&&typeof value.body=="string"&&typeof value.metadata=="object"&&value.metadata!==null}function tryApplyReplayPatch(current,patch){try{const normalizedPatch=normalizeReplayPatchOps(patch),applied=jsonPatch.applyPatch(structuredClone(current),normalizedPatch,!0,!0).newDocument;return isReplayDocumentShape(applied)?{ok:!0,document:{metadata:applied.metadata,body:applied.body}}:{ok:!1,error:new Error("history_replay_invalid_document_shape")}}catch(error){return{ok:!1,error}}}function supportedExplicitHistoryItemHashVersions(entries){return[...new Set(entries.map(entry=>entry.item_hash_version).filter(version=>version!==void 0&&SUPPORTED_HISTORY_ITEM_HASH_VERSIONS.includes(version)))]}function isUnsupportedExplicitHistoryItemHashVersion(version){return version!==void 0&&!SUPPORTED_HISTORY_ITEM_HASH_VERSIONS.includes(version)}function historyEntryHashCandidates(explicitVersion,authoritativeVersion){return explicitVersion!==void 0?[explicitVersion]:authoritativeVersion===void 0?[...SUPPORTED_HISTORY_ITEM_HASH_VERSIONS]:[authoritativeVersion]}function historyEntryIntegrityError(entry){const recordVerification=verifyHistoryRecordHash(entry);if(!recordVerification.ok)return recordVerification.error;const rewriteVerification=verifyHistoryRewriteEvidence(entry);return rewriteVerification.ok?void 0:rewriteVerification.error}function verifyHistoryEntryInput(entry,replay){const integrityError=historyEntryIntegrityError(entry);if(integrityError)return{ok:!1,error:integrityError};const applied=tryApplyReplayPatch(replay,entry.patch);return applied.ok?{ok:!0,document:applied.document}:{ok:!1,error:"patch_apply_failed"}}function assertHistoryEntryIntegrity(entry,index){const integrityError=historyEntryIntegrityError(entry);if(integrityError)throw new TypeError(`${integrityError}:entry_${index+1}`)}function matchReplayEpochCandidates(before,after,candidates,entry,memo){const matches=[];for(const version of candidates){const match=matchReplayHashCandidates(before,after,version,entry,memo);if(matches.push({version,match}),match.pairIndex>=0)break}return matches}function verifyHistoryChainWithVersion(entries){let replay=cloneEmptyReplayDocument(),beforeHashMemo=new Map,detectedVersion,authoritativeExplicitVersion;const errors=findHistoryIdentityDiscontinuities(entries).map(finding=>`verify_failed:duplicate_create:entry_${finding.repeated_create_index}:prior_${finding.prior_genesis_index}`);for(let index=0;index<entries.length;index+=1){const entry=entries[index],explicitVersion=entry.item_hash_version,unsupportedVersion=isUnsupportedExplicitHistoryItemHashVersion(explicitVersion);unsupportedVersion&&errors.push(`verify_failed:unsupported_item_hash_version:${String(explicitVersion)}:entry_${index+1}`);const input=verifyHistoryEntryInput(entry,replay);if(!input.ok)return{ok:!1,errors:[...errors,`verify_failed:${input.error}:entry_${index+1}`]};if(unsupportedVersion){replay=input.document,beforeHashMemo=new Map,detectedVersion=void 0,authoritativeExplicitVersion=void 0;continue}const candidates=historyEntryHashCandidates(explicitVersion,authoritativeExplicitVersion),memo={before:beforeHashMemo,after:new Map},candidateMatches=matchReplayEpochCandidates(replay,input.document,candidates,entry,memo),matchingVersion=candidateMatches.find(({match})=>match.pairIndex>=0);if(matchingVersion===void 0){const beforeMatches=candidateMatches.some(({match})=>match.beforeIndex>=0);return{ok:!1,errors:[...errors,`verify_failed:${beforeMatches?"after":"before"}_hash_mismatch:entry_${index+1}`]}}const version=matchingVersion.version;replay=input.document,beforeHashMemo=memo.after,detectedVersion=version,authoritativeExplicitVersion=explicitVersion??authoritativeExplicitVersion}return errors.length>0?{ok:!1,errors,...detectedVersion===void 0?{}:{item_hash_version:detectedVersion}}:{ok:!0,errors:[],...detectedVersion===void 0?{}:{item_hash_version:detectedVersion}}}function verifyHistoryChain(entries){const result=verifyHistoryChainWithVersion(entries);return{ok:result.ok,errors:result.errors}}function tryApplySingleOp(document,op){try{return{ok:!0,document:jsonPatch.applyPatch(structuredClone(document),[op],!0,!1).newDocument}}catch{return{ok:!1}}}function lenientApplyReplayPatch(current,patch){let working=structuredClone(current),convertedReplaceToAdd=0,skippedOps=0;for(const op of normalizeReplayPatchOps(patch)){const direct=tryApplySingleOp(working,op);if(direct.ok){working=direct.document;continue}if(op.op==="replace"){const asAdd=tryApplySingleOp(working,{...op,op:"add"});if(asAdd.ok){working=asAdd.document,convertedReplaceToAdd+=1;continue}}skippedOps+=1}const candidate=working;return{document:{metadata:typeof candidate.metadata=="object"&&candidate.metadata!==null?candidate.metadata:{},body:typeof candidate.body=="string"?candidate.body:current.body},convertedReplaceToAdd,skippedOps}}function resolveHistoryRepairItemHashVersion(entries){const explicitVersions=supportedExplicitHistoryItemHashVersions(entries);if(explicitVersions.length===1)return explicitVersions[0];const verified=verifyHistoryChainWithVersion(entries);return verified.ok&&verified.item_hash_version!==void 0?verified.item_hash_version:explicitVersions.length===0?1:CURRENT_HISTORY_ITEM_HASH_VERSION}function applyReanchorPatch(replay,entry,projectedPatch=entry.patch){const strict=tryApplyReplayPatch(replay,projectedPatch);if(strict.ok)return{next:strict.document,patch:projectedPatch,repaired:stableStringify(projectedPatch)!==stableStringify(entry.patch),converted:0,skipped:0};const lenient=lenientApplyReplayPatch(replay,projectedPatch);return{next:lenient.document,patch:jsonPatch.compare(replay,lenient.document),repaired:!0,converted:lenient.convertedReplaceToAdd,skipped:lenient.skippedOps}}function applyProjectedReanchorPatch(replay,entry,options){return applyReanchorPatch(replay,entry,options.projectPatch?.(entry,replay))}function reanchorHistoryEntries(entries,itemHashVersion=resolveHistoryRepairItemHashVersion(entries),options={}){const unsupportedIndex=entries.findIndex(entry=>isUnsupportedExplicitHistoryItemHashVersion(entry.item_hash_version));if(unsupportedIndex>=0)throw new TypeError(`unsupported_item_hash_version:${String(entries[unsupportedIndex]?.item_hash_version)}:entry_${unsupportedIndex+1}`);let replay=cloneEmptyReplayDocument();const rewritten=[],details=[];let entriesRehashed=0,entriesPatchRepaired=0,convertedReplaceToAdd=0,skippedOps=0,semanticIndex;const explicitItemHashVersion=itemHashVersion!==1||entries.some(entry=>entry.item_hash_version!==void 0);for(let index=0;index<entries.length;index+=1){const entry=entries[index];assertHistoryEntryIntegrity(entry,index);const patchApplication=applyProjectedReanchorPatch(replay,entry,options),{next,patch:outPatch,repaired:patchRepaired,converted:entryConverted,skipped:entrySkipped}=patchApplication;convertedReplaceToAdd+=entryConverted,skippedOps+=entrySkipped,entriesPatchRepaired+=Number(patchRepaired);const hashMatch=matchReplayHashCandidates(replay,next,itemHashVersion,entry);semanticIndex===void 0||options.continuousHashSurface!==!0?semanticIndex=[hashMatch.pairIndex,hashMatch.beforeIndex,hashMatch.afterIndex,Math.min(semanticIndex??0,hashMatch.beforeHashes.length-1)].find(candidate=>candidate>=0):semanticIndex=Math.min(semanticIndex,hashMatch.beforeHashes.length-1);const beforeHash=hashMatch.beforeHashes[semanticIndex],afterHash=hashMatch.afterHashes[semanticIndex],rehashed=beforeHash!==entry.before_hash||afterHash!==entry.after_hash;rehashed&&(entriesRehashed+=1);let rewrittenEntry={...entry,patch:outPatch,before_hash:beforeHash,after_hash:afterHash};explicitItemHashVersion?rewrittenEntry.item_hash_version=itemHashVersion:delete rewrittenEntry.item_hash_version;const versionChanged=rewrittenEntry.item_hash_version!==entry.item_hash_version;(rehashed||patchRepaired||versionChanged)&&(rewrittenEntry=resealHistoryRewrite(entry,rewrittenEntry,{retainOriginalPatch:patchRepaired})),rewritten.push(rewrittenEntry),details.push({index:index+1,rehashed,patch_repaired:patchRepaired,converted_replace_to_add:entryConverted,skipped_ops:entrySkipped}),replay=next}return{entries:rewritten,finalDocument:replay,entriesRehashed,entriesPatchRepaired,convertedReplaceToAdd,skippedOps,details,itemHashVersion,explicitItemHashVersion}}function historyEntriesToRaw(entries){return entries.length===0?"":`${entries.map(entry=>JSON.stringify(entry)).join(`
|
|
1
|
+
import R from"fast-json-patch";import{historyDigest as de,resolveHistoryHashAlgorithm as E}from"./digest.js";import{findHistoryIdentityDiscontinuities as ce}from"./identity.js";import{digestBridgedSegment as fe,findNextHistoryBridge as ue,locateBridgedSegments as z,matchesHistoryBreak as Y,readHistoryBridge as U}from"./bridge.js";import{ITEM_METADATA_KEY_ORDER as pe}from"../shared/constants.js";import{canonicalDocument as W}from"../item/item-format.js";import{toItemRecord as he}from"../item/item-record.js";import{orderObject as me,stableStringify as k}from"../shared/serialization.js";import{CURRENT_HISTORY_ITEM_HASH_VERSION as G,SUPPORTED_HISTORY_ITEM_HASH_VERSIONS as I,hashDocumentVerificationCandidates as le,isCompleteHistoryRecord as _e,resealHistoryRewrite as K,verifyHistoryRecordHash as ye,verifyHistoryRewriteEvidence as be}from"./history.js";const ge={metadata:{},body:""};function L(){return structuredClone(ge)}function Le(e,t=G,r){return l(e,t,r)[0]}function l(e,t,r){if(Object.keys(e.metadata).length===0||Array.isArray(e.metadata.tags))try{return le(F(e),t,r)}catch{}const n=de(k({replay_fallback:!0,metadata:e.metadata,body:e.body}),r);return t===2?[n,n]:[n]}function O(e,t,r,n,i){const s=E(n.hash_algorithm),o=`${r}:${s}`,a=i?.before.get(o)??l(e,r,s),d=l(t,r,s);return i?.after.set(o,d),{beforeHashes:a,afterHashes:d,pairIndex:a.findIndex((c,u)=>c===n.before_hash&&d[u]===n.after_hash),beforeIndex:a.indexOf(n.before_hash),afterIndex:d.indexOf(n.after_hash)}}function F(e){return{metadata:e.metadata,body:e.body}}function Fe(e,t={}){return W(F(e),t)}function Je(e){if(!e.metadata||Object.keys(e.metadata).length===0)return{metadata:{},body:e.body??""};const t=W(e);return{metadata:me(he(t.metadata),pe),body:t.body}}function _(e){return e==="/front_matter"?"/metadata":e.startsWith("/front_matter/")?`/metadata/${e.slice(14)}`:e}function J(e){return typeof e=="object"&&e!==null&&typeof e.op=="string"&&typeof e.path=="string"}function Q(e){return Array.isArray(e)?e.filter(J).map(t=>({...t,...(t.op==="add"||t.op==="replace")&&Object.hasOwn(t,"value")?{value:structuredClone(t.value)}:{},path:_(t.path),from:typeof t.from=="string"?_(t.from):void 0})):[]}function xe(e){return typeof e=="object"&&e!==null&&"metadata"in e&&"body"in e&&typeof e.body=="string"&&typeof e.metadata=="object"&&e.metadata!==null}function S(e,t){try{const r=Q(t),n=R.applyPatch(structuredClone(e),r,!0,!0).newDocument;return xe(n)?{ok:!0,document:{metadata:n.metadata,body:n.body}}:{ok:!1,error:new Error("history_replay_invalid_document_shape")}}catch(r){return{ok:!1,error:r}}}function ve(e){return[...new Set(e.map(t=>t.item_hash_version).filter(t=>t!==void 0&&I.includes(t)))]}function X(e){return e!==void 0&&!I.includes(e)}function Z(e,t){return e!==void 0?[e]:t===void 0?[...I]:[t]}function q(e){const t=ye(e);if(!t.ok)return t.error;const r=be(e);return r.ok?void 0:r.error}function V(e,t){const r=q(e);if(r)return{ok:!1,error:r};const n=S(t,e.patch);return n.ok?{ok:!0,document:n.document}:{ok:!1,error:"patch_apply_failed"}}function He(e,t){const r=q(e);if(r)throw new TypeError(`${r}:entry_${t+1}`)}function Re(e,t,r,n,i){const s=[];for(const o of r){const a=O(e,t,o,n,i);if(s.push({version:o,match:a}),a.pairIndex>=0)break}return s}function M(e){if(!_e(e))return!1;let t;try{t=E(e.hash_algorithm)==="sha512"?128:64}catch{return!1}const r=new RegExp(`^[a-f0-9]{${t}}$`,"u");return!r.test(e.before_hash)||!r.test(e.after_hash)?!1:!e.patch.filter(J).map(i=>({op:i.op,path:_(i.path),from:typeof i.from=="string"?_(i.from):void 0})).every(i=>w(i))||e.before_hash===e.after_hash||Object.hasOwn(e,"bridge")}function w(e){return e.op==="test"?!0:e.from!==e.path?!1:e.op==="move"||e.op==="copy"&&!/\/(?:\d+|-)$/u.test(e.path)}const ee=new WeakMap;function Ee(e,t){if(t===0||!M(e[t]))return;const r=ue(e,t);if(r<0)return;const n=U(e[r]);if(!(typeof n!="object"||!Y(n.breaks[0],e[t-1],e[t])))return{start:t,closer:r,bridge:n,next:1}}function ke(e,t,r,n,i){const s=e[t],o=e[t-1];if(!M(s))return{ok:!1,error:"record_incomplete"};const a=V(s,n);if(!a.ok)return a;const d=i.map(c=>O(n,a.document,c,s));return d.some(c=>c.beforeIndex>=0)&&!d.some(c=>c.pairIndex>=0)?{ok:!1,error:"after_hash_mismatch"}:s.before_hash===o.after_hash?a:Y(r.bridge.breaks[r.next],o,s)?(r.next+=1,a):{ok:!1,error:"bridge_unnamed_break"}}function Ie(e,t,r,n,i){const s=e[t];if(!M(s))return{ok:!1,error:"record_incomplete"};const o=V(s,n);if(!o.ok)return o;if(r.next!==r.bridge.breaks.length)return{ok:!1,error:"bridge_names_absent_break"};if(s.before_hash!==e[t-1].after_hash)return{ok:!1,error:"bridge_link_mismatch"};if(fe(e.slice(r.start,t),s)!==r.bridge.segment_digest)return{ok:!1,error:"bridge_segment_mismatch"};const a=E(s.hash_algorithm),d=i.find(c=>l(o.document,c,a).includes(s.after_hash));return d===void 0?{ok:!1,error:"bridge_after_hash_mismatch"}:{ok:!0,document:o.document,version:d}}function te(e,t,r,n,i){e.replay=n,e.beforeHashMemo=i,e.detectedVersion=r,e.authoritativeExplicitVersion=t.item_hash_version??e.authoritativeExplicitVersion}function Oe(e,t,r){const n=r.segment,i=e[t];if(t===n.closer&&r.authoritativeExplicitVersion!==void 0&&i.item_hash_version!==r.authoritativeExplicitVersion)return"bridge_epoch_mismatch";const o=(t<n.closer?ke:Ie)(e,t,n,r.replay,Z(i.item_hash_version,r.authoritativeExplicitVersion));if(!o.ok)return o.error;if(o.version===void 0){r.replay=o.document,r.beforeHashMemo=new Map,r.authoritativeExplicitVersion=i.item_hash_version??r.authoritativeExplicitVersion;return}const a={start:n.start,end:t};ee.set(a,o.version),r.bridgedSegments.push(a),r.segment=void 0,te(r,i,o.version,o.document,new Map)}function Se(e,t,r,n){const i=e[t];if(Object.hasOwn(i,"bridge"))return"bridge_without_break";const s=V(i,r.replay);if(!s.ok)return s.error;if(n){r.replay=s.document,r.beforeHashMemo=new Map,r.detectedVersion=void 0,r.authoritativeExplicitVersion=void 0;return}const o={before:r.beforeHashMemo,after:new Map},a=Re(r.replay,s.document,Z(i.item_hash_version,r.authoritativeExplicitVersion),i,o),d=a.find(({match:u})=>u.pairIndex>=0);if(d!==void 0){te(r,i,d.version,s.document,o.after);return}const c=a.some(({match:u})=>u.beforeIndex>=0);if(r.segment=c?void 0:Ee(e,t),r.segment===void 0)return`${c?"after":"before"}_hash_mismatch`;r.replay=s.document,r.beforeHashMemo=new Map,r.authoritativeExplicitVersion=i.item_hash_version??r.authoritativeExplicitVersion}function A(e){const t={replay:L(),beforeHashMemo:new Map,bridgedSegments:[]},r=ce(e).map(o=>`verify_failed:duplicate_create:entry_${o.repeated_create_index}:prior_${o.prior_genesis_index}`),n=(o,a)=>({ok:o,errors:o?[]:r,...a,...t.bridgedSegments.length===0?{}:{bridged_segments:t.bridgedSegments}}),i=(o,a)=>(r.push(`verify_failed:${o}:entry_${a+1}`),n(!1,{})),s=e.findIndex(o=>U(o)==="invalid");if(s>=0)return i("bridge_invalid",s);for(let o=0;o<e.length;o+=1){const a=e[o].item_hash_version,d=X(a);d&&r.push(`verify_failed:unsupported_item_hash_version:${String(a)}:entry_${o+1}`);const c=t.segment===void 0?Se(e,o,t,d):Oe(e,o,t);if(c!==void 0)return i(c,o)}return n(r.length===0,t.detectedVersion===void 0?{}:{item_hash_version:t.detectedVersion})}function Qe(e){const t=A(e);return{ok:t.ok,errors:t.errors}}function P(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function re(e,t,r){try{const n=R.applyPatch(structuredClone(e),[t],!0,!1).newDocument;return r&&!P(n)?{ok:!1}:{ok:!0,document:n}}catch{return{ok:!1}}}function ne(e,t,r){let n=structuredClone(e),i=0,s=0;for(const o of Q(t)){const a=re(n,o,r);if(a.ok){n=a.document;continue}if(o.op==="replace"){const d=re(n,{...o,op:"add"},r);if(d.ok){n=d.document,i+=1;continue}}s+=1}return{working:n,convertedReplaceToAdd:i,skippedOps:s}}function Ve(e,t,r){const n=ne(e,t,!1);if(!P(n.working)&&r==="delete")return{document:{metadata:{},body:""},convertedReplaceToAdd:n.convertedReplaceToAdd,skippedOps:n.skippedOps};const{working:i,convertedReplaceToAdd:s,skippedOps:o}=P(n.working)?n:ne(e,t,!0),a=i;return{document:{metadata:typeof a.metadata=="object"&&a.metadata!==null?a.metadata:{},body:typeof a.body=="string"?a.body:e.body},convertedReplaceToAdd:s,skippedOps:o}}function Me(e){const t=ve(e);if(t.length===1)return t[0];const r=A(e);return r.ok&&r.item_hash_version!==void 0?r.item_hash_version:t.length===0?1:G}function Ae(e,t,r=t.patch){const n=S(e,r);if(n.ok)return{next:n.document,patch:r,repaired:k(r)!==k(t.patch),converted:0,skipped:0};const i=Ve(e,r,t.op);return{next:i.document,patch:R.compare(e,i.document),repaired:!0,converted:i.convertedReplaceToAdd,skipped:i.skippedOps}}function Pe(e,t,r){return Ae(e,t,r.projectPatch?.(t,e))}function Te(e,t,r,n){const i=A(e),o=t.projectPatch===void 0&&t.continuousHashSurface!==!0?(i.bridged_segments??[]).filter(a=>ee.get(a)===r&&(!n||e[a.end].item_hash_version===r)&&e.slice(a.start,a.end+1).every(d=>d.item_hash_version===void 0||d.item_hash_version===r)):[];return{inputVerifies:i.ok,preservable:new Map(o.map(a=>[a.start,a.end])),inexact:oe(t.callerMarksBridgeCoverage===!0?[]:z(e).segments)}}function oe(e){const t=new Set;for(const{start:r,end:n,exact:i}of e){const s=i===!1?n:n-1;for(let o=r;o<=s;o+=1)t.add(o)}return t}function Ce(e){return K(e,{...e,replay_inexact:!0},{retainPriorRecord:!0,retainPriorRecordHash:!1})}function Xe(e){const t=oe(z(e).segments);return e.map((r,n)=>t.has(n)&&r.replay_inexact!==!0?Ce(r):r)}function De(e,t,r,n,i,s){let o=n;for(let a=t;a<=r;a+=1){const d=e[a],c=S(o,d.patch);if(!c.ok)throw new TypeError(`patch_apply_failed:entry_${a+1}`);o=c.document,i.push(d),s.push({index:a+1,rehashed:!1,patch_repaired:!1,converted_replace_to_add:0,skipped_ops:0})}return o}function $e(e,t,r){r.itemHashVersion===void 0?delete t.item_hash_version:t.item_hash_version=r.itemHashVersion,r.inexact&&(t.replay_inexact=!0);const n=Object.hasOwn(e,"bridge");delete t.bridge;const i=n||t.replay_inexact!==e.replay_inexact,s=r.rehashed||r.patchRepaired||i||t.item_hash_version!==e.item_hash_version;return{changed:s,persist:r.inputVerifies?i:s,anchorsChanged:r.rehashed||r.patchRepaired,entry:s?K(e,t,{retainOriginalPatch:r.patchRepaired,retainPriorRecord:n}):t}}function Ze(e,t=Me(e),r={}){const n=e.findIndex(f=>X(f.item_hash_version));if(n>=0)throw new TypeError(`unsupported_item_hash_version:${String(e[n]?.item_hash_version)}:entry_${n+1}`);let i=L();const s=[],o=[];let a=0,d=0,c=0,u=0,T=0,p;const y=t!==1||e.some(f=>f.item_hash_version!==void 0),b=Te(e,r,t,y);let C=!0;for(let f=0;f<e.length;f+=1){const h=e[f];He(h,f);const g=C?b.preservable.get(f):void 0;if(g!==void 0){i=De(e,f,g,i,s,o),f=g;continue}const ie=Pe(i,h,r),{next:D,patch:ae,repaired:x,converted:$,skipped:B}=ie;c+=$,u+=B,d+=Number(x);const m=O(i,D,t,h);p===void 0||r.continuousHashSurface!==!0?p=[m.pairIndex,m.beforeIndex,m.afterIndex,Math.min(p??0,m.beforeHashes.length-1)].find(se=>se>=0):p=Math.min(p,m.beforeHashes.length-1);const j=m.beforeHashes[p],N=m.afterHashes[p],v=j!==h.before_hash||N!==h.after_hash;v&&(a+=1);const H=$e(h,{...h,patch:ae,before_hash:j,after_hash:N},{itemHashVersion:y?t:void 0,rehashed:v,patchRepaired:x,inexact:b.inexact.has(f),inputVerifies:b.inputVerifies});C&&=!H.anchorsChanged,T+=Number(H.persist),s.push(H.entry),o.push({index:f+1,rehashed:v,patch_repaired:x,converted_replace_to_add:$,skipped_ops:B}),i=D}return{entries:s,finalDocument:i,entriesRehashed:a,entriesPatchRepaired:d,convertedReplaceToAdd:c,skippedOps:u,entriesResealed:T,details:o,itemHashVersion:t,explicitItemHashVersion:y}}function qe(e){return e.length===0?"":`${e.map(t=>JSON.stringify(t)).join(`
|
|
2
2
|
`)}
|
|
3
|
-
`}export{EMPTY_REPLAY_DOCUMENT,cloneEmptyReplayDocument,historyEntriesToRaw,lenientApplyReplayPatch,normalizeReplayPatchOps,normalizeReplayPatchPath,reanchorHistoryEntries,replayHash,replayHashVerificationCandidates,replayToCanonicalItemDocument,replayToItemDocument,resolveHistoryRepairItemHashVersion,toReplayDocument,tryApplyReplayPatch,verifyHistoryChain,verifyHistoryChainWithVersion};
|
|
3
|
+
`}const we={isEffectFreeOperation:w};export{ge as EMPTY_REPLAY_DOCUMENT,we as _testOnly,L as cloneEmptyReplayDocument,oe as collectBridgedInteriorIndexes,qe as historyEntriesToRaw,Ve as lenientApplyReplayPatch,Ce as markHistoryEntryInexact,Xe as materializeBridgedSegments,Q as normalizeReplayPatchOps,_ as normalizeReplayPatchPath,Ze as reanchorHistoryEntries,Le as replayHash,l as replayHashVerificationCandidates,Fe as replayToCanonicalItemDocument,F as replayToItemDocument,Me as resolveHistoryRepairItemHashVersion,Je as toReplayDocument,S as tryApplyReplayPatch,Qe as verifyHistoryChain,A as verifyHistoryChainWithVersion};
|
|
4
4
|
//# sourceMappingURL=replay.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
`}function
|
|
1
|
+
import{createHash as O}from"node:crypto";import a from"node:fs/promises";import Y from"node:os";import m from"node:path";import{hasActiveOnReadHooks as A}from"../extensions/index.js";import{isFileMissingError as B,writeFileAtomic as L}from"../fs/fs-utils.js";const P="runtime/history-stream-summary.json",S=1,E=64,I=2000000000n,U=500;let y=U,g=()=>Date.now(),h=()=>v(R(process,Y.userInfo));function v(e){return e===void 0?void 0:O("sha256").update(e).digest("hex").slice(0,16)}function R(e,t){try{if(e.geteuid&&e.getegid&&e.getgroups){const n=[...new Set(e.getgroups())].sort((i,s)=>i-s);return`uid:${e.geteuid()}:gid:${e.getegid()}:groups:${n.join(",")}`}const{username:r}=t();return r.length>0?`user:${r}`:void 0}catch{return}}const $=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/u;function W(e,t){return t===2?e%4===0&&e%100!==0||e%400===0?29:28:t===4||t===6||t===9||t===11?30:31}function k(e){if(typeof e!="string"||!$.test(e))return!1;const t=Number(e.slice(0,4)),r=Number(e.slice(5,7)),n=Number(e.slice(8,10));return r>=1&&r<=12&&n>=1&&n<=W(t,r)&&Number(e.slice(11,13))<24&&Number(e.slice(14,16))<60&&Number(e.slice(17,19))<60}function J(e){let t=null,r=null,n=!1;for(const i of e){const s=typeof i=="object"&&i!==null?i.ts:void 0;if(!k(s)){n=!0;continue}(t===null||s<t)&&(t=s),(r===null||s>r)&&(r=s)}return{count:e.length,oldest:t,newest:r,irregular:n}}function V(e){const t=y;return y=e,()=>{y=t}}function K(e){const t=h;return h=e,()=>{h=t}}function X(e){const t=g;return g=e,()=>{g=t}}function Z(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="EEXIST"}function w(e){return m.join(e,...P.split("/"))}function N(e,t){if(!(!e.isFile()||e.ino===0n||t===void 0))return{size:e.size,signature:[e.dev,e.ino,e.size,e.mtimeNs,e.ctimeNs,t].join(":"),changedAtNs:e.mtimeNs>e.ctimeNs?e.mtimeNs:e.ctimeNs}}async function T(e,t,r){const n=new Map;for(let i=0;i<t.length;i+=E){const s=t.slice(i,i+E);(await Promise.all(s.map(o=>a.stat(m.join(e,o),{bigint:!0}).catch(()=>{})))).forEach((o,c)=>{const f=o===void 0?void 0:N(o,r);f!==void 0&&n.set(s[c],f)})}return n}function x(e){return e===null||k(e)}function j(e){return e.oldest===null!=(e.newest===null)?!1:e.count===0?e.oldest===null&&!e.irregular:e.oldest===null?e.irregular:e.oldest<=e.newest}function z(e){if(!Array.isArray(e)||e.length!==5)return;const[t,r,n,i,s]=e;if(typeof t!="string"||!Number.isSafeInteger(r)||r<0||!x(n)||!x(i)||typeof s!="boolean")return;const u={count:r,oldest:n,newest:i,irregular:s};return j(u)?{signature:t,bounds:u}:void 0}function M(e){return 4096+e*1024}function C(e,t,r){return!e.isFile()||e.nlink!==1||e.size>M(t)?!1:r===void 0||e.uid===r&&(e.mode&18)===0}async function b(e){return(await a.lstat(m.join(e,"runtime"))).isDirectory()}async function D(e){try{return!(await a.lstat(w(e))).isFile()}catch{return!1}}async function q(e){try{if(!await b(e))return!0}catch{return!1}return D(e)}async function G(e,t){if(!await b(e))throw new Error("runtime directory is redirected");if((await a.lstat(w(e))).isSymbolicLink())throw new Error("history stream summary is a link");const r=await a.open(w(e),a.constants.O_RDONLY|a.constants.O_NOFOLLOW|a.constants.O_NONBLOCK);try{const n=await r.stat();if(!C(n,t,process.geteuid?.()))throw new Error("history stream summary is not a trusted file");return await F(r,M(t),n.size)}finally{await r.close()}}async function F(e,t,r){let n=Buffer.alloc(Math.min(Math.max(r,0),t)+1),i=0;for(;;){if(i===n.length){const u=Buffer.alloc(Math.min(n.length*2,t+1));n.copy(u,0,0,i),n=u}const{bytesRead:s}=await e.read(n,i,n.length-i,i);if(s===0)break;if(i+=s,i>t)throw new Error("history stream summary grew past its size cap")}return n.subarray(0,i).toString("utf8")}async function Q(e,t){let r;try{r=await G(e,t)}catch(n){return{state:B(n)?"missing":"invalid",streams:new Map}}try{const n=JSON.parse(r);if(n.version!==S||typeof n.streams!="object"||n.streams===null||Array.isArray(n.streams)||n.checksum!==_(n.streams))return{state:"invalid",streams:new Map};const i=new Map;for(const[s,u]of Object.entries(n.streams)){const o=z(u);if(o===void 0)return{state:"invalid",streams:new Map};i.set(s,o)}return{state:"loaded",streams:i}}catch{return{state:"invalid",streams:new Map}}}function H(e){const t=[...e.entries()].sort(([n],[i])=>n<i?-1:1),r={};for(const[n,{signature:i,bounds:s}]of t)r[n]=[i,s.count,s.oldest,s.newest,s.irregular];return`${JSON.stringify({version:S,checksum:_(r),streams:r})}
|
|
2
|
+
`}function _(e){return O("sha256").update(JSON.stringify(e)).digest("hex")}function ee(e,t,r){if(e==="missing")return"summary_missing";if(e==="invalid")return"summary_invalid";const n=r-t.size;let i=0;for(const{bounds:s}of t.values())s.irregular&&(i+=1);if(!((n+i)*2<=r))return n>=i?"summary_stale":"irregular_timestamps"}function p(e){return{enabled:!1,staleAtOpen:0,fallback:e,trusted:()=>{},record:()=>{},revalidate:async()=>[],commit:async()=>{}}}async function ce(e){if(e.files.length<y)return p(void 0);if(A())return p("read_hooks_active");if(await q(e.pmRoot))return p("summary_invalid");const t=BigInt(Math.floor(g()))*1000000n,r=h(),[n,i]=await Promise.all([Q(e.pmRoot,e.files.length),T(e.historyDir,e.files,r)]);if(A())return p("read_hooks_active");const s=new Map;for(const[o,c]of n.streams)i.get(o)?.signature===c.signature&&s.set(o,c);let u=!1;return{enabled:!0,staleAtOpen:e.files.length-s.size,fallback:ee(n.state,s,e.files.length),trusted:o=>s.get(o)?.bounds,record:(o,{entries:c,raw_bytes:f,source:l})=>{const d=l===null||f===null?void 0:N(l,r);d===void 0||BigInt(f.length)!==d.size||d.changedAtNs+I>=t||s.get(o)?.signature===d.signature||(s.set(o,{signature:d.signature,bounds:J(c)}),u=!0)},revalidate:async o=>{const c=await T(e.historyDir,o,r),f=o.filter(l=>c.get(l)?.signature!==s.get(l)?.signature);for(const l of f)s.delete(l);return f},commit:async()=>{u&&(u=!1,await te(e.pmRoot,s))}}}async function te(e,t){try{if(await a.mkdir(m.join(e,"runtime")).catch(r=>{if(!Z(r))throw r}),!await b(e)||await D(e))return;await L(w(e),H(t),{createParentDirectories:!1,mode:384})}catch{}}const fe={areConsistentBounds:j,readAtMost:F,readerDigest:v,isTrustedSummaryFile:C,summaryByteCap:M,readerIdentityOf:R,checksumOf:_,setMinimumStreams:V,setReaderIdentity:K,setWallClock:X,signatureOf:N,RACY_WINDOW_NS:I,SUMMARY_VERSION:S,serializeSummary:H,parseStoredStream:z};export{U as HISTORY_STREAM_SUMMARY_MINIMUM_STREAMS,P as HISTORY_STREAM_SUMMARY_RELATIVE_PATH,fe as _testOnly,k as isCanonicalHistoryTimestamp,ce as openHistoryStreamSummary,J as summarizeHistoryStreamBounds};
|
|
3
3
|
//# sourceMappingURL=stream-summary.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{statSync as _}from"node:fs";import{normalizeItemId as v,normalizeRawItemId as E}from"../item/id.js";import{getHistoryPath as I}from"../store/paths.js";import{EXIT_CODE as c}from"../shared/constants.js";import{renderPmCommand as u}from"../shared/command-line.js";import{PmCliError as y}from"../shared/errors.js";import{readHistoryEntries as x}from"./read.js";import{applyHistoryPatch as R,replayHistoryToTarget as T,resolveHistoryTarget as w}from"./projection.js";import{EMPTY_REPLAY_DOCUMENT as C}from"./replay.js";import{historyVersionOffset as P}from"./version-address.js";function b(n,a){let i=-1,o=structuredClone(C);for(const[r,m]of n.entries()){if(o=R(o,m.patch,r+1,m.op),o.metadata.id!==void 0&&o.metadata.id!==a)throw new y(`History belongs to item ${String(o.metadata.id)}, expected ${a}.`,c.GENERIC_FAILURE,{code:"history_replay_invalid",required:"Recover the correct history stream for this item before attempting restoration."});o.metadata.id===a&&Array.isArray(o.metadata.tags)&&(i=r)}const e=P(n,!0),s=i<0||e===null?null:e+i+1;let t=s===null?void 0:String(s);if(i>=0&&t===void 0){const r=n[i].ts;w(r,n).historyIndex===i&&(t=r)}return{version:s,target:t}}async function q(n,a,i){const o=new Set([v(a,i),E(a)]);for(const e of o){const s=I(n,e);if(!_(s,{throwIfNoEntry:!1})?.isFile())continue;const t=await x(s,e);let r=-1;if(t.forEach((h,g)=>{h.op==="delete"&&(r=g)}),r<0)continue;const m=T(t,t.length-1);if(Object.keys(m.metadata).length!==0)continue;const{version:p,target:d}=b(t,e),f=d===void 0?["history",e,"--verify"]:["get",e,"--at",d],l=u(f);return new y(`Item ${e} was deleted at ${t[r].ts}; its history is retained.`,c.NOT_FOUND,{code:"item_deleted",required:"Read a retained materialized version, then restore it if the item should exist again.",item_id:e,tombstone:{deleted:!0,deleted_at:t[r].ts,recoverable:d!==void 0,last_materialized_version:p},nextSteps:[l,...d===void 0?["Recover the pre-compaction history from version control."]:[u(["restore",e,d])]],recovery:{suggested_retry:l,suggested_retry_args:f}})}}export{q as buildDeletedItemError};
|
|
2
2
|
//# sourceMappingURL=tombstone.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import{EXIT_CODE as i}from"../shared/constants.js";import{PmCliError as s}from"../shared/errors.js";function c(r,n=!1){const o=r[0];if(o?.op!=="history_compact_baseline")return 0;const t=o.context?.history_compaction,e=typeof t=="object"&&t!==null&&"version_offset"in t?t.version_offset:void 0;if(typeof e=="number"&&Number.isSafeInteger(e)&&e>=0&&Number.isSafeInteger(e+r.length))return e;if(n)return null;throw new s("This compacted stream has no trustworthy version offset; numeric history addresses are unavailable.",i.USAGE,{code:"history_version_mapping_unavailable",required:"Use a retained timestamp or recover the pre-compaction stream from version control.",nextSteps:["Run pm history <id> --full to inspect the retained timestamps and checkpoint evidence."]})}export{c as historyVersionOffset};
|
|
2
2
|
//# sourceMappingURL=version-address.js.map
|