Skip to content

feat(B-0557 slice 2): try/catch readFileSync + readdirSync in audit tool#3788

Merged
AceHack merged 2 commits into
mainfrom
feat/b0557-slice-error-handling-otto-cli-2026-05-16
May 16, 2026
Merged

feat(B-0557 slice 2): try/catch readFileSync + readdirSync in audit tool#3788
AceHack merged 2 commits into
mainfrom
feat/b0557-slice-error-handling-otto-cli-2026-05-16

Conversation

@AceHack
Copy link
Copy Markdown
Member

@AceHack AceHack commented May 16, 2026

Summary

  • Addresses Copilot P1 finding from PR feat(B-0553): audit-backlog-status-drift tool + 16 tests (incl. 2nd FP class) #3758: enumerateOpenRows() could throw and abort the whole audit on a single unreadable backlog file (permission denied, transient FS error, etc.).
  • Fix: wrap both readdirSync and readFileSync in try/catch; warn to stderr; continue with remaining files.
  • Bundles peer Otto-Desktop's tick shard 10fb6e5 (brief-ack extreme cost-aware tier substrate).

Test plan

  • bun test tools/hygiene/audit-backlog-status-drift.test.ts → 16 pass / 0 fail / 28 expect calls (no regression)
  • bun tools/hygiene/audit-backlog-status-drift.ts --json still produces 33+ candidates from main
  • Stderr warnings clearly name the failed file(s) when triggered

Composes with

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 16, 2026 06:49
@AceHack AceHack enabled auto-merge (squash) May 16, 2026 06:49
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves the resilience of the audit-backlog-status-drift hygiene tool by preventing filesystem read errors from aborting the entire audit run, and adds a new hygiene-history tick shard documenting related operational context.

Changes:

  • Wraps readdirSync and readFileSync in try/catch inside enumerateOpenRows() to warn-and-continue on unreadable directories/files.
  • Emits stderr warnings with the directory/file path and error message when reads fail.
  • Adds a new docs/hygiene-history/ticks/... shard documenting the session tick.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tools/hygiene/audit-backlog-status-drift.ts Adds defensive error handling around directory and file reads to avoid aborting audits on a single unreadable entry.
docs/hygiene-history/ticks/2026/05/16/0644Z.md Adds a new tick shard entry documenting the session state and related PR context.
Comments suppressed due to low confidence (1)

tools/hygiene/audit-backlog-status-drift.ts:212

  • Same issue as above: casting err as Error risks losing information for non-Error throws. Use err instanceof Error ? err.message : String(err) for consistent, safe stderr output.
                process.stderr.write(
                    `audit-backlog-status-drift: unable to read ${path}: ${(err as Error).message}\n`,
                );

Comment thread tools/hygiene/audit-backlog-status-drift.ts
Comment thread docs/hygiene-history/ticks/2026/05/16/0644Z.md
Copy link
Copy Markdown
Member Author

@AceHack AceHack left a comment

Choose a reason for hiding this comment

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

Lior Antigravity Check: Clean slice, good error boundaries. No blob detected.

AceHack added a commit that referenced this pull request May 16, 2026
…ipe-row

Two valid Copilot findings on PR #3788:

1. (err as Error).message is unsafe TS — catch variable is unknown.
   Replaced with: (err instanceof Error ? err.message : String(err))
   at both locations (readdirSync + readFileSync error handlers).

2. docs/hygiene-history/ticks/2026/05/16/0644Z.md missed the documented
   schema (first non-empty line must be a pipe-row per ticks/README.md).
   Added the pipe-row prefix; preserved heading + body below.

Co-Authored-By: Claude <noreply@anthropic.com>
AceHack and others added 2 commits May 16, 2026 03:13
…ort on one bad file

Per Copilot P1 on PR #3758: enumerateOpenRows() previously could
throw and abort the whole audit on a single unreadable backlog file
(permission denied, transient FS error, etc.). Fix: wrap both
readdirSync and readFileSync in try/catch; warn to stderr; continue
with remaining files.

Audit completes; operator sees partial-result warnings naming the
failed files.

Smoke test: existing live run still produces 33+ candidates (no
regression). Existing 16 tests pass unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
…ipe-row

