vouchington-tooling 0.44.0 → 0.45.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/agent-blackboard/client.d.mts +6 -0
  2. package/dist/cli/usage.d.mts +1 -1
  3. package/dist/cli/usage.mjs +1 -1
  4. package/dist/mcp-server/context.d.mts +3 -0
  5. package/dist/mcp-server/dispatch.d.mts +3 -0
  6. package/dist/mcp-server/dispatch.mjs +7 -1
  7. package/dist/mcp-server/fake-blackboard.test-helpers.d.mts +2 -0
  8. package/dist/mcp-server/fake-blackboard.test-helpers.mjs +3 -0
  9. package/dist/mcp-server/handlers-pr.d.mts +1 -1
  10. package/dist/mcp-server/handlers-pr.mjs +6 -97
  11. package/dist/mcp-server/handlers-retrospective-save.d.mts +10 -0
  12. package/dist/mcp-server/handlers-retrospective-save.mjs +138 -0
  13. package/dist/mcp-server/handlers-retrospective.d.mts +1 -12
  14. package/dist/mcp-server/handlers-retrospective.mjs +1 -154
  15. package/dist/mcp-server/handlers-session.mjs +25 -6
  16. package/dist/mcp-server/handlers-snapshot-cleanup.d.mts +7 -0
  17. package/dist/mcp-server/handlers-snapshot-cleanup.mjs +36 -0
  18. package/dist/mcp-server/harness.test-helpers.d.mts +2 -0
  19. package/dist/mcp-server/harness.test-helpers.mjs +1 -0
  20. package/dist/mcp-server/policy-run.d.mts +1 -0
  21. package/dist/mcp-server/policy-run.mjs +1 -0
  22. package/dist/mcp-server/pr-body.d.mts +4 -2
  23. package/dist/mcp-server/pr-body.mjs +15 -3
  24. package/dist/mcp-server/pr-defaults.d.mts +3 -0
  25. package/dist/mcp-server/pr-defaults.mjs +7 -2
  26. package/dist/mcp-server/pr-input.d.mts +12 -5
  27. package/dist/mcp-server/pr-input.mjs +21 -4
  28. package/dist/mcp-server/pr-live.d.mts +3 -1
  29. package/dist/mcp-server/pr-live.mjs +7 -2
  30. package/dist/mcp-server/pr-mode.d.mts +7 -0
  31. package/dist/mcp-server/pr-mode.mjs +34 -0
  32. package/dist/mcp-server/pr-no-source.d.mts +9 -0
  33. package/dist/mcp-server/pr-no-source.mjs +22 -0
  34. package/dist/mcp-server/pr-prepare.d.mts +25 -0
  35. package/dist/mcp-server/pr-prepare.mjs +103 -0
  36. package/dist/mcp-server/preview-registry.d.mts +25 -0
  37. package/dist/mcp-server/preview-registry.mjs +38 -0
  38. package/dist/mcp-server/retrospective-check.d.mts +3 -0
  39. package/dist/mcp-server/retrospective-check.mjs +38 -0
  40. package/dist/mcp-server/retrospective-input.mjs +2 -2
  41. package/dist/mcp-server/retrospective-preview.d.mts +17 -0
  42. package/dist/mcp-server/retrospective-preview.mjs +60 -0
  43. package/dist/mcp-server/snapshot-registry.d.mts +25 -0
  44. package/dist/mcp-server/snapshot-registry.mjs +32 -0
  45. package/dist/mcp-server/tools-pr.mjs +20 -4
  46. package/dist/mcp-server/tools-retrospective.mjs +25 -5
  47. package/dist/mcp-server/tools.mjs +6 -0
  48. package/docs/mcp-server.md +95 -23
  49. package/package.json +3 -3
  50. package/skills/retrospective/SKILL.md +3 -1
  51. package/skills/retrospective-distill/SKILL.md +5 -0
@@ -32,6 +32,12 @@ export type BlackboardClientModule = {
32
32
  Snapshots?: new (connection: BlackboardConnection) => {
33
33
  export(options?: unknown): Promise<unknown>;
34
34
  };
35
+ /** Newer clients own the ownership markers of their exports and clean them with a capability. */
36
+ cleanupSnapshotPartitions?: (options: {
37
+ path?: string;
38
+ directory?: string;
39
+ cleanupToken?: string;
40
+ }) => Promise<void>;
35
41
  };
36
42
  type BlackboardClientLoader = () => Promise<BlackboardClientModule>;
