Skip to content

fix(server): accept Grok's Claude event names as well as snake_case - #283

Merged
lukemaj merged 2 commits into
mainfrom
fix/273-grok-event-names
Oct 14, 2026
Merged

lukemaj merged 2 commits into
mainfrom
fix/273-grok-event-names

Conversation

@lukemaj

@lukemaj lukemaj commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

What: Grok hook events named PreToolUse now log a pre_tool moment, and pre_tool_use still does.
Why: Grok's stdin carries both names. hook_event_name is Claude's PascalCase (PreToolUse) and hookEventName is snake_case (pre_tool_use). The grok map only listed the snake_case names and reads hook_event_name, so every live call was bad_event. The hook files on bestia, cavallo and rocky are the same PascalCase keys.
So what: The running Chromeria processes still have the old map. This does not restart them. A real Grok tool call logs pre_tool only after the next server start.

Elon record

  • Requirements and who asked: both Grok event names log a pre_tool moment, and the other names bestia already sends do too (contextmd serving: Grok hook events named PreToolUse are rejected, so bestia never serves #273, user). Rocky's snake_case path stays.
  • Deleted: reinstalling the hooks. All three ~/.grok/hooks/contextmd.json files already use the same keys, and Grok accepts those keys. A Grok upgrade: bestia, cavallo and rocky are all 1.0.52 and send the same two fields.
  • Bottleneck: the grok event map rejected the field the server reads.
  • Checked myself: one Grok stdin on bestia and one on rocky (hook_event_name SessionStart, hookEventName session_start, and the same pair on a tool call). Bestia's serving log is still bad_event for PreToolUse. Rocky's current server logged four bad_event rows from that probe. The route test denies gh pr create for both names.

Upstream pingdotgg/t3code has no ContextMD serving module. This is a fork feature.

No version bump: Chromeria package versions stay with upstream (AGENTS.md).

Proof: vp test run apps/server/src/contextmd/ContextmdRoute.test.ts — 27 passed.

Website impact: none. The change is inside the fork's serving module and does not change a public page.

Refs #273

Grok puts PreToolUse in hook_event_name and pre_tool_use in hookEventName.
The grok map only listed the snake_case names, so every live call was rejected.
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XS labels Oct 14, 2026
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 20.9 KiB 20.9 KiB 0 B (0.0%) 29.3 KiB ✅
Codex Live turn messages 2 2 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB +31 B (+0.6%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB +31 B (+2.6%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB +41 B (+0.2%) 29.3 KiB ✅
Claude Live turn messages 1 2 +1 (+100.0%) 8 ✅

Baseline: d291435 · PR result: 1115c44 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@lukemaj

lukemaj commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

review/independent-sol

What: Verdict: blocking findings, with one formatting failure and no behavioral defect found.
Why: The new regression assertion is not formatted as required, causing the CI Lint job to fail.
So what: The author should format the changed test and obtain passing CI before proceeding.

Reviewed exact head 1a1e6ee1b8dc09ea39b965c173376439376969df against base d2914354e17977f044ed5a1a89803a231ea91e6d, using the operations review method and the full gh pr diff 283 --repo toolboxmd/chromeria diff.

Blocking finding

  1. Format the new assertion so CI can pass.
    • Trigger: CI runs vp check on this candidate.
    • Location: apps/server/src/contextmd/ContextmdRoute.test.ts:618.
    • Effect: The Lint job exits 1 with error: Formatting issues found, naming this file as the only formatting failure. This prevents a clean delivery gate. CI evidence.
    • Independent confirmation: Formatting the base and head file contents through vp fmt --stdin-filepath=apps/server/src/contextmd/ContextmdRoute.test.ts, without writing files, leaves the base unchanged and changes only this head assertion to assert.strictEqual(rows.filter((row) => row.status === "bad_event").length, 0);.

Behavior and proof

The Grok-only aliases cover both PreToolUse and pre_tool_use, plus all six other requested PascalCase events, while preserving every existing snake_case mapping. Select.identify reads hook_event_name; EVENT_OUT still supplies PreToolUse to the deny reply template. Claude's map remains separate and rejects pre_tool_use, with the existing route regression retaining that check. No version bump is appropriate under the project instructions.

The author's pre-commit invocation itself is not available as a transcript, but the Test Server 2 log independently reports ContextmdRoute.test.ts (27 tests) passed, including the new Grok regression. CI used merge commit 2516912fc56a17bb674001c51ee8d87719273874; its tree 4d6b46931e54bb45cef88c372e0a213f519d07d2 exactly matches the requested head's tree. No local test suite was run, no checkout or file was changed, and no commit status was posted.

Reviewer: gpt-6.1-sol, Codex harness.

@lukemaj

lukemaj commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

review/independent-grok

Approve 1115c446b60835dc77c89a051e6e1971c75306eb. No blocking findings.

Prior blocker, cleared. Trigger: CI Lint on 1a1e6ee1. Location: apps/server/src/contextmd/ContextmdRoute.test.ts, the bad_event count assertion (it was wrapped over four lines; the pre_tool count was already one line). Effect: format check failed. 1115c446 puts that assertion on one line, and Lint on this head passed.

Behavior, checked on the whole diff. identify looks up hook_event_name in the harness map (Select.ts). The grok map now has both forms, and both PreToolUse and pre_tool_use are pre_tool. The reply still comes from EVENT_OUT, so a deny body contains PreToolUse for either input. The route test logs exactly two pre_tool rows, both ok, and no bad_event. PostToolUse, UserPromptSubmit, Stop, SessionStart, PostToolUseFailure, and PostCompact are on that map, and the same test requires every row ok. Snake_case keys are still there; the snake_case call is the second pre_tool. Claude's map is unchanged, so pre_tool_use stays an unsupported event there (Select.test.ts). Diff is those two files only, so there is no version bump.

@lukemaj

lukemaj commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

review/independent-sol

What: Approve exact head 1115c446b60835dc77c89a051e6e1971c75306eb against base d2914354e17977f044ed5a1a89803a231ea91e6d; no blocking findings remain.
Why: The prior formatting failure is fixed, and the format commit changes only whitespace in the existing assertion.
So what: This independent review is clear; the remaining merge gates and human approval still apply.

Cleared prior finding:

  • Trigger: formatting the new Grok route regression test.
  • Location: apps/server/src/contextmd/ContextmdRoute.test.ts:618.
  • Effect: the assertion is now on one line, resolving the previous CI Lint failure. Lint passed on the exact reviewed head, verified through the job's head_sha and conclusion.

Read the full PR diff and the complete 1115c446 commit patch. That commit only reformats assert.strictEqual(rows.filter((row) => row.status === "bad_event").length, 0); it introduces no behavioral change. Grok retains its snake_case names and gains the PascalCase aliases. Select.ts still derives replies from EVENT_OUT, including PreToolUse; Claude's map still excludes pre_tool_use. No version bump or unrelated changes.

Review was read-only through GitHub. No checkout, file edits, local test execution, or commit status posted.

Reviewer: gpt-6.1-sol, high reasoning effort, Codex harness.

@lukemaj
lukemaj merged commit 14d2e7e into main Oct 14, 2026
29 checks passed
@lukemaj
lukemaj deleted the fix/273-grok-event-names branch October 14, 2026 10:48
@lukemaj

lukemaj commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Agent Observer published no cost comment. sync finished, then publish --task toolboxmd/chromeria#273 --pr 283 exited 2: nothing to publish: no sessions in scope.

lukemaj added a commit that referenced this pull request Oct 14, 2026
…283)

* fix(server): accept Grok's Claude event names as well as snake_case

Grok puts PreToolUse in hook_event_name and pre_tool_use in hookEventName.
The grok map only listed the snake_case names, so every live call was rejected.

* fix(server): format the Grok event-name assertion

(cherry picked from commit 14d2e7e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant