Skip to content

fix: doctor.sh SessionEnd ordering, install baseline, and --json (#404, #401, #408) - #415

Merged
fdaviddpt merged 2 commits into
mainfrom
fix/404
Aug 28, 2026
Merged

fdaviddpt merged 2 commits into
mainfrom
fix/404

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Summary

Three issues bundled into one lane because they all touch scripts/doctor.sh:

A self-review round (Explore + oss:auditor, run independently against the first commit) both found the same real gap: the new --json mode's _json_escape() handled backslash, quote and newline but not other C0 control bytes (a raw tab or CR), which produces invalid JSON per RFC 8259 for a path containing one. Fixed in a follow-up commit with its own red-then-green test, since it was small, same file, same subsystem, and the mechanism was fully understood.

Test plan

  • tests/test_doctor_verdict_ordering_404.py -- new, red before the ladder reorder, green after; includes the positive control (SessionEnd still reachable with no PostToolUse arm at all).
  • tests/test_doctor_session_end_survives_backup_cleanup_401.py -- new, red before the marker swap, green after; includes the positive control (still WARNs, doesn't manufacture a FAIL, when nothing has ended).
  • tests/test_doctor_json_408.py -- new, four cases: resolved, resolved_assumed_project_dir, could_not_resolve (never carries remember_dir), and the control-byte escaping fix.
  • Existing doctor/migration/git-backup/case-divergence suites (test_doctor.py, test_doctor_session_end_370.py, test_doctor_verdict_ordering_359.py, test_migration.py, test_home_dir_migration.py, test_git_backup_hook.py, test_git_backup_silent_stops_257.py, test_git_backup_push_rejected_253.py, test_case_divergence_298.py) all green against the final diff.
  • python3 .oss/assemble_changelog.py --check -- clean, three fragments (404.fixed.md, 401.fixed.md, 408.added.md) plus the pre-existing 407.fixed.md.
  • A pre-existing, unrelated flake in tests/test_slug_index_297.py::test_concurrent_session_starts_do_not_lose_a_row reproduces on unmodified main too (2/5 failures with this branch's changes stashed) -- not a regression from this diff.

fdaviddpt and others added 2 commits August 28, 2026 23:45
…dable output (#404, #401, #408)

- #404: the VERDICT ladder could still name "SessionEnd has never fired"
  over a more specific PostToolUse-exiting-early cause already printed
  above it, on an aged store. Moved the arm below both PostToolUse arms
  that name a cause, leaving its priority over "capture is working" and
  "PostToolUse never fired at all" unchanged.
- #401: a legacy store migrated to external mode with git backup enabled
  could never reach the SessionEnd FAIL verdict again, because
  50-git-backup.sh deletes the .gitignore file doctor.sh read as its
  install baseline. bootstrap-dirs.sh now writes a dedicated
  .install-marker instead, unconditional of storage mode, that nothing
  else has any reason to touch.
- #408: added `doctor.sh --json`, a provisional machine-readable
  resolution surface (resolved directory + storage mode) for external
  callers that would otherwise have to reimplement session_dir_slug.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Self-review (Explore + oss:auditor, both independently) found that
_json_escape() handled backslash, double-quote and newline but passed
every other control byte (a raw tab, a carriage return) through
unescaped -- invalid inside a JSON string literal per RFC 8259, and
POSIX filesystems permit both in a real path. `tr '[:cntrl:]' ' '`
replaces the earlier `tr '\n' ' '`, flattening the whole class the same
lossy-but-valid way the newline case already was, rather than only the
one byte that had a test.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@fdaviddpt
fdaviddpt merged commit 5f99d81 into main Aug 28, 2026
13 checks passed
@fdaviddpt
fdaviddpt deleted the fix/404 branch August 28, 2026 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant