Fix the os-sdlc PostToolUse:Agent hook: bind the database before the Implementation constant loads #1754

Open
opened 2026-11-13 20:10:41 +00:00 by jared · 0 comments
Owner

Problem

The os-sdlc PostToolUse:Agent hook raises on each async agent launch in a project with a pipeline database. The transcript gets a hook_non_blocking_error record, and the next instruction that the hook must inject is lost.

Observed

Counts from the transcripts under ~/.claude/projects on 2026-11-13: 553 hook_non_blocking_error records dated 2026-11-11 to 2026-11-13.

514 of them have the hook PostToolUse:Agent, all dated 2026-11-11 to 2026-11-13:

sequel/model/base.rb:357:in 'Sequel::Model::ClassMethods#db': No database associated with Sequel::Model: have you called Sequel.connect or Sequel::Model.db= ? (Sequel::Error)
	from /home/jared/dev/cc-os/plugins/os-sdlc/lib/os_sdlc/implementation.rb:4:in '<module:OsSdlc>'
	from /home/jared/dev/cc-os/plugins/os-sdlc/lib/os_sdlc/implementation.rb:3:in '<top (required)>'
	from /home/jared/dev/cc-os/plugins/os-sdlc/lib/os_sdlc/hook.rb:33:in 'OsSdlc::Hook#post_tool_use'
	from /home/jared/dev/cc-os/plugins/os-sdlc/lib/os_sdlc/hook.rb:9:in 'OsSdlc::Hook.post_tool_use'
	from /home/jared/.claude/plugins/os-sdlc/hooks/post_tool_use.rb:6:in '<main>'

plugins/os-sdlc/lib/os_sdlc/hook.rb:33 is:

envelope("PostToolUse", Implementation::NextInstruction.after_launch(connect(root), event))

