Files
ECC/scripts/hooks
CarbonPyramid 5a565cf1d1 fix(hooks): bind context-gate checkpoint to real identity; frame handoff as a proposal
Round-6 ownership revision for the enforce-mode checkpoint (PR #3106,
@haelyra requested-changes on fffda19).

1. Require real handoff identity, preserve an occupied destination.
   - resolveCheckpointPath -> resolveCheckpointIdentity: drops the literal
     'project'/'session' fallbacks. A session id (input.session_id or a
     session env override) AND a project are now required; when neither
     resolves it returns null and the hook declines enforcement, so two
     same-named projects with no session id can no longer collide on one
     shared <sessions>/resume/project-session.md path.
   - New pickOwnedDestination + readOwnerSession: before targeting an
     existing destination the gate checks an ecc-handoff ownership marker.
     A file owned by this session is reused (idempotent); an unmarked,
     unreadable, or foreign-owned file is never overwritten — the gate
     disambiguates to a sibling (-2, -3, ...) or declines.
   - Missing-identity fire now emits a degraded advisory (buildDeclineText):
     it names no checkpoint path and orders no write, but still warns and
     tells the operator to set ECC_SESSION_ID — not a silent drop.

2. Report a proposed handoff until a write is verified.
   - buildOrderText no longer calls the resume command a completed "receipt".
     The checkpoint is a PROPOSAL; the resume command is gated on an explicit
     "verify the file exists and is non-empty" step. The model is instructed
     to stamp the exact ownership marker (session+project) and record the
     source revision (git rev-parse HEAD), binding the handoff to a revision.

Tests: existing buildOrderText case extended for proposal framing; three new
disposable, sandboxed (ECC_AGENT_DATA_HOME) ownership cases — missing-identity
same-named projects with a pre-existing destination that survives byte-for-byte,
foreign-owned destination disambiguated, same-owner destination reused. Full
suite 4765/4765 serial.
2026-11-05 22:51:16 -06:00
..