37
43
  export type BlackboardClientDependencies = {
@@ -1,4 +1,4 @@
1
- export declare const USAGE = "Usage: vouchington <command> [options]\n\nCommands:\n runner-port-policy Print or validate a runner port policy\n with-host-lock Run a command under a host-wide lock\n gha-runtime-audit Audit successful GitHub Actions job runtimes\n require-up-to-date Require HEAD to include a fetched remote branch\n fresh-base Classify the worktree against a remote base branch\n gitleaks-directory-scan Scan a directory with Gitleaks\n ast-grep-examples Run AST-grep rule examples\n ast-grep-pack Print shipped unconditional AST-grep pack paths as JSON\n gha-workspace-policy Check GitHub Actions workspace safety policy\n gha-output Write a collision-safe multiline GITHUB_OUTPUT record\n gha-needs-results Fail if required GitHub Actions job results failed\n download-with-diagnostics Download a URL and report HTTP status on failure\n download-optional-run-artifacts Download optional artifacts from the current run\n host-pressure-diagnostics Print a bounded host memory/OOM/PSI snapshot\n allocate-browser-safe-ports Allocate Fetch-safe localhost ports\n diagnose-port-collision Capture bounded localhost port diagnostics\n prepare-trivy-db Download the Trivy vulnerability database\n gha-artifacts-cleanup Delete classified GitHub Actions artifacts\n http-origin Validate an optional HTTP(S) origin\n vitest-blob-manifest Stamp a vitest-blob-manifest:v1 identity file\n vitest-report-attempt Write or read a Vitest report-attempt marker\n prepare-vitest-reports Validate and select Vitest report JSON files\n pnpm-install Install a pnpm workspace with retry and release-age fail-fast\n check-cache-size Measure a path and decide whether to save a GHA cache\n make-shard-matrix Emit a [1..N] GitHub Actions shard matrix\n load-runner-env Overlay a runner env file onto GITHUB_ENV with injection guards\n clean-workspace Reset a persistent-runner workspace with a fork-PR trust gate\n install-github-release Download a checksum-verified GitHub Release binary\n run-with-timeout Run a command with GNU timeout or a Perl fallback\n lint-links Two-pass lychee: internal links fail, external warn\n materialize-pr-context Dump PR title/body/files/diff/comments and #N crawl\n wait-for-apt-locks Wait until apt/dpkg lock files are free\n install-playwright-chromium-arm64 Install Playwright Chromium from browsers.json\n ghcr-package-retention Delete old GHCR package versions past KEEP_MIN\n harness-admission-lane Compute a GITHUB_RUN_ID admission lane for fleet fan-out\n harness-assert-gates Fail if any named HARNESS_*_ENABLED gate is enabled\n gha-collaborator-trust Classify authors as write-access collaborators or not\n nuget-central-version Validate a Directory.Packages.props PackageVersion delta\n swift-semantic-equal Compare Swift sources ignoring comments and whitespace\n post-review Post one COMMENT review from a staged payload file\n stage-review-payload Validate a review payload file into a staging directory\n retrospective-transcript Format facts from Claude-compatible, Codex, or Grok transcripts\n link-skill Link one packaged skill into an explicit consumer directory\n retrospective-facts Gather immutable facts for a retrospective\n agent-blackboard Probe and journal an Agent Blackboard deployment\n mcp Serve the agent-blackboard journal tools over stdio (MCP)\n\nOptions:\n -h, --help Show this help\n -v, --version Print the package version\n\nrunner-port-policy\n (no args) Print the shipped policy as JSON\n --file <path> Validate and print a policy file\n --reserved <port> Print true if the port is reserved\n\nwith-host-lock\n --name <family>\n [--slots <n>]\n --timeout-seconds <n>\n [--command-timeout-seconds <n>]\n [--failure-diagnostics <absolute-script>]\n [--on-acquire-timeout fail|run-unlocked]\n -- <command> [args...]\n\ngha-runtime-audit\n [--repository owner/name] Default GITHUB_REPOSITORY\n [--branch main]\n [--median-threshold-floor <seconds>] Off unless set. Must be below the ceiling\n [--median-threshold-ceiling <seconds>] Default 360. Flags a five-sample median above this\n --pr-workflow <name|/regex/> Repeatable\n --push-workflow <name|/regex/> Repeatable\n\nrequire-up-to-date --remote <name> --branch <name>\nfresh-base [--remote <name>] [--branch <name>] [--skip-fetch]\ngitleaks-directory-scan --config <path> [--directory <path>]\nast-grep-examples --rules <directory> --config <path>\nast-grep-pack\ngha-workspace-policy [--root <directory>] [--workflow-directory <directory>] [--action-directory <directory>]\n\ngha-output <name>\ngha-needs-results [label]\ndownload-with-diagnostics <url> <destination> [-- curl-args...]\ndownload-optional-run-artifacts (--name <name>... | --pattern <pattern>) --dir <directory>\nhost-pressure-diagnostics\nallocate-browser-safe-ports <count> [--policy path] [--forbidden-ports path]\ndiagnose-port-collision [--ports \"2200 2216\"] [--output-dir PATH]\nprepare-trivy-db\ngha-artifacts-cleanup run --run-id <id> [--keep-pattern glob] [--delete-pattern glob] [--patterns-file json]\ngha-artifacts-cleanup sweep --older-than-hours <n> [--keep-pattern glob] [--delete-pattern glob] [--patterns-file json]\nhttp-origin [--field NAME] [value]\nvitest-blob-manifest <suite> [reports-directory]\nvitest-report-attempt <write DIRECTORY SUITE|read ROOT>\nprepare-vitest-reports [primary-directory] [fallback-directory] [output-directory]\npnpm-install --runner-lifecycle persistent|ephemeral|ephemeral-full --install-scripts true|false\ncheck-cache-size <path> <max-bytes> <label>\nmake-shard-matrix <total>\nload-runner-env\nclean-workspace\ninstall-github-release --repo owner/name --version X --asset 'name-{platform}.tar.gz' --bin name [--tag-prefix PREFIX] [--expected-sha256 SHA256] [--no-checksum] [--checksums-asset NAME] [--version-flag FLAG] [--bin-dir DIR]\nrun-with-timeout <timeout-seconds> <kill-after-seconds> <command...>\nlint-links [--offline] [--config PATH] [--glob PATTERN] [files...]\nmaterialize-pr-context\nwait-for-apt-locks\ninstall-playwright-chromium-arm64 [name:archive...]\nghcr-package-retention <url-encoded-package>...\nharness-admission-lane <lanes>\nharness-assert-gates <gate>...\ngha-collaborator-trust <owner/repo> [--allow-bot <login>]... < authors.json\nnuget-central-version <trusted-props> <candidate-props> <metadata-json> <output-props>\nswift-semantic-equal <base> <head> <file.swift>\npost-review\nstage-review-payload optional|required <source> <destination>\nretrospective-transcript [--session-id ID] [--jsonl PATH] [--projects-dir PATH] [--codex-sessions-dir PATH] [--grok-sessions-dir PATH]\nlink-skill <name> --source-root <skills-dir> --target-root <consumer-skills-dir> Link a packaged or repository-local skill\nretrospective-facts (--pr NUMBER | --branch NAME | --no-pr) [--repo OWNER/NAME] [--raw]\nagent-blackboard probe\nagent-blackboard journal append --mode interactive|autonomous --source-event-id ID --work-outcome OUTCOME --coverage-status STATUS --session-id UUID --agent NAME --version VERSION --file PATH --repository OWNER/NAME [--repository OWNER/NAME ...] [--parent-session-id UUID] [--timestamp ISO8601] [--coverage-source SOURCE,...] [--dropped-count N] [--outbox-directory PATH]\nagent-blackboard journal entries --session-id UUID\nagent-blackboard journal status --session-id UUID --outbox-directory PATH\nagent-blackboard journal flush --outbox-directory PATH [--session-id UUID]\nInteractive journal append requires --outbox-directory PATH.\nagent-blackboard journal is deprecated and being phased out: agents journal through the mcp server.\nagent-blackboard snapshot partition --snapshot PATH --checksum SHA256 --counts '{\"sessions\":N,\"entries\":N,\"records\":N,\"bytes\":N}'\nagent-blackboard snapshot cleanup [--snapshot PATH] [--partition-directory PATH --receipt JSON]\nmcp\n (no args) Serve journal_append, journal_entries, outbox_status, outbox_flush,\n session_ensure, retrospective_check, retrospective_save,\n pr_validate, pr_create, pr_update,\n snapshot_export, and session_archive over stdio.\n Needs the optional @modelcontextprotocol/sdk peer (and zod).\n Launch it from inside the repository's git worktree.\n";
1
+ export declare const USAGE = "Usage: vouchington <command> [options]\n\nCommands:\n runner-port-policy Print or validate a runner port policy\n with-host-lock Run a command under a host-wide lock\n gha-runtime-audit Audit successful GitHub Actions job runtimes\n require-up-to-date Require HEAD to include a fetched remote branch\n fresh-base Classify the worktree against a remote base branch\n gitleaks-directory-scan Scan a directory with Gitleaks\n ast-grep-examples Run AST-grep rule examples\n ast-grep-pack Print shipped unconditional AST-grep pack paths as JSON\n gha-workspace-policy Check GitHub Actions workspace safety policy\n gha-output Write a collision-safe multiline GITHUB_OUTPUT record\n gha-needs-results Fail if required GitHub Actions job results failed\n download-with-diagnostics Download a URL and report HTTP status on failure\n download-optional-run-artifacts Download optional artifacts from the current run\n host-pressure-diagnostics Print a bounded host memory/OOM/PSI snapshot\n allocate-browser-safe-ports Allocate Fetch-safe localhost ports\n diagnose-port-collision Capture bounded localhost port diagnostics\n prepare-trivy-db Download the Trivy vulnerability database\n gha-artifacts-cleanup Delete classified GitHub Actions artifacts\n http-origin Validate an optional HTTP(S) origin\n vitest-blob-manifest Stamp a vitest-blob-manifest:v1 identity file\n vitest-report-attempt Write or read a Vitest report-attempt marker\n prepare-vitest-reports Validate and select Vitest report JSON files\n pnpm-install Install a pnpm workspace with retry and release-age fail-fast\n check-cache-size Measure a path and decide whether to save a GHA cache\n make-shard-matrix Emit a [1..N] GitHub Actions shard matrix\n load-runner-env Overlay a runner env file onto GITHUB_ENV with injection guards\n clean-workspace Reset a persistent-runner workspace with a fork-PR trust gate\n install-github-release Download a checksum-verified GitHub Release binary\n run-with-timeout Run a command with GNU timeout or a Perl fallback\n lint-links Two-pass lychee: internal links fail, external warn\n materialize-pr-context Dump PR title/body/files/diff/comments and #N crawl\n wait-for-apt-locks Wait until apt/dpkg lock files are free\n install-playwright-chromium-arm64 Install Playwright Chromium from browsers.json\n ghcr-package-retention Delete old GHCR package versions past KEEP_MIN\n harness-admission-lane Compute a GITHUB_RUN_ID admission lane for fleet fan-out\n harness-assert-gates Fail if any named HARNESS_*_ENABLED gate is enabled\n gha-collaborator-trust Classify authors as write-access collaborators or not\n nuget-central-version Validate a Directory.Packages.props PackageVersion delta\n swift-semantic-equal Compare Swift sources ignoring comments and whitespace\n post-review Post one COMMENT review from a staged payload file\n stage-review-payload Validate a review payload file into a staging directory\n retrospective-transcript Format facts from Claude-compatible, Codex, or Grok transcripts\n link-skill Link one packaged skill into an explicit consumer directory\n retrospective-facts Gather immutable facts for a retrospective\n agent-blackboard Probe and journal an Agent Blackboard deployment\n mcp Serve the agent-blackboard journal tools over stdio (MCP)\n\nOptions:\n -h, --help Show this help\n -v, --version Print the package version\n\nrunner-port-policy\n (no args) Print the shipped policy as JSON\n --file <path> Validate and print a policy file\n --reserved <port> Print true if the port is reserved\n\nwith-host-lock\n --name <family>\n [--slots <n>]\n --timeout-seconds <n>\n [--command-timeout-seconds <n>]\n [--failure-diagnostics <absolute-script>]\n [--on-acquire-timeout fail|run-unlocked]\n -- <command> [args...]\n\ngha-runtime-audit\n [--repository owner/name] Default GITHUB_REPOSITORY\n [--branch main]\n [--median-threshold-floor <seconds>] Off unless set. Must be below the ceiling\n [--median-threshold-ceiling <seconds>] Default 360. Flags a five-sample median above this\n --pr-workflow <name|/regex/> Repeatable\n --push-workflow <name|/regex/> Repeatable\n\nrequire-up-to-date --remote <name> --branch <name>\nfresh-base [--remote <name>] [--branch <name>] [--skip-fetch]\ngitleaks-directory-scan --config <path> [--directory <path>]\nast-grep-examples --rules <directory> --config <path>\nast-grep-pack\ngha-workspace-policy [--root <directory>] [--workflow-directory <directory>] [--action-directory <directory>]\n\ngha-output <name>\ngha-needs-results [label]\ndownload-with-diagnostics <url> <destination> [-- curl-args...]\ndownload-optional-run-artifacts (--name <name>... | --pattern <pattern>) --dir <directory>\nhost-pressure-diagnostics\nallocate-browser-safe-ports <count> [--policy path] [--forbidden-ports path]\ndiagnose-port-collision [--ports \"2200 2216\"] [--output-dir PATH]\nprepare-trivy-db\ngha-artifacts-cleanup run --run-id <id> [--keep-pattern glob] [--delete-pattern glob] [--patterns-file json]\ngha-artifacts-cleanup sweep --older-than-hours <n> [--keep-pattern glob] [--delete-pattern glob] [--patterns-file json]\nhttp-origin [--field NAME] [value]\nvitest-blob-manifest <suite> [reports-directory]\nvitest-report-attempt <write DIRECTORY SUITE|read ROOT>\nprepare-vitest-reports [primary-directory] [fallback-directory] [output-directory]\npnpm-install --runner-lifecycle persistent|ephemeral|ephemeral-full --install-scripts true|false\ncheck-cache-size <path> <max-bytes> <label>\nmake-shard-matrix <total>\nload-runner-env\nclean-workspace\ninstall-github-release --repo owner/name --version X --asset 'name-{platform}.tar.gz' --bin name [--tag-prefix PREFIX] [--expected-sha256 SHA256] [--no-checksum] [--checksums-asset NAME] [--version-flag FLAG] [--bin-dir DIR]\nrun-with-timeout <timeout-seconds> <kill-after-seconds> <command...>\nlint-links [--offline] [--config PATH] [--glob PATTERN] [files...]\nmaterialize-pr-context\nwait-for-apt-locks\ninstall-playwright-chromium-arm64 [name:archive...]\nghcr-package-retention <url-encoded-package>...\nharness-admission-lane <lanes>\nharness-assert-gates <gate>...\ngha-collaborator-trust <owner/repo> [--allow-bot <login>]... < authors.json\nnuget-central-version <trusted-props> <candidate-props> <metadata-json> <output-props>\nswift-semantic-equal <base> <head> <file.swift>\npost-review\nstage-review-payload optional|required <source> <destination>\nretrospective-transcript [--session-id ID] [--jsonl PATH] [--projects-dir PATH] [--codex-sessions-dir PATH] [--grok-sessions-dir PATH]\nlink-skill <name> --source-root <skills-dir> --target-root <consumer-skills-dir> Link a packaged or repository-local skill\nretrospective-facts (--pr NUMBER | --branch NAME | --no-pr) [--repo OWNER/NAME] [--raw]\nagent-blackboard probe\nagent-blackboard journal append --mode interactive|autonomous --source-event-id ID --work-outcome OUTCOME --coverage-status STATUS --session-id UUID --agent NAME --version VERSION --file PATH --repository OWNER/NAME [--repository OWNER/NAME ...] [--parent-session-id UUID] [--timestamp ISO8601] [--coverage-source SOURCE,...] [--dropped-count N] [--outbox-directory PATH]\nagent-blackboard journal entries --session-id UUID\nagent-blackboard journal status --session-id UUID --outbox-directory PATH\nagent-blackboard journal flush --outbox-directory PATH [--session-id UUID]\nInteractive journal append requires --outbox-directory PATH.\nagent-blackboard journal is deprecated and being phased out: agents journal through the mcp server.\nagent-blackboard snapshot partition --snapshot PATH --checksum SHA256 --counts '{\"sessions\":N,\"entries\":N,\"records\":N,\"bytes\":N}'\nagent-blackboard snapshot cleanup [--snapshot PATH] [--partition-directory PATH --receipt JSON]\nmcp\n (no args) Serve journal_append, journal_entries, outbox_status, outbox_flush,\n session_ensure, retrospective_check, retrospective_save,\n pr_validate, pr_create, pr_update,\n snapshot_export, snapshot_cleanup, and session_archive over stdio.\n Needs the optional @modelcontextprotocol/sdk peer (and zod).\n Launch it from inside the repository's git worktree.\n";
2
2
  export declare function printUsage(stream?: NodeJS.WritableStream): void;
3
3
  export declare function commandNames(usage?: string): string[];
4
4
  export declare function commandUsage(command: string, usage?: string): string;
@@ -130,7 +130,7 @@ mcp
130
130
  (no args) Serve journal_append, journal_entries, outbox_status, outbox_flush,
131
131
  session_ensure, retrospective_check, retrospective_save,
132
132
  pr_validate, pr_create, pr_update,
133
- snapshot_export, and session_archive over stdio.
133
+ snapshot_export, snapshot_cleanup, and session_archive over stdio.
134
134
  Needs the optional @modelcontextprotocol/sdk peer (and zod).
135
135
  Launch it from inside the repository's git worktree.
136
136
  `;
@@ -3,6 +3,7 @@ import type { FeedbackIdentity } from '../agent-blackboard/feedback-types.mts';
3
3
  import type { RunTextCommand } from '../gh-cli/exec.mts';
4
4
  import type { GhRunner } from './pr-gh.mts';
5
5
  import type { PolicySpawner } from './policy-spawn.mts';
6
+ import type { SnapshotRegistry } from './snapshot-registry.mts';
6
7
  import { type Args } from './args.mts';
7
8
  /** What a handler may rely on: every field here was validated before the handler ran. */
8
9
  export type ToolContext = {
@@ -14,6 +15,8 @@ export type ToolContext = {
14
15
  launchRoot: string | undefined;
15
16
  /** Test seam: replaces the child process a policy export runs in. */
16
17
  spawnPolicy?: PolicySpawner;
18
+ /** The server's record of its own exports, which `snapshot_cleanup` is bound to. */
19
+ snapshots: SnapshotRegistry;
17
20
  /** Runs git with the isolated environment; callers add their own `-C <worktree>`. */
18
21
  runGit: RunTextCommand;
19
22
  /** Test seam: replaces locating and running gh. */
@@ -2,6 +2,7 @@ import type { BlackboardClientDependencies } from '../agent-blackboard/client.mt
2
2
  import type { RunTextCommand } from '../gh-cli/exec.mts';
3
3
  import type { GhRunner } from './pr-gh.mts';
4
4
  import type { PolicySpawner } from './policy-spawn.mts';
5
+ import { type SnapshotRegistry } from './snapshot-registry.mts';
5
6
  export type ServerEnvironment = {
6
7
  /** The launch directory's worktree top level, or undefined when it is not inside one. */
7
8
  launchRoot: string | undefined;
@@ -20,6 +21,8 @@ export type ServerEnvironment = {
20
21
  user: string;
21
22
  host: string;
22
23
  };
24
+ /** Test seam: a fresh registry stands in for a server restart. Defaults to the process's own. */
25
+ snapshots?: SnapshotRegistry;
23
26
  };
24
27
  export type ToolCallResult = {
25
28
  content: Array<{
@@ -2,12 +2,16 @@ import { FeedbackDeliveryError } from "../agent-blackboard/index.mjs";
2
2
  import { optionalString, rejectUnknown, requireObject } from "./args.mjs";
3
3
  import { readSessionId } from "./context.mjs";
4
4
  import { journalAppend, journalEntries } from "./handlers-journal.mjs";
5
- import { retrospectiveCheck, retrospectiveSave } from "./handlers-retrospective.mjs";
5
+ import { retrospectiveSave } from "./handlers-retrospective.mjs";
6
+ import { retrospectiveCheck } from "./retrospective-check.mjs";
6
7
  import { outboxFlush, outboxStatus } from "./handlers-outbox.mjs";
8
+ import { snapshotCleanup } from "./handlers-snapshot-cleanup.mjs";
7
9
  import { sessionArchive, sessionEnsure, snapshotExport } from "./handlers-session.mjs";
8
10
  import { handlePrCreate, handlePrUpdate, handlePrValidate } from "./handlers-pr.mjs";
11
+ import { createSnapshotRegistry } from "./snapshot-registry.mjs";
9
12
  import { TOOLS } from "./tools.mjs";
10
13
  import { resolveWorktree } from "./worktree.mjs";
14
+ const PROCESS_SNAPSHOTS = createSnapshotRegistry();
11
15
  const HANDLERS = {
12
16
  journal_append: journalAppend,
13
17
  journal_entries: journalEntries,
@@ -20,6 +24,7 @@ const HANDLERS = {
20
24
  pr_create: handlePrCreate,
21
25
  pr_update: handlePrUpdate,
22
26
  snapshot_export: snapshotExport,
27
+ snapshot_cleanup: snapshotCleanup,
23
28
  session_archive: sessionArchive,
24
29
  };
25
30
  const DIAGNOSTIC_HINTS = {
@@ -60,6 +65,7 @@ export async function callTool(name, rawArguments, environment) {
60
65
  env: environment.env,
61
66
  launchRoot: environment.launchRoot,
62
67
  runGit: environment.runGit,
68
+ snapshots: environment.snapshots ?? PROCESS_SNAPSHOTS,
63
69
  ...(environment.runGh === undefined ? {} : { runGh: environment.runGh }),
64
70
  ...(environment.device === undefined ? {} : { device: environment.device }),
65
71
  ...(environment.spawnPolicy === undefined ? {} : { spawnPolicy: environment.spawnPolicy }),
@@ -13,6 +13,8 @@ export type FakeOptions = {
13
13
  omitArchive?: boolean;
14
14
  omitSnapshots?: boolean;
15
15
  exportResult?: unknown;
16
+ /** Gives the fake client its own capability-aware snapshot cleanup. */
17
+ clientCleanup?: (options: unknown) => Promise<void>;
16
18
  /** Makes `ensure` fail for any other identity, and `get` report a session with this one. */
17
19
  conflictingSession?: {
18
20
  id: string;
@@ -81,6 +81,9 @@ export function fakeBlackboard(options = {}) {
81
81
  Sessions,
82
82
  Entries,
83
83
  ...(options.omitSnapshots ? {} : { Snapshots }),
84
+ ...(options.clientCleanup === undefined
85
+ ? {}
86
+ : { cleanupSnapshotPartitions: options.clientCleanup }),
84
87
  };
85
88
  return { dependencies: { loadClient: async () => module }, calls, stored };
86
89
  }
@@ -1,4 +1,4 @@
1
- import { type ToolHandler } from './context.mts';
1
+ import type { ToolHandler } from './context.mts';
2
2
  export declare const handlePrValidate: ToolHandler;
3
3
  export declare const handlePrCreate: ToolHandler;
4
4
  export declare const handlePrUpdate: ToolHandler;
@@ -1,115 +1,24 @@
1
- import { hostname, userInfo } from 'node:os';
2
- import { validateGitHubBodyLength } from "../gh-cli/body-length.mjs";
3
1
  import { createPullRequest } from "../gh-cli/pr-create.mjs";
4
- import { assertPolicyAllowed } from "./context.mjs";
5
- import { runValidator } from "./policy-run.mjs";
6
- import { renderPullRequestBody, worktreeLabel } from "./pr-body.mjs";
7
2
  import { pullRequestNumber, withBodyFile } from "./pr-body-file.mjs";
8
3
  import { pullRequestDefaults } from "./pr-defaults.mjs";
9
- import { createGhRunner, ghEnvironment } from "./pr-gh.mjs";
10
- import { checkTitleLength, positiveInteger, readPullRequestInput, } from "./pr-input.mjs";
11
- import { preserveShepherdJournal } from "./pr-journal.mjs";
12
- import { assertJournalUnchanged, credentials, liveBase, livePullRequest, redactCredentials, } from "./pr-live.mjs";
13
- import { parseWorktreeList } from "./worktree.mjs";
14
- function gitIn(context) {
15
- return (args) => context.runGit(['-C', context.worktree, ...args]);
16
- }
17
- function ghIn(context) {
18
- const run = context.runGh ?? createGhRunner(context.env);
19
- const env = ghEnvironment(context.env);
20
- return (args) => run(args, { cwd: context.worktree, env });
21
- }
22
- async function currentBranch(git) {
23
- const branch = (await git(['rev-parse', '--abbrev-ref', 'HEAD'])).trim();
24
- if (branch === 'HEAD')
25
- throw new Error('the worktree has a detached HEAD: check out a branch');
26
- return branch;
27
- }
28
- async function label(context, git) {
29
- const listing = await git(['worktree', 'list', '--porcelain', '-z']);
30
- return worktreeLabel(context.worktree, parseWorktreeList(listing)[0]);
31
- }
4
+ import { positiveInteger } from "./pr-input.mjs";
5
+ import { assertJournalUnchanged } from "./pr-live.mjs";
6
+ import { ghIn, gitIn, policyFor, prepare } from "./pr-prepare.mjs";
32
7
  function readPr(args, required) {
33
8
  if (args.pr === undefined && !required)
34
9
  return undefined;
35
10
  return positiveInteger(args.pr, 'pr');
36
11
  }
37
- function policyFor(context) {
38
- return {
39
- worktree: context.worktree,
40
- env: context.env,
41
- ...(context.spawnPolicy === undefined ? {} : { spawn: context.spawnPolicy }),
42
- };
43
- }
44
- /** Renders the body, preserves the live journal for an update, and runs the policy validator. */
45
- async function prepare(args, context, pr) {
46
- assertPolicyAllowed(context);
47
- // No server credential may reach the policy or gh, whatever the caller wrote: every field is
48
- // redacted before anything is rendered or forwarded.
49
- const secrets = credentials(context.env);
50
- const given = redactCredentials(readPullRequestInput(args), secrets);
51
- checkTitleLength(given.title);
52
- const git = gitIn(context);
53
- const head = await currentBranch(git);
54
- // Branch names are refs passed to gh as is: redacting one would name a branch that does not exist.
55
- if (secrets.some((secret) => head.includes(secret)))
56
- throw new Error('the worktree branch name contains a server credential: rename the branch');
57
- if (secrets.some((secret) => args.base?.includes(secret)))
58
- throw new Error('base contains a server credential: use another base branch');
59
- const live = pr === undefined ? undefined : await livePullRequest(ghIn(context), pr);
60
- if (live !== undefined && live.headRefName !== head)
61
- throw new Error(`pull request ${pr} has head ${live.headRefName}, not the worktree branch ${head}`);
62
- const base = live === undefined
63
- ? given.base
64
- : liveBase(pr, live, redactCredentials(args.base, secrets));
65
- const input = { ...given, base };
66
- if (head === base)
67
- throw new Error(`head branch ${head} must differ from base ${base}`);
68
- const device = (context.device ?? (() => ({ user: userInfo().username, host: hostname() })))();
69
- let body = renderPullRequestBody(input, {
70
- sessionId: context.sessionId,
71
- ...device,
72
- worktree: await label(context, git),
73
- });
74
- if (live !== undefined)
75
- body = preserveShepherdJournal(body, live.body);
76
- body = redactCredentials(body, secrets);
77
- const length = validateGitHubBodyLength(body);
78
- if (!length.ok)
79
- throw new Error(`the rendered body has ${length.characterCount} characters; GitHub allows ${length.maxCharacterCount}`);
80
- const report = await runValidator({
81
- ...policyFor(context),
82
- export: 'validatePullRequest',
83
- input: {
84
- title: input.title,
85
- body,
86
- base: input.base,
87
- head,
88
- mode: input.mode,
89
- ...(pr === undefined ? {} : { pr }),
90
- },
91
- });
92
- const errors = 'errors' in report ? report.errors : [];
93
- const warnings = 'warnings' in report ? report.warnings : [];
94
- return {
95
- input,
96
- head,
97
- body,
98
- errors,
99
- warnings,
100
- ...(live === undefined ? {} : { liveBody: live.body }),
101
- };
102
- }
103
12
  function rejectErrors(prepared) {
104
13
  if (prepared.errors.length)
105
14
  throw new Error(`policy rejected the pull request:\n- ${prepared.errors.join('\n- ')}`);
106
15
  }
107
16
  export const handlePrValidate = async (args, context) => {
108
- const { body, errors, warnings } = await prepare(args, context, readPr(args, false));
17
+ const { body, errors, warnings } = await prepare(args, context, 'validate', readPr(args, false));
109
18
  return { body, errors, warnings };
110
19
  };
111
20
  export const handlePrCreate = async (args, context) => {
112
- const prepared = await prepare(args, context, undefined);
21
+ const prepared = await prepare(args, context, 'create', undefined);
113
22
  rejectErrors(prepared);
114
23
  const { input, head, body } = prepared;
115
24
  const defaults = await pullRequestDefaults(policyFor(context), input);
@@ -127,7 +36,7 @@ export const handlePrCreate = async (args, context) => {
127
36
  };
128
37
  export const handlePrUpdate = async (args, context) => {
129
38
  const pr = readPr(args, true);
130
- const prepared = await prepare(args, context, pr);
39
+ const prepared = await prepare(args, context, 'update', pr);
131
40
  rejectErrors(prepared);
132
41
  await assertJournalUnchanged(ghIn(context), pr, prepared.liveBody, prepared.input.base);
133
42
  const url = await withBodyFile(prepared.body, async (bodyFile) => (await ghIn(context)([
@@ -0,0 +1,10 @@
1
+ import { type ToolHandler } from './context.mts';
2
+ /** The default event id, hashed when the session id would push it past the 256-byte limit. */
3
+ export declare function defaultSourceEventId(sessionId: string): string;
4
+ /**
5
+ * Saves the session's retrospective: composes it when `compose` is given, checks the arguments
6
+ * against the document's front matter, runs the checkout's `validateRetrospective` policy (in a
7
+ * child process) and writes nothing if it reports errors, then writes through the same verified
8
+ * path as `journal_append`.
9
+ */
10
+ export declare const retrospectiveSave: ToolHandler;
@@ -0,0 +1,138 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { createFeedbackEnvelope, validateFeedbackEnvelope } from "../agent-blackboard/index.mjs";
3
+ import { optionalRecord, optionalString, requiredChoice, requiredString, requiredStringArray, } from "./args.mjs";
4
+ import { assertPolicyAllowed, readIdentity } from "./context.mjs";
5
+ import { MODES, OUTCOMES, readCoverage } from "./handlers-journal.mjs";
6
+ import { runValidator } from "./policy-run.mjs";
7
+ import { previewRegistry } from "./preview-registry.mjs";
8
+ import { deliver, saveFromPreview } from "./retrospective-preview.mjs";
9
+ import { parseRetrospectiveFrontMatter } from "./retrospective-front-matter.mjs";
10
+ import { FEEDBACK_MARKDOWN_MAX_BYTES, redactFeedbackText, } from "../agent-blackboard/feedback-codec.mjs";
11
+ import { composeFromArgs, sensitiveValues } from "./retrospective-input.mjs";
12
+ import { checkFrontMatter, resolveRepositories } from "./retrospective-resolve.mjs";
13
+ function readMarkdownSource(args) {
14
+ const compose = optionalRecord(args, 'compose');
15
+ if ((args.markdown === undefined) === (compose === undefined))
16
+ throw new Error('pass exactly one of markdown or compose');
17
+ return compose === undefined ? { markdown: requiredString(args, 'markdown') } : { compose };
18
+ }
19
+ /** The default event id, hashed when the session id would push it past the 256-byte limit. */
20
+ export function defaultSourceEventId(sessionId) {
21
+ const id = `retrospective-${sessionId}`;
22
+ return Buffer.byteLength(id) <= 256
23
+ ? id
24
+ : `retrospective-${createHash('sha256').update(sessionId).digest('hex')}`;
25
+ }
26
+ /**
27
+ * Saves the session's retrospective: composes it when `compose` is given, checks the arguments
28
+ * against the document's front matter, runs the checkout's `validateRetrospective` policy (in a
29
+ * child process) and writes nothing if it reports errors, then writes through the same verified
30
+ * path as `journal_append`.
31
+ */
32
+ export const retrospectiveSave = async (args, context) => {
33
+ assertPolicyAllowed(context);
34
+ const identity = readIdentity(args, context.sessionId);
35
+ const mode = requiredChoice(args, 'mode', MODES);
36
+ const sourceEventId = optionalString(args, 'sourceEventId') ?? defaultSourceEventId(context.sessionId);
37
+ if (args.previewToken !== undefined)
38
+ return saveFromPreview(args, context, identity, mode, sourceEventId);
39
+ const workOutcome = requiredChoice(args, 'workOutcome', OUTCOMES);
40
+ const feedbackCoverage = readCoverage(args);
41
+ const argRepositories = args.repositories === undefined ? undefined : requiredStringArray(args, 'repositories');
42
+ const category = optionalString(args, 'category');
43
+ if (args.dryRun !== undefined && typeof args.dryRun !== 'boolean')
44
+ throw new Error('dryRun must be a boolean');
45
+ const policy = {
46
+ worktree: context.worktree,
47
+ env: context.env,
48
+ ...(context.spawnPolicy === undefined ? {} : { spawn: context.spawnPolicy }),
49
+ };
50
+ const { markdown: given, compose } = readMarkdownSource(args);
51
+ if (compose !== undefined && args.knownSensitiveValues !== undefined)
52
+ throw new Error('with compose, pass knownSensitiveValues inside compose');
53
+ // A markdown save redacts every argument with the same values a compose save would.
54
+ const secrets = sensitiveValues(compose ?? { knownSensitiveValues: args.knownSensitiveValues }, context.env);
55
+ // Everything the policy sees is derived from the redacted document, never the raw input.
56
+ const redactedGiven = given === undefined ? undefined : redactFeedbackText(given, secrets);
57
+ // Reject a document that can never be stored before any policy export runs for it.
58
+ if (redactedGiven !== undefined && Buffer.byteLength(redactedGiven) > FEEDBACK_MARKDOWN_MAX_BYTES)
59
+ throw new Error(`markdown must be at most ${FEEDBACK_MARKDOWN_MAX_BYTES} bytes`);
60
+ const early = redactedGiven === undefined ? undefined : parseRetrospectiveFrontMatter(redactedGiven);
61
+ const repositories = await resolveRepositories(argRepositories, early?.repositories, policy);
62
+ const markdown = redactedGiven ??
63
+ redactFeedbackText(await composeFromArgs(compose, {
64
+ sessionId: context.sessionId,
65
+ repositories,
66
+ workOutcome,
67
+ feedbackCoverage,
68
+ worktree: context.worktree,
69
+ env: context.env,
70
+ dependencies: context.dependencies,
71
+ }), secrets);
72
+ const front = early ?? parseRetrospectiveFrontMatter(markdown);
73
+ checkFrontMatter(front, {
74
+ sessionId: context.sessionId,
75
+ workOutcome,
76
+ // The document was redacted before parsing, so compare it with equally redacted sources.
77
+ feedbackCoverage: {
78
+ ...feedbackCoverage,
79
+ sources: feedbackCoverage.sources.map((source) => redactFeedbackText(source, secrets)),
80
+ },
81
+ repositories: argRepositories,
82
+ });
83
+ // Building the envelope first rejects empty or oversized markdown before any policy runs.
84
+ const envelope = createFeedbackEnvelope({
85
+ schemaVersion: 1,
86
+ type: 'retrospective',
87
+ sourceEventId,
88
+ // The server owns the timestamp, as in journal_append.
89
+ timestamp: new Date().toISOString(),
90
+ date: front.date,
91
+ issues: front.issues,
92
+ prs: front.prs,
93
+ repositories,
94
+ markdown,
95
+ workOutcome,
96
+ feedbackCoverage,
97
+ ...(category === undefined ? {} : { category }),
98
+ }, { knownSensitiveValues: secrets });
99
+ const redactedFront = parseRetrospectiveFrontMatter(envelope.markdown);
100
+ validateFeedbackEnvelope(envelope);
101
+ const report = await runValidator({
102
+ ...policy,
103
+ export: 'validateRetrospective',
104
+ input: {
105
+ sessionId: context.sessionId,
106
+ parentSessionId: identity.parentSessionId,
107
+ mode,
108
+ workOutcome,
109
+ // The envelope's copy, which is redacted like the markdown.
110
+ feedbackCoverage: envelope.feedbackCoverage,
111
+ repositories,
112
+ markdown: envelope.markdown,
113
+ sourceEventId,
114
+ metadata: {
115
+ date: redactedFront.date,
116
+ issues: redactedFront.issues,
117
+ prs: redactedFront.prs,
118
+ description: redactedFront.description,
119
+ },
120
+ },
121
+ });
122
+ if ('errors' in report && report.errors.length)
123
+ throw new Error(`policy rejected the retrospective:\n- ${report.errors.join('\n- ')}`);
124
+ const warnings = 'warnings' in report ? report.warnings : [];
125
+ if (args.dryRun === true) {
126
+ const previewToken = previewRegistry.put({
127
+ sessionId: context.sessionId,
128
+ parentSessionId: identity.parentSessionId,
129
+ mode,
130
+ worktree: context.worktree,
131
+ sourceEventId,
132
+ envelope,
133
+ warnings,
134
+ });
135
+ return { markdown: envelope.markdown, previewToken, policy: { warnings } };
136
+ }
137
+ return { ...(await deliver(envelope, identity, mode, context)), policy: { warnings } };
138
+ };
@@ -1,12 +1 @@
1
- import { type ToolHandler } from './context.mts';
2
- /** Whether the session already holds a retrospective, and which (sourceEventId, issues, prs). */
3
- export declare const retrospectiveCheck: ToolHandler;
4
- /** The default event id, hashed when the session id would push it past the 256-byte limit. */
5
- export declare function defaultSourceEventId(sessionId: string): string;
6
- /**
7
- * Saves the session's retrospective: composes it when `compose` is given, checks the arguments
8
- * against the document's front matter, runs the checkout's `validateRetrospective` policy (in a
9
- * child process) and writes nothing if it reports errors, then writes through the same verified
10
- * path as `journal_append`.
11
- */
12
- export declare const retrospectiveSave: ToolHandler;
1
+ export { defaultSourceEventId, retrospectiveSave } from './handlers-retrospective-save.mts';
@@ -1,154 +1 @@
1
- import { createHash } from 'node:crypto';
2
- import { createFeedbackEnvelope, validateFeedbackEnvelope, writeFeedback, } from "../agent-blackboard/index.mjs";
3
- import { optionalRecord, optionalString, requiredChoice, requiredString, requiredStringArray, } from "./args.mjs";
4
- import { assertPolicyAllowed, outboxDirectory, readIdentity } from "./context.mjs";
5
- import { byCreatedAt, deliveryResponse, MODES, OUTCOMES, readCoverage, } from "./handlers-journal.mjs";
6
- import { readEntriesIfPresent } from "./journal-read.mjs";
7
- import { runValidator } from "./policy-run.mjs";
8
- import { parseRetrospectiveFrontMatter } from "./retrospective-front-matter.mjs";
9
- import { FEEDBACK_MARKDOWN_MAX_BYTES, redactFeedbackText, } from "../agent-blackboard/feedback-codec.mjs";
10
- import { composeFromArgs, sensitiveValues } from "./retrospective-input.mjs";
11
- import { checkFrontMatter, resolveRepositories } from "./retrospective-resolve.mjs";
12
- function retrospectiveData(entry) {
13
- const data = entry?.data;
14
- return data?.type === 'retrospective' ? data : undefined;
15
- }
16
- /** Whether the session already holds a retrospective, and which (sourceEventId, issues, prs). */
17
- export const retrospectiveCheck = async (args, context) => {
18
- const sourceEventId = optionalString(args, 'sourceEventId');
19
- const entries = await readEntriesIfPresent(context.sessionId, context.env, context.dependencies);
20
- const found = (entries ?? [])
21
- .toSorted(byCreatedAt)
22
- .flatMap((entry) => {
23
- const data = retrospectiveData(entry);
24
- return data === undefined ? [] : [data];
25
- })
26
- .filter((data) => sourceEventId === undefined || data.sourceEventId === sourceEventId)
27
- .map((data) => ({
28
- sourceEventId: data.sourceEventId,
29
- timestamp: data.timestamp,
30
- issues: data.issues ?? [],
31
- prs: data.prs ?? [],
32
- }));
33
- return { sessionId: context.sessionId, saved: found.length > 0, entries: found };
34
- };
35
- function readMarkdownSource(args) {
36
- const compose = optionalRecord(args, 'compose');
37
- if ((args.markdown === undefined) === (compose === undefined))
38
- throw new Error('pass exactly one of markdown or compose');
39
- return compose === undefined ? { markdown: requiredString(args, 'markdown') } : { compose };
40
- }
41
- /** The default event id, hashed when the session id would push it past the 256-byte limit. */
42
- export function defaultSourceEventId(sessionId) {
43
- const id = `retrospective-${sessionId}`;
44
- return Buffer.byteLength(id) <= 256
45
- ? id
46
- : `retrospective-${createHash('sha256').update(sessionId).digest('hex')}`;
47
- }
48
- /**
49
- * Saves the session's retrospective: composes it when `compose` is given, checks the arguments
50
- * against the document's front matter, runs the checkout's `validateRetrospective` policy (in a
51
- * child process) and writes nothing if it reports errors, then writes through the same verified
52
- * path as `journal_append`.
53
- */
54
- export const retrospectiveSave = async (args, context) => {
55
- assertPolicyAllowed(context);
56
- const identity = readIdentity(args, context.sessionId);
57
- const mode = requiredChoice(args, 'mode', MODES);
58
- const workOutcome = requiredChoice(args, 'workOutcome', OUTCOMES);
59
- const feedbackCoverage = readCoverage(args);
60
- const argRepositories = args.repositories === undefined ? undefined : requiredStringArray(args, 'repositories');
61
- const sourceEventId = optionalString(args, 'sourceEventId') ?? defaultSourceEventId(context.sessionId);
62
- const category = optionalString(args, 'category');
63
- if (args.dryRun !== undefined && typeof args.dryRun !== 'boolean')
64
- throw new Error('dryRun must be a boolean');
65
- const policy = {
66
- worktree: context.worktree,
67
- env: context.env,
68
- ...(context.spawnPolicy === undefined ? {} : { spawn: context.spawnPolicy }),
69
- };
70
- const { markdown: given, compose } = readMarkdownSource(args);
71
- const secrets = sensitiveValues(compose, context.env);
72
- // Everything the policy sees is derived from the redacted document, never the raw input.
73
- const redactedGiven = given === undefined ? undefined : redactFeedbackText(given, secrets);
74
- // Reject a document that can never be stored before any policy export runs for it.
75
- if (redactedGiven !== undefined && Buffer.byteLength(redactedGiven) > FEEDBACK_MARKDOWN_MAX_BYTES)
76
- throw new Error(`markdown must be at most ${FEEDBACK_MARKDOWN_MAX_BYTES} bytes`);
77
- const early = redactedGiven === undefined ? undefined : parseRetrospectiveFrontMatter(redactedGiven);
78
- const repositories = await resolveRepositories(argRepositories, early?.repositories, policy);
79
- const markdown = redactedGiven ??
80
- redactFeedbackText(await composeFromArgs(compose, {
81
- sessionId: context.sessionId,
82
- repositories,
83
- workOutcome,
84
- feedbackCoverage,
85
- worktree: context.worktree,
86
- env: context.env,
87
- dependencies: context.dependencies,
88
- }), secrets);
89
- const front = early ?? parseRetrospectiveFrontMatter(markdown);
90
- checkFrontMatter(front, {
91
- sessionId: context.sessionId,
92
- workOutcome,
93
- // The document was redacted before parsing, so compare it with equally redacted sources.
94
- feedbackCoverage: {
95
- ...feedbackCoverage,
96
- sources: feedbackCoverage.sources.map((source) => redactFeedbackText(source, secrets)),
97
- },
98
- repositories: argRepositories,
99
- });
100
- // Building the envelope first rejects empty or oversized markdown before any policy runs.
101
- const envelope = createFeedbackEnvelope({
102
- schemaVersion: 1,
103
- type: 'retrospective',
104
- sourceEventId,
105
- // The server owns the timestamp, as in journal_append.
106
- timestamp: new Date().toISOString(),
107
- date: front.date,
108
- issues: front.issues,
109
- prs: front.prs,
110
- repositories,
111
- markdown,
112
- workOutcome,
113
- feedbackCoverage,
114
- ...(category === undefined ? {} : { category }),
115
- }, { knownSensitiveValues: secrets });
116
- const redactedFront = parseRetrospectiveFrontMatter(envelope.markdown);
117
- validateFeedbackEnvelope(envelope);
118
- const report = await runValidator({
119
- ...policy,
120
- export: 'validateRetrospective',
121
- input: {
122
- sessionId: context.sessionId,
123
- parentSessionId: identity.parentSessionId,
124
- mode,
125
- workOutcome,
126
- // The envelope's copy, which is redacted like the markdown.
127
- feedbackCoverage: envelope.feedbackCoverage,
128
- repositories,
129
- markdown: envelope.markdown,
130
- sourceEventId,
131
- metadata: {
132
- date: redactedFront.date,
133
- issues: redactedFront.issues,
134
- prs: redactedFront.prs,
135
- description: redactedFront.description,
136
- },
137
- },
138
- });
139
- if ('errors' in report && report.errors.length)
140
- throw new Error(`policy rejected the retrospective:\n- ${report.errors.join('\n- ')}`);
141
- const warnings = 'warnings' in report ? report.warnings : [];
142
- if (args.dryRun === true)
143
- return { markdown: envelope.markdown, policy: { warnings } };
144
- const directory = mode === 'interactive' ? outboxDirectory(context.worktree) : undefined;
145
- const result = await writeFeedback({
146
- identity,
147
- envelope,
148
- mode,
149
- ...(directory === undefined ? {} : { outboxDirectory: directory }),
150
- env: context.env,
151
- dependencies: context.dependencies,
152
- });
153
- return { ...deliveryResponse(result, context, mode), policy: { warnings } };
154
- };
1
+ export { defaultSourceEventId, retrospectiveSave } from "./handlers-retrospective-save.mjs";