Skip to content

feat: composable context-intelligence behaviors — logging / analytics / full#27

Open
colombod wants to merge 8 commits into
mainfrom
feat/spike-readonly-behaviour
Open

feat: composable context-intelligence behaviors — logging / analytics / full#27
colombod wants to merge 8 commits into
mainfrom
feat/spike-readonly-behaviour

Conversation

@colombod
Copy link
Copy Markdown
Collaborator

@colombod colombod commented May 30, 2026

Intent

The context-intelligence logging hook was doing two unrelated jobs: session-event telemetry AND fetching/refreshing the context-intelligence-graph-query skill content from the server. Those concerns have different consumers — telemetry is wanted by anyone capturing sessions (ideal as an always-on --app), while skill-content sync is only relevant to the analytics path (the graph-analyst agent + graph_query/blob_read tools that actually use the skill). Coupling them forced all-or-nothing composition and put server-fetch + disk-write logic inside a telemetry hook.

This PR separates the concerns: the bundle now exposes three composable behaviors (logging / analytics / full) so consumers pick exactly what they need, and the logging hook becomes pure telemetry.

What changed

1. Skill-content sync relocated: hook → tool-graph-query

  • New skill_fetcher.py (server fetch, ETag conditional GET, Bearer auth) and skill_sync.py (on_session_ready orchestration).
  • Sync now runs in the graph-analyst sub-session (where the skill is consumed) via the kernel on_session_ready mechanism — not at hook-mount time.
  • Offline-drift invalidation: when the server is unreachable and the on-disk SKILL.md hash has drifted, the .etag/.content_hash sidecars are invalidated (content retained) — so a stale ETag can't mask a local reset.
  • skill:unloaded re-sync handler for mid-session reloads.

2. Logging hook reduced to pure telemetry

  • Removed skill_fetcher.py, legacy_content/, and the skill tests from hook-context-intelligence. Hook __init__.py: 306 → 157 lines.

3. Config-resolver correctness

  • Renamed _resolver_hook_resolver across both tools; the hook resolver is fetched lazily via capability in on_session_ready, not at mount.
  • Restored the ToolConfigResolver env/settings fallback for analytics-only mode (its earlier removal would have been a silent breaking change).
  • Fixed placeholder expansion: ${AMPLIFIER_CONTEXT_INTELLIGENCE_*} config placeholders are now expanded before the truthiness check, so analytics-only mode resolves the real server URL instead of a truthy literal that silently defeated the env fallback.

4. Dependency hygiene

  • All three modules resolve amplifier-core from the PyPI wheel (>=1.6.0) instead of a git/Rust source build — removes a maturin build hang and reverts an out-of-place v1.2.4 downgrade.

5. Documentation

  • README: all three behaviors documented with their --app install commands; expanded Development (per-module tests, the venv --reinstall --refresh caveat, DTU pointer).
  • Fixed docs/logging-handler-flow.dot rendering and added docs/context-intelligence-skill-sync-flow.dot for the server-sync flow.
  • Regenerated bundle.dot/bundle.png for the 3-behavior split.
  • Added a contributor AGENTS.md (setup, tests, DTU gate, pitfalls).

Improvements & why they matter

  • Granular composition — install logging-only, analytics, or full; pick exactly what you need.
  • Separation of concerns — the telemetry hook no longer fetches skills or writes to disk.
  • Analytics-only sync actually works (the whole point of the relocation) — proven against a live server.
  • No silent staleness — offline drift invalidates sidecars; a reset can't masquerade as a good state.
  • Faster, reproducible builds — PyPI wheel, no Rust compile.

Evidence

  • Unit tests (fresh): 421 passing, 0 failurestool-graph-query 87 · tool-blob-read 35 · hook-context-intelligence 299.
  • Red-green verified on the core placeholder fix: reverting tool_resolver.py (with uv sync --reinstall --refresh) turns the 3 placeholder tests RED (assert '${AMPLIFIER_…}' == 'secret'); restoring turns them GREEN — the regression test genuinely catches the bug.
  • Lint/types clean — ruff (lint + format) pass; pyright 0 errors / 0 warnings on the changed source.
  • DTU end-to-end against a LIVE context-intelligence server — all 4 scenarios PASS:
    • S1 analytics-only + reachable server → SKILL.md populated with real server content (MATCH (×44) + .etag/.content_hash written; resolver returned the real URL.
    • S2 offline drift → sidecars invalidated, content retained (validated with frontmatter-preserving drift).
    • S3 logging-only → zero skill activity, telemetry written.
    • S4 full → telemetry + a single skill sync.
  • Causality investigation proved the relocated sync's disk writes do not perturb skills discovery; an earlier S2 "failure" was a flawed test (frontmatter-destroying drift), not a product defect.

🤖 Generated with Amplifier


Commits and Files Changed

  • 21 commits pushed to feat/spike-readonly-behaviour
  • 54 files changed: 3395 insertions, 3357 deletions

@colombod colombod changed the title feat: composable analytics behavior — use CI read/query/design without the hook feat: composable context-intelligence behaviors — logging / analytics / full May 31, 2026
@colombod colombod force-pushed the feat/spike-readonly-behaviour branch from 56e58a6 to ca10e89 Compare June 2, 2026 09:18
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