Ruby resolves the receiver Implementation::NextInstruction before it evaluates the argument connect(root). The constant lookup loads implementation.rb, where class Implementation < Sequel::Model needs a database. connect(root) is the call that binds the database, and it has not run yet. The other two hook entries use in_project, which calls connect(root) first. Commit 031244657 (2026-11-10, #1646) wrote line 33 in this form.

Reproduce

Launch one background Agent in a session whose project has .sdlc/pipeline.db. The transcript gets the error above.

Approach

Hook#post_tool_use binds the database before it names an Implementation constant, as in_project does.

Required work: none beyond the acceptance criteria.

Acceptance criteria

  1. Given a project with .sdlc/pipeline.db, when the PostToolUse hook runs for an async Agent launch, then it exits 0 and prints the next-instruction envelope.
  2. Given one day of sessions after the fix, when a person counts hook_non_blocking_error records with the text No database associated with Sequel::Model from hook.rb:33, then the count is 0.

Non-goals

The trim-status-table hook path. A separate ticket of 2026-11-13 covers it.

Origin

  • Trigger: the os-me check of 2026-11-13 in session 2bb44e9c. Jared asked how the os-me outcome function works and said "We definitely need to get this back on track. /os-me:predict desired outcome, how to get there, then do it!" The applied Prediction (docs/decisions/rulings.tsv row 161) sends this work to a ticket.
  • Improvised this session: none
  • Chain: PostToolUse:Agent fails ← hook.rb:33 loads a Sequel model before connect(root) binds the database ← commit 031244657 (#1646) wrote the call in that order ← DESIGN (plugins/os-sdlc/lib/os_sdlc/hook.rb)
  • Root candidate: none found; searched "No database associated with Sequel::Model", post_tool_use, hook.rb, after_launch, NextInstruction, trim-status-table, CLAUDE_PROJECT_DIR, hook_non_blocking_error, PostToolUse:Agent, 1646
  • Where: plugins/os-sdlc/lib/os_sdlc/hook.rb:33 (OsSdlc::Hook#post_tool_use)
  • Session: 2bb44e9c-522c-4c97-8449-bd46bed898e0
  • Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os/2bb44e9c-522c-4c97-8449-bd46bed898e0.jsonl

VERDICT: CREATE (ticket-skeptic, 2026-11-13): observed recurring failure, 514 records; the skeptic split the draft into two tickets by mechanism.

## Problem The os-sdlc `PostToolUse:Agent` hook raises on each async agent launch in a project with a pipeline database. The transcript gets a `hook_non_blocking_error` record, and the next instruction that the hook must inject is lost. ## Observed Counts from the transcripts under `~/.claude/projects` on 2026-11-13: 553 `hook_non_blocking_error` records dated 2026-11-11 to 2026-11-13. 514 of them have the hook `PostToolUse:Agent`, all dated 2026-11-11 to 2026-11-13: ``` sequel/model/base.rb:357:in 'Sequel::Model::ClassMethods#db': No database associated with Sequel::Model: have you called Sequel.connect or Sequel::Model.db= ? (Sequel::Error) from /home/jared/dev/cc-os/plugins/os-sdlc/lib/os_sdlc/implementation.rb:4:in '<module:OsSdlc>' from /home/jared/dev/cc-os/plugins/os-sdlc/lib/os_sdlc/implementation.rb:3:in '<top (required)>' from /home/jared/dev/cc-os/plugins/os-sdlc/lib/os_sdlc/hook.rb:33:in 'OsSdlc::Hook#post_tool_use' from /home/jared/dev/cc-os/plugins/os-sdlc/lib/os_sdlc/hook.rb:9:in 'OsSdlc::Hook.post_tool_use' from /home/jared/.claude/plugins/os-sdlc/hooks/post_tool_use.rb:6:in '<main>' ``` `plugins/os-sdlc/lib/os_sdlc/hook.rb:33` is: ```ruby envelope("PostToolUse", Implementation::NextInstruction.after_launch(connect(root), event)) ``` Ruby resolves the receiver `Implementation::NextInstruction` before it evaluates the argument `connect(root)`. The constant lookup loads `implementation.rb`, where `class Implementation < Sequel::Model` needs a database. `connect(root)` is the call that binds the database, and it has not run yet. The other two hook entries use `in_project`, which calls `connect(root)` first. Commit 031244657 (2026-11-10, #1646) wrote line 33 in this form. ## Reproduce Launch one background Agent in a session whose project has `.sdlc/pipeline.db`. The transcript gets the error above. ## Approach `Hook#post_tool_use` binds the database before it names an `Implementation` constant, as `in_project` does. Required work: none beyond the acceptance criteria. ## Acceptance criteria 1. Given a project with `.sdlc/pipeline.db`, when the `PostToolUse` hook runs for an async Agent launch, then it exits 0 and prints the next-instruction envelope. 2. Given one day of sessions after the fix, when a person counts `hook_non_blocking_error` records with the text `No database associated with Sequel::Model` from `hook.rb:33`, then the count is 0. ## Non-goals The trim-status-table hook path. A separate ticket of 2026-11-13 covers it. ## Origin - Trigger: the os-me check of 2026-11-13 in session 2bb44e9c. Jared asked how the os-me outcome function works and said "We definitely need to get this back on track. /os-me:predict desired outcome, how to get there, then do it!" The applied Prediction (docs/decisions/rulings.tsv row 161) sends this work to a ticket. - Improvised this session: none - Chain: PostToolUse:Agent fails ← hook.rb:33 loads a Sequel model before connect(root) binds the database ← commit 031244657 (#1646) wrote the call in that order ← DESIGN (plugins/os-sdlc/lib/os_sdlc/hook.rb) - Root candidate: none found; searched "No database associated with Sequel::Model", post_tool_use, hook.rb, after_launch, NextInstruction, trim-status-table, CLAUDE_PROJECT_DIR, hook_non_blocking_error, PostToolUse:Agent, 1646 - Where: plugins/os-sdlc/lib/os_sdlc/hook.rb:33 (OsSdlc::Hook#post_tool_use) - Session: 2bb44e9c-522c-4c97-8449-bd46bed898e0 - Transcript: /home/jared/.claude/projects/-home-jared-dev-cc-os/2bb44e9c-522c-4c97-8449-bd46bed898e0.jsonl VERDICT: CREATE (ticket-skeptic, 2026-11-13): observed recurring failure, 514 records; the skeptic split the draft into two tickets by mechanism.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jared/cc-os#1754
No description provided.