Skip to content

fix(office-hours): session writer was writing to legacy file#1676

Open
pryow wants to merge 2 commits into
garrytan:mainfrom
pryow:fix-1671-profile-migration
Open

fix(office-hours): session writer was writing to legacy file#1676
pryow wants to merge 2 commits into
garrytan:mainfrom
pryow:fix-1671-profile-migration

Conversation

@pryow
Copy link
Copy Markdown

@pryow pryow commented May 24, 2026

Fixes #1677.

What users get

Returning /office-hours users now hit the welcome_back tier on their second visit instead of being pitched as first-timers every time. Live on every fresh-$HOME user since v1.0.0.0 (~5 weeks).

Root cause

v1.0.0.0 moved the read path to ~/.gstack/developer-profile.json but left the writer in office-hours/SKILL.md.tmpl echoing to the legacy ~/.gstack/builder-profile.jsonl. ensure_profile creates a stub with sessions: []; subsequent writes went to a file the reader never re-reads. Reader and writer disagreed on storage. SESSION_COUNT stayed at 0 forever, welcome_back (which exists specifically to skip the closing pitch for returning users) was unreachable on fresh-$HOME installs.

Fix

  1. New bin/gstack-developer-profile --log-session '<json>' — read-modify-writes developer-profile.json's sessions[]. Atomic mktemp+mv. Silent skip on invalid JSON (matches gstack-timeline-log:22-26). Aggregates signals_accumulated, resources_shown, topics. Calls gstack-brain-enqueue after write, mirroring gstack-timeline-log:40. Verb joins the gstack-*-log family.
  2. Swap office-hours/SKILL.md.tmpl writer calls at lines 490 + 893 to use the new subcommand. Regenerate office-hours/SKILL.md.
  3. Fix latent do_read bug: filter mode:"resources" entries when picking LAST_PROJECT / LAST_ASSIGNMENT / LAST_DESIGN_TITLE / CROSS_PROJECT. Phase 6 resources auto-append runs after the real session in the same invocation; without the filter, it clobbers real-session state next visit. Masked by the broken writer; activated by this fix.

Affected users

Stranded entries in ~/.gstack/builder-profile.jsonl from the broken-writer period (v1.0.0.0 → v1.43.4.0) are not auto-recovered. Affected users' next /office-hours session lands fresh in welcome_back; past data stays in the legacy file (still readable by other tools during deprecation). Most pre-existing users have only a handful of stranded sessions; the loss is mostly aesthetic.

Tests

+8 behavioral tests in test/gstack-developer-profile.test.ts: regression (read-write-read promotes to welcome_back), aggregation (signals, resources_shown, topics dedup), validation (silent skip on invalid input), ts injection/preservation, do_read mode filter. +3 static-grep invariants in test/static-no-legacy-writes.test.ts (new) that prevent future writers from regressing onto the legacy file. All 62 pass in 5.17s.

What's intentionally NOT in this fix
  • No auto-reconcile for stranded entries. One-release-only reconcile code dropped per right-sized-diff voice. Loss is mostly aesthetic (see "Affected users" above).
  • No new binary. --log-session belongs on the owner of developer-profile.json, not the gstack-*-log event family. Joins --migrate / --derive as a write-side subcommand on the same binary.
  • No mkdir-locks. Concurrent /office-hours has a r-m-w race on developer-profile.json. gstack-config accepts the same race on YAML; not introduced here.
  • No schema bump. Stays at schema_version: 1.

Full rationale: docs/designs/FIX_1671_PROFILE_MIGRATION.md.

Related

#1139Voice prompt: "apply to YC" suggestion triggers too frequently across sessions. This PR unblocks proposed fix #3 (suppress-on-prior-session detection). Without correct SESSION_COUNT, that detection couldn't have worked even if implemented; YC-apply suppression itself is separate work.

🤖 Generated with Claude Code

Rook and others added 2 commits May 24, 2026 06:07
…legacy file

User-visible symptom: returning /office-hours users get the same closing
pitch every visit, no matter how many times they've run the skill. The
welcome_back tier (which exists specifically to skip the pitch for
returning users) was unreachable. Live since 2026-04-18 / v1.0.0.0 on
every fresh-$HOME user.

Root cause: the v1.0.0.0 migration moved the read path to
~/.gstack/developer-profile.json but left the writer in
office-hours/SKILL.md.tmpl writing to the legacy
~/.gstack/builder-profile.jsonl. Reader and writer disagreed on storage,
so SESSION_COUNT never incremented and /office-hours always treated the
user as a first-timer.

Fix:
- bin/gstack-developer-profile: new --log-session subcommand that
  read-modify-writes developer-profile.json's sessions[] array (atomic
  mktemp+mv, signals/resources/topics aggregation, gbrain-enqueue mirror
  of gstack-timeline-log:40). Naming matches the gstack-*-log family verb.
- bin/gstack-developer-profile: do_read filters mode:"resources" entries
  when picking LAST_PROJECT/LAST_ASSIGNMENT/LAST_DESIGN_TITLE so the Phase
  6 resources auto-append doesn't clobber real-session state. Latent bug
  that was masked by the broken writer; activated by the fix.
- office-hours/SKILL.md.tmpl: lines 490 + 893 swap echo >> for --log-session.
- test/gstack-developer-profile.test.ts: +8 tests covering --log-session
  contract (regression, aggregation, dedup, validation, ts handling) plus
  the mode-filter regression. All 8 fail on main, all 8 pass with this fix.
- test/static-no-legacy-writes.test.ts: new static-grep invariant walking
  every skill dir to prevent future regressions onto the legacy file.

Affected users: stranded builder-profile.jsonl entries are not recovered
automatically by this PR. On their next /office-hours run, the first new
session lands in welcome_back; past data stays in the legacy file (still
readable by other tools during deprecation). Most pre-existing users have
only a handful of stranded sessions.

See docs/designs/FIX_1671_PROFILE_MIGRATION.md for scope decisions
(RC2/RC3 follow-ups, what was intentionally left out, and why).

Issue: garrytan#1671
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@pryow pryow changed the title fix(office-hours): #1671 — session writer was writing to legacy file fix(office-hours): session writer was writing to legacy file May 24, 2026
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