[PR #5591] [CLOSED] fix(ida): fail doctor readiness for FIFO registrations and unusable workspace roots #6983

Closed
opened 2026-11-01 21:44:29 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5591
Author: @kaoru0822-kitauji
Created: 10/20/2026
Status: ❌ Closed

Base: main ← Head: fix/ida-doctor-readiness


📝 Commits (1)

  • d80bda9 fix(ida): fail doctor readiness for FIFO registrations and unusable workspace roots

📊 Changes

5 files changed (+255 additions, -26 deletions)

View changed files

📝 docs/ida-provider.md (+1 -1)
📝 src/ida/IdaConfiguration.test.ts (+8 -0)
📝 src/ida/IdaConfiguration.ts (+57 -8)
📝 src/ida/IdaDoctor.ts (+59 -17)
➕ tests/boundary/cli/idaDoctorReadiness.test.ts (+130 -0)

📄 Description

Summary

Fixes #5559
Fixes #5561

rea doctor --provider ida reported IDA ready for a headless workspaceRoot that analysis cannot use, and stopped responding when REA_IDA_MCP_CONFIG selected a FIFO. Doctor now reports both as failed local readiness checks without starting IDA or creating anything.

Problem and expected behavior

  • #5561: readIdaConfiguration called statSync then a blocking readFileSync. A FIFO with no writer blocks that synchronous read, so doctor (and setup/analysis, which share the parser) never return and SIGINT cannot be handled. Expected: an unhealthy report with invalid_configuration, exit 1.
  • #5559: the registration schema checks only that workspaceRoot is absolute, and doctor's private_workspace check only checks platform authority. A regular file, missing path, or non-writable directory passed doctor, then failed at IdaWorkspace.allocate with ENOTDIR/ENOENT/EACCES. Expected: private_workspace fails with workspaceRoot guidance, IDA available: false, exit 1.

Change and scope

  • src/ida/IdaConfiguration.ts (registration parser, the owner shared by doctor, setup, and the provider): opens the file with O_RDONLY | O_NONBLOCK | O_NOCTTY, rejects descriptors that are not regular files, and reads at most 64 KiB + 1 byte from the descriptor. The existing 64 KiB limit and error message are unchanged. The function stays synchronous because the resolveProviderRequestBudget and provider configuration callers are synchronous; the async openRegularFile helper in src/filesystem/ would have required changes across all of those consumers.
  • src/ida/IdaDoctor.ts: when a headless registration sets workspaceRoot, private_workspace also checks that the parent exists, is a directory (symlinks are followed, as realpath is in IdaWorkspace.allocate), and is W_OK|X_OK. A failure reports invalid_configuration / config_drift with remediation. Nothing is created. When workspaceRoot is omitted, behavior is unchanged.
  • docs/ida-provider.md: states what doctor validates.

Not included: doctor still does not check the default tmpdir() parent when workspaceRoot is omitted. Contribution scope: not applicable (a fix inside the existing read-only doctor boundary).

Contract and boundary impact

  • Semantic owner and earliest changed stage: the IDA registration parser (readIdaConfiguration) and the IDA doctor inspection.

  • Contribution scope fit and linked maintainer decision: not applicable; read-only diagnostics fix.

  • CLI and MCP/tool-catalog contract: no schema change. Existing registration / private_workspace check names and the existing invalid_configuration code are reused.

  • Provider, bridge, target-format, or platform compatibility: O_NONBLOCK/O_NOCTTY fall back to 0 where undefined (Windows). Non-regular registration paths that were previously read (for example a character device) are now rejected.

  • Evidence, artifact, provenance, or reconstruction contract: none.

  • Target selection, authority, upstream behavior, and cleanup details: doctor still launches no IDA process and creates no workspace.

  • Generated metadata, package, or installation impact: none.

  • Read existing files or captured data.

Evidence and regression coverage

  • Tests added or updated:
    • tests/boundary/cli/idaDoctorReadiness.test.ts (new, POSIX only): public rea doctor --provider ida --json with a FIFO registration (bounded by a process timeout), and with workspaceRoot set to a regular file, a missing path, a 0500 directory (expected ready when running as root), a writable directory, and omitted. It also asserts that the missing parent is not created and that the writable parent stays empty.
    • src/ida/IdaConfiguration.test.ts: adds a check that a 65,536-byte registration is accepted and a 65,537-byte one is rejected.
  • Base reproduction: with the source fix reverted, the new CLI test failed in both cases. The FIFO case timed out at 30 s, and the workspaceRoot file case returned exit 0 / healthy: true where exit 1 was expected. With the fix restored, both pass.
  • User-visible CLI output (FIFO): registration check ok: false, code: "invalid_configuration", detail REA_IDA_MCP_CONFIG must select a regular JSON file: <path>, exit 1. Missing root: private_workspace ok: false, code: "invalid_configuration", detail IDA workspaceRoot <path> is not a usable directory: ENOENT: ..., exit 1.
  • Remaining proof gaps: macOS only; Linux and Windows were not run. No real IDA engine was used. The permission case was run as an unprivileged user.

Validation performed

  • npm run test:focused -- tests/boundary/cli/idaDoctorReadiness.test.ts src/ida/IdaDoctor.test.ts src/ida/IdaConfiguration.test.ts tests/composition/idaProvider.test.ts: 13 passed.
  • npm run test:focused -- tests/acceptance/setup/registrationRuntimeEnvironmentCli.test.ts tests/boundary/cli/idaRetainedCleanupCli.test.ts tests/boundary/cli/idaStartupAttributionCli.test.ts tests/boundary/providers/ida/*.test.ts: 57 passed, 1 skipped (Windows-only).
  • The same new CLI test with the source fix reverted: 2 failed, as described above.
  • npm run check:fast: passed.
  • npm run docs:check: passed.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Configurations that analysis could not use now fail doctor.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS arm64 with fake IDA registrations only.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: doctor stays read-only. The registration read is non-blocking and bounded.

Author readiness

Human owner: @kaoru0822-kitauji

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/5591 **Author:** [@kaoru0822-kitauji](https://github.com/kaoru0822-kitauji) **Created:** 10/20/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/ida-doctor-readiness` --- ### 📝 Commits (1) - [`d80bda9`](https://github.com/morluto/rea/commit/d80bda9bec08349637463f2143006b0f61a41ca3) fix(ida): fail doctor readiness for FIFO registrations and unusable workspace roots ### 📊 Changes **5 files changed** (+255 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `docs/ida-provider.md` (+1 -1) 📝 `src/ida/IdaConfiguration.test.ts` (+8 -0) 📝 `src/ida/IdaConfiguration.ts` (+57 -8) 📝 `src/ida/IdaDoctor.ts` (+59 -17) ➕ `tests/boundary/cli/idaDoctorReadiness.test.ts` (+130 -0) </details> ### 📄 Description ## Summary Fixes #5559 Fixes #5561 `rea doctor --provider ida` reported IDA ready for a headless `workspaceRoot` that analysis cannot use, and stopped responding when `REA_IDA_MCP_CONFIG` selected a FIFO. Doctor now reports both as failed local readiness checks without starting IDA or creating anything. ## Problem and expected behavior - #5561: `readIdaConfiguration` called `statSync` then a blocking `readFileSync`. A FIFO with no writer blocks that synchronous read, so doctor (and setup/analysis, which share the parser) never return and SIGINT cannot be handled. Expected: an unhealthy report with `invalid_configuration`, exit 1. - #5559: the registration schema checks only that `workspaceRoot` is absolute, and doctor's `private_workspace` check only checks platform authority. A regular file, missing path, or non-writable directory passed doctor, then failed at `IdaWorkspace.allocate` with `ENOTDIR`/`ENOENT`/`EACCES`. Expected: `private_workspace` fails with `workspaceRoot` guidance, IDA `available: false`, exit 1. ## Change and scope - `src/ida/IdaConfiguration.ts` (registration parser, the owner shared by doctor, setup, and the provider): opens the file with `O_RDONLY | O_NONBLOCK | O_NOCTTY`, rejects descriptors that are not regular files, and reads at most 64 KiB + 1 byte from the descriptor. The existing 64 KiB limit and error message are unchanged. The function stays synchronous because the `resolveProviderRequestBudget` and provider configuration callers are synchronous; the async `openRegularFile` helper in `src/filesystem/` would have required changes across all of those consumers. - `src/ida/IdaDoctor.ts`: when a headless registration sets `workspaceRoot`, `private_workspace` also checks that the parent exists, is a directory (symlinks are followed, as `realpath` is in `IdaWorkspace.allocate`), and is `W_OK|X_OK`. A failure reports `invalid_configuration` / `config_drift` with remediation. Nothing is created. When `workspaceRoot` is omitted, behavior is unchanged. - `docs/ida-provider.md`: states what doctor validates. Not included: doctor still does not check the default `tmpdir()` parent when `workspaceRoot` is omitted. Contribution scope: not applicable (a fix inside the existing read-only doctor boundary). ## Contract and boundary impact - Semantic owner and earliest changed stage: the IDA registration parser (`readIdaConfiguration`) and the IDA doctor inspection. - Contribution scope fit and linked maintainer decision: not applicable; read-only diagnostics fix. - CLI and MCP/tool-catalog contract: no schema change. Existing `registration` / `private_workspace` check names and the existing `invalid_configuration` code are reused. - Provider, bridge, target-format, or platform compatibility: `O_NONBLOCK`/`O_NOCTTY` fall back to 0 where undefined (Windows). Non-regular registration paths that were previously read (for example a character device) are now rejected. - Evidence, artifact, provenance, or reconstruction contract: none. - Target selection, authority, upstream behavior, and cleanup details: doctor still launches no IDA process and creates no workspace. - Generated metadata, package, or installation impact: none. - [x] Read existing files or captured data. ## Evidence and regression coverage - Tests added or updated: - `tests/boundary/cli/idaDoctorReadiness.test.ts` (new, POSIX only): public `rea doctor --provider ida --json` with a FIFO registration (bounded by a process timeout), and with `workspaceRoot` set to a regular file, a missing path, a `0500` directory (expected ready when running as root), a writable directory, and omitted. It also asserts that the missing parent is not created and that the writable parent stays empty. - `src/ida/IdaConfiguration.test.ts`: adds a check that a 65,536-byte registration is accepted and a 65,537-byte one is rejected. - Base reproduction: with the source fix reverted, the new CLI test failed in both cases. The FIFO case timed out at 30 s, and the `workspaceRoot` file case returned exit 0 / `healthy: true` where exit 1 was expected. With the fix restored, both pass. - User-visible CLI output (FIFO): `registration` check `ok: false`, `code: "invalid_configuration"`, detail `REA_IDA_MCP_CONFIG must select a regular JSON file: <path>`, exit 1. Missing root: `private_workspace` `ok: false`, `code: "invalid_configuration"`, detail `IDA workspaceRoot <path> is not a usable directory: ENOENT: ...`, exit 1. - Remaining proof gaps: macOS only; Linux and Windows were not run. No real IDA engine was used. The permission case was run as an unprivileged user. ## Validation performed - `npm run test:focused -- tests/boundary/cli/idaDoctorReadiness.test.ts src/ida/IdaDoctor.test.ts src/ida/IdaConfiguration.test.ts tests/composition/idaProvider.test.ts`: 13 passed. - `npm run test:focused -- tests/acceptance/setup/registrationRuntimeEnvironmentCli.test.ts tests/boundary/cli/idaRetainedCleanupCli.test.ts tests/boundary/cli/idaStartupAttributionCli.test.ts tests/boundary/providers/ida/*.test.ts`: 57 passed, 1 skipped (Windows-only). - The same new CLI test with the source fix reverted: 2 failed, as described above. - `npm run check:fast`: passed. - `npm run docs:check`: passed. ## Compatibility, safety, and release - Breaking changes or migration steps: none. Configurations that analysis could not use now fail doctor. - Real Hopper/Ghidra, browser, or OS coverage: macOS arm64 with fake IDA registrations only. - Package or release metadata impact: none. - Security, privacy, process, or containment review: doctor stays read-only. The registration read is non-blocking and bounded. ## Author readiness Human owner: @kaoru0822-kitauji - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [ ] This PR addresses a concrete problem or an agreed enhancement. - [ ] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [ ] The PR has one focused outcome and the title follows `type(scope): outcome`. - [ ] Related issue is linked, or the reason for not linking one is stated above. - [ ] Tests cover changed observable behavior and meaningful failure paths. - [ ] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [ ] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:44:29 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6983
No description provided.