Repository navigation
fix(mcp): place Railway log records by their own time in the first-load timeline - #11
Conversation
…ad timeline `railway logs --deployment --json` lifts each JSON record's fields to the top level and adds `timestamp`, when Railway collected the line in batches. The timeline took that branch and replaced the record's own `at` with Railway's `timestamp`, so records were reordered and some fell outside the trial window they belonged to. On the 30 October evidence, 65 of 98 records were off by more than 50 ms, and up to 13.2 s. No per-trial finding changes. The record's own `at` now wins; `timestamp` remains the fallback for lines without one. A test drives the script with Railway-shaped lines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
yia-mw-agent
left a comment
There was a problem hiding this comment.
Helmet-Review-Request: #11 (comment)
Reviewed the full merge-base-to-head diff (base develop 9d9c2ad = merge-base, 2 files) at 78bb0cc. The live head matched at start and before submitting.
No material defects.
apps/mcp/scripts/first-load-timeline.mjs: theraw.eventbranch now keeps a numeric top-levelatand falls back to Railway'stimestamponly whenatis absent. Themessage-wrapped and edge-log paths are unchanged. This matches the stated cause.apps/mcp/test/first-load-timeline.test.ts: the three cases cover the reordering fix, the fallback and the wrapped-message path. The assertions are specific.
Validation: node --test test/first-load-timeline.test.ts passed 3 of 3. I also ran the pre-fix script (from develop) and the PR script on a Railway-shaped fixture. The old script reported "no card read was observed". The new one placed tools/list at +1.00s and resources/read at +9.50s. I could not run the repo-wide lint and typecheck: dependencies are not installed in this worktree and pnpm is unavailable. CI was still pending when I submitted.
Non-blocking: the at check is typeof === 'number', so an at that arrives as a string would silently fall back to the batch timestamp. The application writes Date.now(), so this is not a concern today.
Fixes the ordering bug in
apps/mcp/scripts/first-load-timeline.mjs, the tool that joins first-load trials with server logs for iaser-ai#335.What was wrong
railway logs --deployment --jsonlifts each JSON record's fields to the top level and adds its owntimestamp. That is when Railway collected the line, and it collects in batches. The script saweventat the top level and overwrote the record's ownatwith Railway'stimestamp. As a result, records were reordered, and some fell outside the trial window they belonged to.Change
at, the script uses it.timestampis now only the fallback, for lines without their own time (for exampleStarting Container).messagealready kept their own time; that is unchanged.Verification
test/first-load-timeline.test.tsruns the script on Railway-shaped lines:timestamp.messagekeeps its own time.server/discoveris at +0.73 s, not +9.96 s.pnpm mcp verifypassed: 157 tests and 78 browser checks.🤖 Generated with Claude Code