Skip to content

feat(catalog): add context bundler, turn batching, and harness-tailored routing - #126

Merged
futuregerald merged 2 commits into
mainfrom
feat/turn-batching-and-harness-efficiency
Nov 15, 2026
Merged

futuregerald merged 2 commits into
mainfrom
feat/turn-batching-and-harness-efficiency

Conversation

@futuregerald

Copy link
Copy Markdown
Owner

Summary

  • Add a deterministic, byte- and line-bounded subagent context bundler (build_subagent_context.py) and codify parallel read/edit batching rules across shared skills, Antigravity, Claude Code, and OpenCode.
  • Introduce an Antigravity-only persistent sleeping Hydrogen ops worker pattern (gemini-4-hydrogen-high, 0.2x) with observable cum_turns=<N> rotation and strict untrusted-output/write-path guards while enforcing zero Antigravity-only mechanics leakage into Claude Code, Zed, or OpenCode assets.
  • Harden read-only reviewer tool allowlists across Claude Code and OpenCode (eliminating MCP * wildcards that exposed mutating index/delete tools), set effort: low on context-finder and runner, install skill scripts/*.{py,sh} as 0755, and track ByteOffset pagination in the Antigravity circuit-breaker hooks.

Background

Context

Subagent-driven workflows across Antigravity, Claude Code, Zed, and OpenCode previously incurred avoidable token replay and wall-clock latency from three sources:

  1. Subagents and adversarial reviewers reading full source files or unchunked diffs one file per turn instead of consuming pre-packed file:start-end slices and bounded unified-diff chunks in parallel batches.
  2. Repeatedly spawning high-cost frontier turns for mechanical multi-turn repository tasks (multi-suite/E2E runs, standalone builds, CI log extraction, wide caller scouting) in Antigravity, whereas Claude Code has different delegation economics (+58% Agent resume replay penalty and ~7x multi-session Agent Teams overhead).
  3. Shared skill files (future-model-router, subagent-driven-development, comprehensive-code-review) carrying legacy 4-section handoff references or Antigravity-specific primitives (Hydrogen, swarm_wait, baton-pass, peer-pipeline-swarm, /start-small), alongside wildcard MCP tool grants (mcp__codebase-memory-mcp__*) on read-only reviewers.

The problem

  • Wide lines or dense unified diffs chunked solely by line count could still exceed read_file's 46,080-byte per-call limit, forcing extra pagination turns, while ByteOffset pagination in Antigravity's autonomous_breaker.py was not differentiated from true repeated-slice loops.
  • mcp__codebase-memory-mcp__* wildcards on Claude Code read-only reviewers implicitly granted mutating index_repository and delete_project MCP tools, and OpenCode reviewer definitions needed valid boolean tools: maps enforcing read-only invariants.
  • Skill helper scripts (scripts/*.py, scripts/*.sh) were installed with 0644 permissions rather than 0755.

The fix

  • Deterministic context bundler (build_subagent_context.py): Supports pre-code (## Acceptance Criteria extraction + --root realpath-contained file:start-end numbered slices) and post-code (safe --no-ext-diff --no-textconv -- unified diffs for both uncommitted <base> working trees and <base>...<head> ranges), computing a converged two-pass ## Read Chunk Index bounded to both <=700 lines and <=38,000 UTF-8 bytes with dynamic backtick fences and atomic 0600 non-symlink writes.
  • Harness-tailored delegation & read-only hardening:
    • Antigravity (internal/catalog/antigravity/): Documents observed Turn-1 floors (22.7k, 24.8k, 29.3k, 45.0k), adds <185k peak-context guard + parallel batching to implementer and all 5 read-only reviewers, defines the optional sleeping ops worker (gemini-4-hydrogen-high, cum_turns=<N> rotation, /tmp/*-only writes, untrusted-log safety, baton-pass teardown), and tracks ByteOffset in breaker_rules.py and autonomous_breaker.py.
    • Claude Code (internal/catalog/claude/): Preserves fresh one-shot Agent dispatches (documenting the +58% resume replay penalty and experimental Agent Teams ~7x multiplier), sets effort: low on context-finder and runner, and locks all read-only reviewers to explicit read-only tool allowlists (Read, Grep, Glob, ToolSearch + read-only codebase-memory-mcp query tools only).
    • OpenCode & Shared (internal/catalog/opencode/, internal/catalog/shared/): Strips Antigravity-only mechanics from shared/skills/future-model-router, aligns all shared prompts and OpenCode agents on the 5-section handoff, and validates OpenCode YAML boolean tools: maps in harness_efficiency_test.go.
    • Installer (internal/installer/): Installs .py and .sh files under skill scripts/ directories with executable mode 0755.

Test plan

  • Added 16 unit tests in internal/catalog/shared/skills/subagent-driven-development/scripts/test_build_subagent_context.py covering pre-code slice extraction, two-pass Read Chunk Index byte/line reconstruction, UTF-8 multibyte line splitting under --max-chunk-bytes, --root traversal/symlink rejection, 0600 atomic non-symlink writes, dynamic backtick fences, canonical git diff flags, and invalid git ref rejection (wired into Makefile and .github/workflows/test.yaml).
  • Added cross-harness catalog tests in internal/catalog/harness_efficiency_test.go verifying zero Antigravity-only mechanics or legacy 4-section handoff strings outside internal/catalog/antigravity/, explicit read-only Claude reviewer allowlists, valid OpenCode YAML boolean tools: maps, effort: low helper frontmatter, PII/email hygiene, and Antigravity floor consistency.
  • Added TestSkillScriptsInstalledExecutable0755 in internal/installer/installer_test.go and ByteOffset pagination loop tests in internal/catalog/antigravity/hooks/{test_autonomous_breaker.py,test_breaker_rules.py}.
  • Ran bash scripts/sync-antigravity-from-local.sh, gofmt -l ., HOME=$(mktemp -d) go test -race ./..., make test-python (650 shared + 125 Antigravity hook tests passed), make build, and ./skill-installer -y --force --global -t claude --track opinionated.

Rollback plan

Revert this PR and re-run skill-installer (or skill-installer restore) to restore the previous global skill and agent definitions.

@futuregerald
futuregerald merged commit 6559ed8 into main Nov 15, 2026
1 check passed
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