Skip to content

fix(pm-aggregator): create metadata DB parent directory before opening (#13293) - #13346

Merged
dezren39 merged 1 commit into
mainfrom
lane-wu-13293
Nov 23, 2026
Merged

dezren39 merged 1 commit into
mainfrom
lane-wu-13293

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Fix for #13293: pm-aggregator server boot crashed in clean environments with SQLITE_CANTOPEN.

Change (2 files, +42): openMetadataStore in pm-stack/aggregator/src/metadata-ingestion.ts now creates the metadata DB's parent directory (mkdirSync(dirname(path), { recursive: true }), :memory: exempt) before opening — mirroring the other state stores' mkdir-on-write. Genuine open failures still throw; only the missing-directory case self-heals. Two regression tests in test/metadata-ingestion.test.ts: a missing nested parent is created and the store opens with pm_metadata_items installed; an unhealable parent (a regular file in the path) still throws, fail-closed.

Verification (laptop, this branch):

  • bun test test/metadata-ingestion.test.ts — 15 pass / 0 fail, 67 expect() calls (mutation check by the original author: disabling the mkdir line fails exactly the new missing-directory test).
  • Clean-HOME boot: fresh empty HOME, bun run src/server.ts (fixtures source) → /api/health 200 {"status":"ok"}, ~/.local/state/pm-aggregator/pm-metadata.sqlite created by the boot, zero SQLITE_CANTOPEN in the log. (Free PM_AGG_PORT/PM_AGG_FRESHNESS_PORT overrides used — the defaults collide with the laptop's live pm-stack services; unrelated to this change.)
  • Boot suites (test/boot.test.ts, test/actions.test.ts, test/break-glass-route-9608.test.ts): paired comparison against the pristine base commit in the same environment — failure sets identical between base and this branch (spawned-server reachability flakes on the loaded laptop; zero SQLITE_CANTOPEN anywhere). Break-glass suite passes.
  • bunx tsc --noEmit clean.

History: fix authored by Lane WU, held by a platform execution-risk flag (record on #13293), cleared by Drew's batch approval 2026-11-23; landed by the recovery agent after the first landing agent ended silently.

{
  "direct_parent": null,
  "links": [],
  "lineage": {
    "design": null,
    "roadmap_item": null,
    "priority": null
  },
  "pm_meta": 1,
  "provenance": {
    "queue_id": null,
    "scheduled_start": null,
    "picked_up_at": null,
    "work_started_at": null,
    "created_at": "2026-11-23T14:01:58Z",
    "session_id": null,
    "lane": null,
    "host": "htch-runtime",
    "worktree": null,
    "model": null,
    "lane_start_issues": [],
    "workspace_ref": null,
    "auth_subject": "archer",
    "stamped_by": "fleet 0.1.0 (native)"
  }
}

Start Proof
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

#13293)

openMetadataStore opened the metadata DB without ensuring its parent
directory exists; bun:sqlite creates the file but not its parents, so a
clean environment (no ~/.local/state/pm-aggregator yet) crashed server
boot with SQLITE_CANTOPEN. Create the parent with mkdirSync recursive
before opening (:memory: exempt); genuine open failures still throw.

Adds two regression tests: a missing nested parent directory is created
and the store opens; an unhealable parent still fails closed.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2d181aa5-dc04-4886-bf9a-77d49088a188
Commits

Reviewing files that changed from the base of the PR and between 4b9df02 and a1dbcf6.

Files selected for processing: 2

  • pm-stack/aggregator/src/metadata-ingestion.ts
  • pm-stack/aggregator/test/metadata-ingestion.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T14:03:32.120111Z a1dbcf6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39
dezren39 merged commit ae19862 into main Nov 23, 2026
2 checks passed
@dezren39
dezren39 deleted the lane-wu-13293 branch November 23, 2026 14:02
@dezren39 dezren39 added the audit:complete PR fully implemented spawning issue label Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

audit:complete PR fully implemented spawning issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant