myxce/.wolf/bugs/bug-1602.md
Rongsong Shen d26ff8870d
feat(buglog): one Markdown record per bug, checked against a record standard
The buglog was one 27K-line JSON file whose fields covered only symptom,
root cause and fix, as free text: 2% of entries named the code version a
bug was found on, 12% the build profile, 36% a way to reproduce, and 58% of
the file was OpenWolf hook auto-detections ("Missing guard clause",
"Function not marked async" on .md files).

- .claude/skills/buglog/bug-record.md: the record standard. Eight
  sections (Summary as the title, Description, Environment, Reproduction;
  Root cause, Fix, Verification, References once fixed), each with the
  content it must contain -- e.g. Environment needs the OS, the libc the
  failing binary loads (from its ELF interpreter: glibc 2.42 in the nix
  shell vs 2.40 on the host), toolchain, build profile and commit.
- .wolf/bugs/<id>.md: 500 records migrated from buglog.json; every field
  verified to round-trip. They carry legacy: true and an explicit "not
  recorded" where the old log had no such field; component derived from
  file paths, severity from keywords (else unknown), fix_commits from
  hashes in status_note/fix that git resolves (91 of 463 fixed).
- .wolf/buglog-archive.json: the 710 hook auto-detections, verbatim.
- .wolf/buglog.json is now an index generated from the records, keeping
  the fields OpenWolf's hooks and `openwolf bug search` read.
- scripts/buglog.py rewritten: new (template + Environment collected from
  the machine and --binary), check, status (refuses a status the record
  doesn't support; fixed needs Root cause, Fix, Verification and
  --commit hashes git resolves), note, recur, set, show, list, triage,
  env, index. 29 unittest cases in scripts/tests/test_buglog.py.
- scripts/git-hooks/pre-commit runs `check --staged`: incomplete staged
  records, a legacy record hand-changed to fixed without the fix-time
  sections, a new record claiming legacy: true, or a stale index refuse
  the commit.
- scripts/gitea-sync.py reads the records: issue body = the record's
  sections plus linked fix commits (origin remote, GITEA_COMMIT_REPO to
  override), and a body hash so an issue's text is refreshed when the
  record changes.
- bug-1866 rewritten to the full standard as the worked example.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 03:40:11 +00:00

42 lines
3.3 KiB
Markdown

---
id: "bug-1602"
status: "fixed"
status_updated: "2026-09-24"
status_note: ""
component: "scheduler"
severity: "unknown"
timestamp: "2026-08-20T08:30:00Z"
last_seen: "2026-09-19T09:00:00Z"
occurrences: 1
files: ["src/scheduler/src/repl_break.c", "src/scheduler/src/sim.c"]
tags: ["scheduler", "repl", "sim", "replay", "session", "feature", "observability"]
related: ["bug-1595"]
legacy: true
---
# bug-1602: User request: scheduler simulation mode should show event time and session when events occur, and…
## Description
User request: scheduler simulation mode should show event time and session when events occur, and loading a replay file should show its total session count up front.
## Environment
_Not recorded (migrated from buglog.json)._
## Reproduction
_Not recorded (migrated from buglog.json)._
## Root cause
Feature gap, not a defect: repl_print_event_summary() (interactive REPL event echo) printed only the event type/payload, no clock time or session number; sched_sim_driver_start() never reported how many sessions a loaded .replay file contains before stepping through it.
## Fix
repl_print_event_summary() now prefixes each echoed event with "[sim] t=<ns> (<human>) session=<N>". Non-obvious correctness point found via sim_loop.c inspection (not assumption): events are read+echoed individually AS THEY STREAM from the file, and the ReplaySession/begin_round message for that batch -- which is what increments rs->session_count via xce_repl_on_begin_round() -- comes AFTER those events in file order (file layout is event,event,...,ReplaySession). So every echoed event always belongs to the UPCOMING session; the function reports session_count+1, not the raw count. A first attempt using the raw count failed its own new test (session=0 instead of session=1) and was corrected after tracing the real sim_loop.c call order (xce_repl_check_event at line ~593 vs xce_repl_check_begin_round at ~631) rather than trusting the repl.h doc comment's summary.
Added sim_prescan_session_count() (sim.c): scans sim->replay_file from the current position using msg_root_has_shape() shape-only classification (ReplayEvent/ReplaySession/SnapshotEntry, matching sim_loop.c main loop's own three-way dispatch) to count ReplaySession messages, then rewinds via fseek back to the captured ftell() position -- mirrors sim_locate_and_load_snapshot()'s own established rewind pattern. Confirmed safe via research: capn_init_fp() in this codebase is always unpacked (packed=0), reading via a single plain fread() per message with no internal read-ahead buffer, so ftell/fseek stay exactly in sync with message boundaries. Wired into sched_sim_driver_start() right after sim_set_virtual_clock(): prints "[sim] replay file contains N sessions" once at load, non-fatal on scan failure. User explicitly chose this pre-scan approach over a recording-time trailer message (would have required a schema change and only worked for newly-recorded files) via AskUserQuestion.
Added test_replay_load_reports_total_session_count (2-session fixture) and extended test_step_echoes_events_before_session_decisions with t=/session=1 assertions in test_repl_breakpoints_inspection.c. Full scheduler suite: 42/43 Ok, only pre-existing unrelated bug-1560 remains (now 3 occurrences).
## Verification
_Not recorded (migrated from buglog.json)._
## References
- Related: bug-1595