Skip to content

fix(debugger): keep an unwritable ~/.argent from failing debugger-status - #1122

Closed
latekvo wants to merge 6 commits into
mainfrom
fix/log-file-writer-mkdir-eacces
Closed

latekvo wants to merge 6 commits into
mainfrom
fix/log-file-writer-mkdir-eacces

Conversation

@latekvo

@latekvo latekvo commented Sep 9, 2026 •

Copy link
Copy Markdown
Member

Fixes #908

Cause - LogFileWriter's constructor ran mkdir -p ~/.argent/tmp with no guard. Under a root-owned ~/.argent (what a sudo-run argent leaves behind) that threw a plain EACCES out of the JS-runtime-debugger factory, so debugger-status, debugger-connect and debugger-log-registry failed with it instead of connecting.

Fix - swallow the mkdirSync failure so the writer runs without a file, as it already does when ~/.argent/tmp is unwritable. debugger-log-registry adds a note whenever its file does not exist, saying how to fix permissions and how to get a session that has a file.

debugger-log-registry under a root-owned ~/.argent
Before HTTP 500: EACCES: permission denied, mkdir '~/.argent/tmp'
After status: "connected", counts and clusters, plus note: "No log file exists at <file> ... sudo chown -R "$USER" ~/.argent ... call stop-all-simulator-servers with devices: ["<id>"], then debugger-connect again."

Docs: only the tool description changes. No docs-site page describes this output.

Verification
  • E2E over HTTP against a tool-server on its own port, with HOME set to a temp dir whose .argent is 0500 and a mock Metro. On main, debugger-status, debugger-connect and debugger-log-registry return HTTP 500 EACCES. On this branch they return connected plus the note. Running the note's steps (chmod 700, then stop-all-simulator-servers {devices:["dev-1"]}, then debugger-connect) gives a new session with a log file on disk and no note.
  • test/metro/teardown-log-history.test.ts drives Registry -> JsRuntimeDebugger -> debugger-connect -> debugger-log-registry the same way. Each of these mutations turns it red: main's source (3 tests), the note overwriting the reaped-session note (1), the note's stop-all hint removed (1).
  • npx tsc --build, typecheck:tests, the tool-server suite (6750 passed, 1 skipped), and eslint and prettier on the changed files are all clean.

LogFileWriter's constructor mkdir -p'd ~/.argent/tmp unguarded, so a
root-owned ~/.argent (the state a sudo-run argent leaves behind) threw a
plain EACCES out of the JS-runtime-debugger factory. classifyNotConnected
finds no failure code on it, so debugger-status and debugger-log-registry
rethrow it raw instead of returning the discriminated not-connected
result their descriptions promise.

Swallowing the mkdir lands that state on the path an unwritable
~/.argent/tmp already takes: open() fails, entries buffer in memory, and
the debugger connection survives.
@coderabbitai

This comment has been minimized.

…kdir-eacces

# Conflicts:
#	packages/tool-server/test/debugger/log-file-writer.test.ts
…exist

A writer that could not create its file (unwritable ~/.argent or
~/.argent/tmp) still handed back a `file` path that the tool description
tells the agent to read, with nothing saying it is missing.
debugger-log-registry now adds a `note` naming the missing file, the
likely cause and the fix.
@latekvo
latekvo force-pushed the fix/log-file-writer-mkdir-eacces branch from cc40edc to f8b5abd Compare September 10, 2026 14:26
@latekvo

latekvo commented Sep 28, 2026

Copy link
Copy Markdown
Member Author

Still reproduces as of 2026-09-28 (main 133b1dfcd). The PR's two new tests still fail on main 133b1df: when ~/.argent is at mode 0500, the unguarded mkdirSync in the LogFileWriter constructor throws a raw EACCES: permission denied, mkdir '.../.argent/tmp', so debugger-connect fails instead of connecting without a log file.

@hubgan hubgan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I think you can merge it if you're fine with SKILL.md and tool description change.

Drop the SKILL.md line (the note describes itself in the tool output),
correct the note field's JSDoc, and pin the reaped + missing-file note
concatenation in a test.
@latekvo
latekvo marked this pull request as ready for review October 12, 2026 15:16
# Conflicts:
#	packages/tool-server/src/tools/debugger/debugger-log-registry.ts
#	packages/tool-server/src/utils/debugger/log-file-writer.ts
#	packages/tool-server/test/metro/teardown-log-history.test.ts
@latekvo

latekvo commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

Folded into #1753 as 8fc73e5, to review together with the other capture fixes.

@latekvo latekvo closed this Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An unwritable ~/.argent makes debugger-status throw a raw EACCES, against its documented "never fails" contract

2 participants