Skip to content

fix: merged-PR push check + worklog revamp#12

Merged
George-iam merged 2 commits intomainfrom
feat/safety-merged-pr-fix-20260406
Apr 6, 2026
Merged

fix: merged-PR push check + worklog revamp#12
George-iam merged 2 commits intomainfrom
feat/safety-merged-pr-fix-20260406

Conversation

@George-iam
Copy link
Copy Markdown
Contributor

Summary

Two changes:

1. Fix: merged-PR push check was silently failing (ESM require bug)

checkGit had a merged-PR check that used require("node:child_process") inside the function body. Since safety.ts is ESM, require is undefined - the catch {} silently swallowed the ReferenceError and the check never ran.

Additionally, the check relied on git branch --show-current which fails when CWD is a workspace root (not a git repo).

Fixes:

  • Replaced require() with top-level ESM imports
  • Parse branch name directly from push command (git push origin <branch>) as primary source
  • Fall back to git branch --show-current with workspace subdirectory scan

Verified live: git push origin feat/narrative-worklog-20260406 (has merged PR#10) now correctly returns BLOCKED.

2. Worklog.jsonl revamp - actionable events

Replaced low-value events with actionable ones:

  • safety_block: logged in pre-tool-use when a tool call is denied
  • audit_complete: logged with cost and extraction counts
  • decision_saved/decision_superseded: logged when decisions are created or replaced
  • session_end: trimmed to filesCount instead of full filesChanged array dump

New CLI: axme-code stats [path] - sessions, audit cost, safety blocks, errors.

Test plan

  • Live test: push to merged branch BLOCKED
  • 14/14 checkGit regression (updated for merged-PR awareness)
  • 12/12 prefix boundary tests
  • 13/13 full regression suite
  • axme-code stats works on real workspace
  • Build clean

The checkGit merged-PR check used require("node:child_process") inside
the function body, but safety.ts is ESM. require is undefined in ESM,
causing ReferenceError caught by catch {} - the check silently passed.

Two fixes:
1. Replaced require() with top-level ESM imports (execSync, existsSync,
   readdirSync, dirname)
2. Parse branch name from the push command itself (git push origin <branch>)
   instead of only relying on git branch --show-current which fails
   when CWD is a workspace root (not a git repo)
Replaced low-value events with actionable ones:
- safety_block: logged in pre-tool-use when a tool call is denied (audit trail)
- audit_complete: logged with cost, memories/decisions/safety counts
- decision_saved/superseded: logged when decisions are created or replaced
- session_end: trimmed to filesCount instead of full filesChanged array

Removed dead event types: agent_turn, check_result.

New CLI command: axme-code stats [path]
Shows total sessions, audit cost, safety blocks, recent errors.

New worklogStats() function for programmatic access.
@George-iam George-iam merged commit af925e3 into main Apr 6, 2026
@George-iam George-iam deleted the feat/safety-merged-pr-fix-20260406 branch April 7, 2026 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant