fix: /context-save session_duration_s empty on Linux (GNU date -jf) - #2704
Open
exGeni wants to merge 1 commit into
Open
fix: /context-save session_duration_s empty on Linux (GNU date -jf)#2704exGeni wants to merge 1 commit into
exGeni wants to merge 1 commit into
Conversation
The Step 3 duration fallback shelled out to `ps -o lstart= -p $PPID | date -jf "%c" ...`. `-j`/`-f` are BSD/macOS-only date flags; GNU date on Linux rejects them outright, so START_EPOCH silently ends up empty and session_duration_s is omitted from every checkpoint frontmatter on Linux. Even fixed, `ps -o lstart=` is locale-dependent (non-English month/day names break any date parser downstream). Also: the fallback was measuring the wrong thing regardless of platform — `ps -o lstart -p $PPID` reports how long the *parent* (host) process has been alive, not how long this specific /context-save invocation has been running. Fix: reuse the existing `~/.gstack/sessions/"$PPID"` session-marker file (already touched by every skill's preamble) as the start-time source, reading its mtime portably (`date -r` on Linux, `stat -f %m` on Darwin) instead of parsing `ps` output at all. Drops the ps/date-flag/locale problem entirely rather than patching around it. Live evidence (this machine, GNU/uutils coreutils 0.8.0): $ date -jf "%c" "Thu Aug 27 03:56:58 2026" "+%s" error: unexpected argument '-j' found # confirms the Linux failure $ date -r ~/.gstack/sessions/"$PPID" +%s 1787842375 # new path works, real marker file Verified: bun run gen:skill-docs --host all clean, bun run skill:check freshness clean (context-save/SKILL.md now in sync with the .tmpl for the first time - a prior hand-patch had been applied directly to the generated file and would have been silently destroyed by the next regen). The skill:check "claude/SKILL.md missing" line and the 53 test failures in test/gstack-repo-mode.test.ts and friends are pre-existing on a clean origin/main checkout (verified via git stash), unrelated to this change.
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implementation: Claude Code (Sonnet 5). Independent technical review: Codex — findings from both the plan review and the diff review are folded into this PR (see Live evidence).
Why (in your own words)
/context-save's session_duration_s is always empty on Linux — GNU/uutils date
rejects the BSD-only
date -jf "%c"flags used in the Step 3 durationfallback, so START_EPOCH silently ends up empty on every Linux user's
machine. Separately, the fallback measured the wrong thing on any platform:
ps -o lstart -p $PPIDreports how long the parent process has beenalive, not how long this specific /context-save invocation ran.
Live evidence
Before (the actual failure, this machine, GNU/uutils coreutils 0.8.0):
After (the fix's actual mechanism — read the existing session-marker file's
mtime instead of parsing
psoutput at all):End-to-end: ran the actual (unmodified) Step 3 bash from context-save/SKILL.md
as its own subprocess, separate from its preamble:
(Step 3's code doesn't reference anything from the sibling telemetry fix in
the other PR — this number comes entirely from this PR's own diff. It was
captured on a local-only branch that also had the other PR's commits merged
in for realistic end-to-end testing; the isolation just described is why
that's safe to cite here.)
Scope
regenerated context-save/SKILL.md
machine
available) — the existing BSD
date -jfpath is preserved byte-for-byte,only defensively prefixed with
LC_TIME=Cin case macOSps/strptimeare locale-sensitive the same way Linux's are; would appreciate a
maintainer/community check on real hardware
Liveness proof (required)
Checklist
GSTACK PRtyped live into a real surface