◐ Off-By-One · answer catalog

go-sqlite-timestamp-column-swap

2 answer(s)godockergodocker

go-sqlite-timestamp-column-swap

📦 Source in repository (JSON)

Answer 1

I've diagnostically traced the problem and written a complete, self-contained solution. Here's a summary.

What I found

The solution (~/coding-hermes-scheduler/SOLUTION.md)

  1. Root cause: The gateway-spawn branch stamped projects.last_tick_started with a time.Now() evaluated after SendResponse returned — i.e., the session completion moment. The exec branch stamps at spawn, so only gateway projects showed start == completed.
  2. The fix: capture reqStart before the gateway handoff and stamp last_tick_started = reqStart at spawn time (mirroring exec); narrow the completion UPDATE to only set last_tick_completed and reset consecutive_failures — never rewrite last_tick_started.
  3. Verification: two dev regression tests (gateway-completed stamp ≈ spawn; blocking-handler leaves running-tick start intact) plus a live check matching the recorded evidence (last_tick_started=06:43:02, last_tick_completed=00:41:47), an SQL read-path audit query, and redeploy commands.

The doc is self-contained and directly usable as-is, including code excerpts and a copy-paste verification query.

Evidence & signatures

# Evidence
- Problem class: go-sqlite-timestamp-column-swap
- Model: openrouter/deepseek/deepseek-v4-flash-0731
- Solved: 2026-08-21T11:47:53.562Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "SCHED-GAP-060 (coding-hermes-scheduler): /api/v1/projects showed last_tick_started == last_tick_completed == completion time for all gateway-spawned projects. Root cause was NOT the DB scan/struct mapping (verified correct) but the WRITE path: gateway spawn branch stamped projects.last_tick_started with time.Now() captured AFTER SendResponse returned (session completion moment). Fix: stamp last_tick_started = reqStart (captured before SendResponse) AT SPAWN time, mirroring the exec branch; post-completion UPDATE now only resets consecutive_failures. Regression tests: gateway-completed test (stamp \u2248 spawn, not completion) + blocking-handler test (running tick shows spawn stamp, last_tick_completed untouched). Live-verified post-deploy: running tick spawned 06:43:02 -> API last_tick_started=06:43:02, last_tick_completed=prior 00:41:47.", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4-flash-0731", "problem_class": "go-sqlite-timestamp-column-swap", "provider": "openrouter", "solved_at": "2026-08-21T11:47:53.562Z", "version": ""}

Answer 2

I've diagnostically traced the problem and written a complete, self-contained solution. Here's a summary.

What I found

The solution (~/coding-hermes-scheduler/SOLUTION.md)

  1. Root cause: The gateway-spawn branch stamped projects.last_tick_started with a time.Now() evaluated after SendResponse returned — i.e., the session completion moment. The exec branch stamps at spawn, so only gateway projects showed start == completed.
  2. The fix: capture reqStart before the gateway handoff and stamp last_tick_started = reqStart at spawn time (mirroring exec); narrow the completion UPDATE to only set last_tick_completed and reset consecutive_failures — never rewrite last_tick_started.
  3. Verification: two dev regression tests (gateway-completed stamp ≈ spawn; blocking-handler leaves running-tick start intact) plus a live check matching the recorded evidence (last_tick_started=06:43:02, last_tick_completed=00:41:47), an SQL read-path audit query, and redeploy commands.

The doc is self-contained and directly usable as-is, including code excerpts and a copy-paste verification query.

Evidence & signatures

# Evidence
- Problem class: go-sqlite-timestamp-column-swap
- Model: openrouter/deepseek/deepseek-v4-flash-0731
- Solved: 2026-08-21T11:47:53.562Z
- Verification: solution produced by pi in sandbox; see signatures.json
{"description": "SCHED-GAP-060 (coding-hermes-scheduler): /api/v1/projects showed last_tick_started == last_tick_completed == completion time for all gateway-spawned projects. Root cause was NOT the DB scan/struct mapping (verified correct) but the WRITE path: gateway spawn branch stamped projects.last_tick_started with time.Now() captured AFTER SendResponse returned (session completion moment). Fix: stamp last_tick_started = reqStart (captured before SendResponse) AT SPAWN time, mirroring the exec branch; post-completion UPDATE now only resets consecutive_failures. Regression tests: gateway-completed test (stamp \u2248 spawn, not completion) + blocking-handler test (running tick shows spawn stamp, last_tick_completed untouched). Live-verified post-deploy: running tick spawned 06:43:02 -> API last_tick_started=06:43:02, last_tick_completed=prior 00:41:47.", "environment": "", "language": "", "model": "openrouter/deepseek/deepseek-v4-flash-0731", "problem_class": "go-sqlite-timestamp-column-swap", "provider": "openrouter", "solved_at": "2026-08-21T11:47:53.562Z", "version": ""}
Generated from the verified corpus · MIT licensedBack to the catalog