Skip to content

feat(hooks): push contention awareness via PostToolUse additionalContext#594

Merged
NagyVikt merged 2 commits into
mainfrom
agent/claude/post-tool-use-contention-awareness-push-2026-06-12-15-43
Jun 12, 2026
Merged

feat(hooks): push contention awareness via PostToolUse additionalContext#594
NagyVikt merged 2 commits into
mainfrom
agent/claude/post-tool-use-contention-awareness-push-2026-06-12-15-43

Conversation

@NagyVikt

Copy link
Copy Markdown
Collaborator

Summary

Final phase of the approved Colony plan (awareness slice):

  • Mid-session contention was only visible at the NEXT turn's preface. The PostToolUse hook now injects a one-line [Colony] session X recently claimed <file> — coordinate via task_message… note into the agent's context the moment an edit touches a file another live session holds (Claude Code additionalContext via hookSpecificOutput).
  • Debounced once per 2 minutes per session through an awareness-push observation marker (hook processes are one-shot — the marker doubles as the audit trail; scan depth 200 so the marker can't scroll out within a turn).
  • autoClaimFromToolUse now reports live-owner blocked takeovers (CLAIM_HELD_BY_ACTIVE_OWNER/CLAIM_TAKEOVER_RECOMMENDED) in conflicts — the strongest contention signal previously vanished silently. Bash-redirect auto-claims feed the same note.
  • Hot path unchanged: zero extra I/O for uncontended edits (early return before any storage read).

Test plan

  • pnpm typecheck / pnpm lint / pnpm test (hooks 205) / pnpm build
  • bash scripts/e2e-publish.sh green (hook stdout contract touched — required by repo rule)
  • New awareness-push suite: note emission + marker, 2-min debounce + recovery, silent without conflicts, contended-edit integration, uncontended silence
  • Independent review: APPROVE (both MEDIUMs fixed: bash-path conflicts threaded, scan depth 200)

🤖 Generated with Claude Code

NagyVikt added 2 commits June 12, 2026 15:51
Mid-session contention was only visible at the next turn's preface. The
PostToolUse hook now injects a one-line [Colony] note the moment an
edit touches a file another live session holds — debounced 2 min per
session via an awareness-push observation marker (one-shot hook
processes hold no memory). autoClaimFromToolUse reports live-owner
blocked takeovers in conflicts so the strongest contention signal
reaches the note.
@NagyVikt NagyVikt merged commit 1d78c99 into main Jun 12, 2026
6 of 8 checks passed
@NagyVikt NagyVikt deleted the agent/claude/post-tool-use-contention-awareness-push-2026-06-12-15-43 branch June 12, 2026 14:01
NagyVikt added a commit that referenced this pull request Jun 12, 2026
* fix(spec): forward-slash publish result paths; deterministic archive-target collision

spec_change_path/plan_workspace_path returned OS-native separators, so
Windows callers (and the plan.test.ts contains-assertions) saw
backslash paths. archiveChange relied on renameSync failing onto an
existing target — POSIX throws, Windows MoveFileEx clobbers — so the
existence check is now explicit.

* fix(spec,release): Windows-green plan tests + valid release plan

- publishPlan returns forward-slash spec_change_path/plan_workspace_path
  so Windows callers (and plan.test.ts contains-assertions) see
  separator-stable reference paths.
- archiveChange checks the archive target explicitly: POSIX renameSync
  threw on an existing target, Windows MoveFileEx silently clobbered —
  the 'delta written then archive throws' test now errors on every OS.
- .changeset/post-tool-use-awareness-push.md referenced package 'colony'
  (not in workspace; the CLI is 'colonyq'), which crashed changesets'
  assemble-release-plan and failed every Release run since #594.

* fix(cli,mcp): Windows-portable test expectations + structured already-archived error

mcp-server going green on Windows exposed the next packages in pnpm's
recursive run: 9 apps/cli failures, all path-portability in tests —
expectations assumed POSIX literals where the implementation resolves
and shell-quotes OS-natively. Added shellQuoteForTest mirroring the
production quoting rule; cockpit/queen-health/agents-spawn expectations
now derive from resolve(). PATH stubs join with path.delimiter. The
gx/cue PATH-spawning integration tests gate to POSIX (both tools spawn
via execFileSync without shell, which Windows cannot satisfy).

spec_archive returns structured SPEC_ARCHIVE_ALREADY_EXISTS
(status: already_archived) instead of an opaque throw on same-day
re-archive (review follow-up).

* chore(release): mark internal @colony/* packages private

The npm @Colony scope is not ours (@colony/core@3.1.0 belongs to a
different project), so 'changeset publish' would 403 on every public
internal package and fail Release after versioning. colonyq is the
product artifact and ships self-contained (prepack bundles, no
@colony/* deps in the published tarball — e2e-publish green), so the
ten internal packages are now private: publish ships exactly colonyq.

* fix(spec,cli): review follow-ups — staging recovery, aligned shellQuote charset, normalized archived_path

---------

Co-authored-by: NagyVikt <nagy.viktordp@gmail.com>
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