Skip to content

Port Remember capture to Antigravity CLI (agy): SessionStart, PreInvocation, Stop (#563) - #566

Merged
fdaviddpt merged 2 commits into
mainfrom
fix/563
Sep 5, 2026
Merged

fdaviddpt merged 2 commits into
mainfrom
fix/563

Conversation

@fdaviddpt

@fdaviddpt fdaviddpt commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Ports Remember's session-memory capture onto Antigravity CLI (agy), a fourth agent-CLI host, for issue #563 (superseding #553's investigation). Re-derives #553's own hooks.json schema finding live against agy 1.1.27 rather than trusting it as given -- confirms firing for SessionStart, PreInvocation, PostInvocation, Stop and wires the first three into capture.

  • pipeline/host.py: new ANTIGRAVITY host (real, live-captured ANTIGRAVITY_CONVERSATION_ID signature) and antigravity_exchange() reader for Antigravity's own flat transcript shape.
  • pipeline/extract.py: a third understood envelope, "antigravity".
  • Three new adapter scripts (scripts/agy-session-start-hook.sh, scripts/agy-pre-invocation-hook.sh, scripts/agy-stop-hook.sh) rename Antigravity's stdin payload into the shape the existing Claude Code-oriented hook scripts already understand, rather than teaching those scripts a second payload shape.
  • Stop fires after every turn, not once at session end (Hermes (hermes-agent) sessions never auto-restore — per-turn on_session_end deletes the restore record manaflow-ai/cmux#5000) -- agy-stop-hook.sh is deliberately not wired to session-end-hook.sh; it triggers save-session.sh's own idempotent, cooldown-gated flush instead, the same safe-to-repeat call post-tool-hook.sh already makes.
  • scripts/install_agy_hooks.py merges a "remember" entry into the shared, per-machine ~/.gemini/config/hooks.json without a static checked-in manifest -- nothing observed on Antigravity supplies a variable such a file could rely on.
  • docs/install-antigravity.md (new) and a correction to .claude/jit-context/vocabulary/02-hosts/antigravity-hooks.md, which had pinned an earlier, superseded hooks.json schema and a "PostToolUse/Stop never fire" finding that turned out to be an artifact of that wrong schema.

No genuine Antigravity session-end signal was found -- of the four events confirmed loading and firing, none is a process-exit or conversation-close event. Reported as an open gap in docs/install-antigravity.md, not silently worked around.

Three real defects were found and fixed only by driving this against a live agy process (protojson stdout parse failure on a Claude Code-shaped hook stdout; a backgrounded save not surviving the hook process exiting; a missing CLAUDE_PROJECT_DIR for that backgrounded save) -- see the commit messages and the developer note for the exact log evidence.

Self-review

Two spawns (Explore, oss:auditor) reviewed the first commit. Three real findings were fixed in a follow-up commit: stale docstrings after adding the fourth host, a one-directional wiring guard closed with a reverse-direction test, and install_agy_hooks.py silently treating a corrupt shared hooks.json the same as an absent one (now raises CorruptHooksFile and writes nothing). The auditor also caught an unused, live-looking CLAUDE_CODE_MESSAGING_TOKEN committed into a test fixture -- trimmed in the same follow-up commit.

Below the bar: agy-stop-hook.sh's sed -n Np field extraction (splitting conversationId/transcriptPath/workspacePaths[0] by line number) would misalign if one of those fields ever contained an embedded newline. Not fixed: both values are host-generated by agy itself (a UUID; a filesystem path Antigravity constructs deterministically), never attacker- or remote-authored text reaching this boundary, so the reachable input space that would trigger it is empty in practice -- there is no real caller for this class here.

Maintainer note on the leaked-looking fixture value: the raw CLAUDE_CODE_MESSAGING_TOKEN value is still present in this branch's first commit's diff (before the follow-up trimmed it). Consider squash-merging this PR rather than merging both commits individually, so the raw value never reaches the default branch's own history.

Test plan

  • pytest tests/test_antigravity_signature_563.py tests/test_antigravity_envelope_563.py tests/test_install_agy_hooks_563.py tests/test_agy_hooks_563.py tests/test_extract.py tests/test_hooks_json.py tests/test_host_shell_parity_407.py tests/test_codex_signature_463.py tests/test_codex_manifest_410.py tests/test_gemini_manifest_456.py tests/test_cross_host_lock_contract_491.py -q -- 129 passed, 40 skipped (platform-tooling skips, pre-existing) locally
  • CI green across all legs
  • python3 .oss/assemble_changelog.py --check -- passes

Closes #563

🤖 Generated with Claude Code

Verified by the maintainer

The "leaked-looking fixture value" this PR itself flags is real: tests/fixtures/antigravity-env-563.txt in this branch's original first commit (88f1769) carried this machine's live CLAUDE_CODE_MESSAGING_TOKEN, and it compared equal to the actual value in this session's own environment -- not a placeholder. A squash-merge does not contain that exposure: pushing the branch at all uploads the blob to GitHub, and once a pull request exists the object stays reachable via refs/pull/N/head even after the branch is deleted -- the exposure happens at push time, not merge time.

Before pushing, I rewrote this branch to a single commit (git reset --soft to the base, one fresh commit over the already-trimmed final tree) rather than pushing the original two-commit history and relying on squash-merge to hide the first commit. Confirmed the token string does not appear in any commit reachable from the new fix/563 HEAD (9efbf6e) via git rev-list HEAD | xargs -n1 git show | grep, and confirmed it is absent from the working tree via a full-tree grep. Whether the token itself should also be rotated is a separate question outside this PR's scope, raised with the maintainer.

Independently re-ran the new/changed test files against a scratch worktree of origin/main with this fix absent: tests/test_agy_hooks_563.py, tests/test_antigravity_envelope_563.py, tests/test_antigravity_signature_563.py genuinely fail (15 failed, 4 passed) and tests/test_install_agy_hooks_563.py fails to even collect (ModuleNotFoundError: No module named 'install_agy_hooks') -- confirming these are not vacuous tests. Re-ran the full new/changed test set against this branch's rewritten HEAD: 36 passed, 40 skipped (pre-existing platform-tooling skips), matching the report's own claim.

Accepted the below-bar finding on agy-stop-hook.sh's sed -n Np extraction as reasoned -- both fields are host-generated (UUID, deterministic path), not attacker-reachable.

[AI-generated]

fdaviddpt and others added 2 commits September 5, 2026 17:11
…cation, Stop (#563)

Re-derives #553's own hooks.json schema finding live against agy 1.1.27, confirms
firing (SessionStart, PreInvocation, PostInvocation, Stop) and wires the first three
into this plugin's capture pipeline: pipeline/host.py gains an ANTIGRAVITY host and
antigravity_exchange() reader for Antigravity's own flat transcript shape, and three
new adapter scripts rename Antigravity's stdin payload into the shape the existing
Claude Code hook scripts already understand rather than teaching those scripts a
second payload shape.

Stop fires after every turn, not once at session end (manaflow-ai/cmux#5000), so it
is deliberately NOT wired to session-end-hook.sh -- agy-stop-hook.sh instead triggers
save-session.sh's own idempotent, cooldown-gated flush, the same safe-to-repeat call
post-tool-hook.sh already makes. No Antigravity session-end signal was found; that
gap is documented, not silently patched over.

Three defects were found and fixed only by driving this against a real agy process
(none visible from a transcript-parsing unit test alone): agy's hook executor fails
to protojson-parse a Claude Code-shaped hook stdout, a plain backgrounded save did
not survive the hook process exiting (needed nohup + disown), and the backgrounded
save had no stdin of its own to resolve PROJECT_DIR from. Installed via
scripts/install_agy_hooks.py, which merges into the shared, per-machine
~/.gemini/config/hooks.json without a static manifest -- nothing observed on
Antigravity supplies a variable a checked-in file could rely on.

Also corrects .claude/jit-context/vocabulary/02-hosts/antigravity-hooks.md, which
pinned an earlier, wrong hooks.json schema and a "PostToolUse/Stop never fire"
finding that turned out to be an artifact of that schema, not of the host.

Self-review (Explore + oss:auditor) found and fixed 4 issues against the original
two-commit history: a live-looking CLAUDE_CODE_MESSAGING_TOKEN value in
tests/fixtures/antigravity-env-563.txt trimmed to only the variables the tests
actually read; a corrupt-hooks-file data-loss bug in install_agy_hooks.py's
_load_existing() (an existing-but-unparseable ~/.gemini/config/hooks.json was
treated as absent, so install() would have silently discarded another plugin's
real hook entries -- it now raises CorruptHooksFile and writes nothing); a
one-directional gap in the agy-*-hook.sh wiring guard; and stale host/envelope
counts in pipeline/host.py and pipeline/extract.py docstrings.

Squashed to one commit before push: the token above was present in this branch's
original first commit and trimmed in a follow-up commit, which does not remove it
from a pushed branch's history. Squashing here means no object ever reaches the
remote carrying the real value; the fixture's tree state (token already trimmed)
is unchanged.

Refs #553, #563.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bv6BGZD2EdZ9EuJ7tPDTb7
CI (pytest windows-latest 3.10) failed #497's own meta-guard,
tests/test_windows_skip_triage_497.py: every module that carries a
module-level `pytestmark = pytest.mark.skipif(sys.platform == "win32", ...)`
must have an entry in docs/windows-skip-triage.md, and this new module
(added in the previous commit) did not.

Added the entry: `unclear`, the same templated reason string and verdict
already given to test_session_end_hook_345.py, test_post_tool_hook_spawns.py
and test_prompt_hook_spawns.py, which this module's own three subprocess
tests are modelled on. Bumped the doc's own recomputed counts (97 -> 98
total, 77 -> 78 unclear) to match.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bv6BGZD2EdZ9EuJ7tPDTb7
@fdaviddpt
fdaviddpt merged commit 304565f into main Sep 5, 2026
16 checks passed
@fdaviddpt
fdaviddpt deleted the fix/563 branch September 5, 2026 15:42
fdaviddpt added a commit that referenced this pull request Sep 5, 2026
The `agy` port shipped in #563/#566 with a full install page, and the README
never mentioned it -- `grep -niE 'antigravity|agy' README.md` returned nothing.
The README also stated the rule for its own host badges ("Gemini CLI carries no
host badge above, while Claude Code and Codex do") while being wrong about its
own badge row: Antigravity is an observed host under exactly that rule, driven
end to end against a real `agy` 1.1.27 process rather than reasoned from docs.

Antigravity gains a badge, an install section around `scripts/install_agy_hooks.py`,
its own hooks-table column and a docs-list entry. The column is separate rather
than folded into `Claude Code / Codex` because the mapping genuinely differs:
`UserPromptSubmit` maps to `PreInvocation`, `PostToolUse` is not wired, and
`SessionEnd` has no analogue found. That last row is stated in the README itself,
not left to the install page -- none of the four Antigravity events confirmed to
fire is a process-exit signal, so a short conversation can end with no final
flush, and that belongs in front of a reader choosing a host.

Gemini CLI comes off the README: its install section, table column and docs-list
link are removed. `gemini extensions link` is refused on a free-tier individual
account with working credentials (`IneligibleTierError: UNSUPPORTED_CLIENT`,
#532) and Google's own error text names Antigravity as the migration. This is
NOT a claim that Gemini CLI was withdrawn upstream: paid tiers were never tested
and nothing above 0.58.0 was re-probed, so "refused on the tiers that could be
tested" is the whole observation, and the README says no more than that.
`.gemini/settings.json` and `tests/test_gemini_manifest_456.py` are untouched.

`tests/test_host_neutral_wording_562.py:61` hard-asserted the old table header
verbatim, so it moves with the table; the #562 guard it belongs to is unchanged.

Known follow-on, deliberately not settled here: `docs/install-gemini-cli.md` is
now linked from nowhere while its manifests stay checked in and tested, which
this repo's own bar counts as a defect. Named in #572 for a decision.

Closes #572


Claude-Session: https://claude.ai/code/session_01Bv6BGZD2EdZ9EuJ7tPDTb7

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.

Port Remember's capture to Antigravity CLI (agy): SessionStart, PreInvocation, Stop

1 participant