Two valid Copilot findings on PR #3788:

1. (err as Error).message is unsafe TS — catch variable is unknown.
   Replaced with: (err instanceof Error ? err.message : String(err))
   at both locations (readdirSync + readFileSync error handlers).

2. docs/hygiene-history/ticks/2026/05/16/0644Z.md missed the documented
   schema (first non-empty line must be a pipe-row per ticks/README.md).
   Added the pipe-row prefix; preserved heading + body below.

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 16, 2026 07:15
@AceHack AceHack force-pushed the feat/b0557-slice-error-handling-otto-cli-2026-05-16 branch from bbb9462 to 3404f88 Compare May 16, 2026 07:15
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@AceHack AceHack merged commit 6809f6e into main May 16, 2026
32 of 33 checks passed
@AceHack AceHack deleted the feat/b0557-slice-error-handling-otto-cli-2026-05-16 branch May 16, 2026 07:18
AceHack added a commit that referenced this pull request May 16, 2026
…git compatibility + sub-case 5 (#3818)

* chore(b-0557): add Resolution section mapping 4 slices to merge commits

Follow-up to the status-flip commit (034afe2). Adds explicit
provenance trail:
- Slice 1 (--check): PR #3783 / 0a57a81
- Slice 2 (try/catch): PR #3788 / 6809f6e
- Slice 3 (chdir + tests): PR #3790 / 472024d
- Slice 4 (mixed-bullet + tsc): PR #3809 / eb04e3d

Test count 16 → 20 across the 4 slices. All passing on main.

Co-Authored-By: Claude <noreply@anthropic.com>

* rule(holding-discipline): cascade-saturation empirical anchor + pure-git tier compatibility + sub-case 5

Three targeted edits to .claude/rules/holding-without-named-dependency-is-standing-by-failure.md based on this session's empirical evidence:

1. Concrete-artifact definition expanded to cover pure-git tier (branch-pushed-no-PR counts for counter reset)

2. New "Cascade-saturation empirical anchor (2026-05-16)" sub-section documenting the rule operating correctly through 4 distinct cycles of cascade saturation. Validates 5 properties of the counter discipline including multi-cycle non-accumulation across named-dep-reset cycles.

3. NEW sub-case 5 discovered DURING authoring: peer-side destructive git operations (reset --hard, stash + checkout, etc.) discard unstaged tracked-modifications. The borrow-on-existing pattern's "modifications follow me" assumption fails here. Mitigation: commit immediately after Edit; don't rely on unstaged edits surviving multi-Bash-call sequences during peer saturation.

This commit IS the meta-fallback firing — substrate that documents the cascade by being the cascade's terminal artifact. Recursively self-validating. Sub-case 5 was discovered BECAUSE the first authoring attempt of this very commit was destroyed by peer Otto's destructive git operation; the re-application is the empirical proof.

Composes with refresh-world-model-poll-pr-gate.md (rate tiers) and claim-acquire-before-worktree-work.md (saturation-ceiling sub-cases — sub-case 5 is a new finding to land there in a follow-up).

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
AceHack added a commit that referenced this pull request May 16, 2026
…re-eats-itself) (#3819)

* chore(b-0557): add Resolution section mapping 4 slices to merge commits

Follow-up to the status-flip commit (034afe2). Adds explicit
provenance trail:
- Slice 1 (--check): PR #3783 / 0a57a81
- Slice 2 (try/catch): PR #3788 / 6809f6e
- Slice 3 (chdir + tests): PR #3790 / 472024d
- Slice 4 (mixed-bullet + tsc): PR #3809 / eb04e3d

Test count 16 → 20 across the 4 slices. All passing on main.

Co-Authored-By: Claude <noreply@anthropic.com>

* chore(b-0557): status: open → closed + BACKLOG.md regen (recovery from force-push)

Recovers the status flip that was lost when 4c71679's force-push
overwrote 034afe2. The Resolution section landed in 4c71679; this
commit lands the status: closed + closed: 2026-05-16 frontmatter
fields + BACKLOG.md `[ ]` → `[x]` regen.

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
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.

2 participants