Skip to content

feat: Opus 4.7 integration (v4.5.0)#13

Closed
Luispitik wants to merge 2 commits into
mainfrom
feat/opus-4-7-integration
Closed

feat: Opus 4.7 integration (v4.5.0)#13
Luispitik wants to merge 2 commits into
mainfrom
feat/opus-4-7-integration

Conversation

@Luispitik

Copy link
Copy Markdown
Owner

Summary

  • Cache-stable instinct orderingid.localeCompare tiebreaker after priority + occurrences makes the injected systemMessage prefix byte-stable across consecutive tool uses, unlocking prompt-cache hits on Opus 4.7's cached system block (~90% discount on the instinct payload once the cache warms).
  • New PreCompact hook (core/_precompact-guard.sh) — re-invokes the session-learner right before Claude Code compacts the context in long sessions, so fresh observations are flushed to proposals before the transcript is rewritten. Fire-and-forget with an 8 s cap; relies on the existing advisory lock inside _session-learner.sh.
  • Caps raised for 1M contextTOKEN_BUDGET 1500→4000, top-N instincts per tool use 3→6, observation window 1000→5000 lines. Cross-session detectors see a longer history; per-turn injection can surface more relevant rules.
  • RFC for adaptive thinking in /analyze-session (docs/rfc-v5-adaptive-thinking.md) — design only, opt-in behind SINAPSIS_LLM_ANALYZE=1. Core stays fully deterministic until validated.
  • 11 new TDD tests covering deterministic ordering, PreCompact wiring, and raised caps. All existing suites re-run clean: 112 tests passing (install-upgrade 21, dashboard 12, dream 25, gstack-separation 18, security 11, v433-hardening 14, v45-opus47 11).

Test plan

  • bash tests/test-v45-opus47.sh — 11/11 PASS (cache-stability + PreCompact + caps)
  • bash tests/test-v433-hardening.sh — 14/14 PASS (regression: auto-promote, token budget, scrubbing)
  • bash tests/test-install-upgrade.sh — 21/21 PASS (install copies _precompact-guard.sh + chmod)
  • bash tests/test-dashboard.sh — 12/12 PASS
  • bash tests/test-dream.sh — 25/25 PASS
  • bash tests/test-gstack-separation.sh — 18/18 PASS
  • bash tests/test-security.sh — 11/11 PASS (3 pre-existing LOAD_FAIL skips, not regressions)
  • CI on Ubuntu / macOS / Windows (automatic on push)
  • Manual smoke: observe a tool use, confirm systemMessage order is stable across calls, confirm PreCompact fires on a long session without blocking

🤖 Generated with Claude Code

Luispitik and others added 2 commits April 18, 2026 14:38
CHANGELOG: add v4.4.2 entry documenting the regression fix from #7.
README: bump 4.4.1 -> 4.4.2 (tests stay at 99, PR #7 was code-only).

Fix resuelve issue #6 (crash on /dashboard-sinapsis first run).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sinapsis stays fully deterministic in the hot path and becomes richer and
cheaper to run on top of Claude Opus 4.7.

- Cache-stable instinct ordering: id.localeCompare tiebreaker after
  priority + occurrences makes the injected systemMessage prefix
  byte-stable across consecutive tool uses, which is the prerequisite
  for prompt-cache hits on Opus 4.7's cached system block.
- PreCompact hook (core/_precompact-guard.sh): re-invokes the learner
  before Claude Code compacts the context in long sessions, so fresh
  observations are flushed to proposals before the transcript is
  rewritten. Fire-and-forget with an 8s cap.
- Raised caps for the 1M context window:
  * TOKEN_BUDGET 1500 -> 4000 (chars injected per tool use)
  * top-N instincts per tool use 3 -> 6 (MAX_INSTINCTS_INJECTED)
  * observation window for session-learner 1000 -> 5000 lines
- settings.template.json declares the new PreCompact hook (hooks 6 -> 7).
  install.sh copies and chmods _precompact-guard.sh.
- RFC docs/rfc-v5-adaptive-thinking.md: design for an opt-in
  SINAPSIS_LLM_ANALYZE=1 path in /analyze-session that would call the
  Anthropic SDK with adaptive thinking. NOT implemented in this release
  - core stays deterministic until the approach is validated.
- Operator note: Scout/Analyst blueprint in v5.0-alpha no longer uses
  Haiku; Sonnet 4.6 is the lowest tier the system proposes.

New suite tests/test-v45-opus47.sh (11 tests, all GREEN) covers the
deterministic ordering invariant (shuffled-index byte-identical output,
alphabetical tiebreaker), end-to-end PreCompact wiring, and the new
caps. All existing suites re-run clean: install-upgrade 21/21,
dashboard 12/12, dream 25/25, gstack-separation 18/18, security 11/11,
v433-hardening 14/14. Total 112 tests passing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@Luispitik Luispitik mentioned this pull request Apr 21, 2026
8 tasks
@Luispitik

Copy link
Copy Markdown
Owner Author

Superseded by #14 — same commit, rebased cleanly on main (branch base had conflicting squash from #11).

@Luispitik Luispitik closed this Apr 21, 2026
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