Skip to content

feat: Wave 0-3 — EA/EFM kernel overhaul#1

Merged
chazmaniandinkle merged 10 commits intocogos-dev:mainfrom
chazmaniandinkle:main
Apr 7, 2026
Merged

feat: Wave 0-3 — EA/EFM kernel overhaul#1
chazmaniandinkle merged 10 commits intocogos-dev:mainfrom
chazmaniandinkle:main

Conversation

@chazmaniandinkle
Copy link
Copy Markdown
Contributor

Summary

Complete implementation of the CogOS externalized attention and executive function modulation (EA/EFM) architecture across 10 commits:

  • Kernel bug fixes: Turn-pair eviction, precision token estimation (rune-aware + iris pressure), keyword-anywhere intent extraction
  • Gemma 4 E4B: Default local model with model profiles, CapToolCallValidation capability
  • Tool-call hallucination gate: "Model proposes, runtime disposes" — validates tool calls before execution, proprioceptive logging, per-provider rejection tracking
  • Digestion pipeline: StreamTailer + FileWatcher + Claude Code/OpenClaw JSONL adapters, wired into process loop (state-gated)
  • Memory consolidation: ConsolidationAction during Dormant state + archive eviction policy
  • Constellation bridge: ConstellationBridge interface + NilBridge + SyncWatcher for BEP-synced blocks
  • Comprehensive test suite: 35+ new tests across all subsystems
  • E2E test plan: 5-scenario spec (standalone, Gemma 4, digestion, constellation, full stack)
  • README: Reframed with EA/EFM thesis + ecosystem overview

Test plan

  • go build ./... passes
  • All new tests pass (go test ./internal/engine/... -short)
  • Pre-existing TestClaudeCodeBuildPromptIncludesMultipleUserTurns failure is unchanged (not caused by these changes)

🤖 Generated with Claude Code + Codex

chazmaniandinkle and others added 10 commits April 7, 2026 16:30
…ction

- evictForBudgetMode now evicts user+assistant pairs atomically (prevents
  orphaned assistant answers without their triggering prompt)
- Added estTokensPrecise() with rune-aware heuristics for CJK, JSON, and
  code. Activated when iris pressure > 0.8 via WithIrisSignal option.
- Replaced extractGoal prefix matching with keyword-anywhere matching
  across action/understand/operate categories. Handles polite prefixes.

All three bugs identified during architectural review session.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Codex gpt-5.4 <noreply@openai.com>
- Added model profile system to OllamaProvider with known profiles for
  gemma4:e4b, gemma4:e2b, qwen3.5:9b
- New CapToolCallValidation capability — Gemma 4 advertises this but NOT
  CapToolUse, enabling the router to route tool-heavy tasks to providers
  with reliable tool support
- Added local_model config field (default: gemma4:e4b)
- Router wired to honor local_model override with provider rejection tracking

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Codex gpt-5.4 <noreply@openai.com>
- ValidateToolCall rejects: unknown tools, missing required params,
  type mismatches, and embedded result fields (hallucination detection)
- Rejected calls fed back to model as system message for retry
- Proprioceptive logging of rejections for shadow model training
- Per-provider rejection counter feeds router sovereignty gradient
- ToolCallValidationEnabled config (default true)
- Trusted providers with CapToolUse skip validation automatically

Addresses known Gemma 4 tool-call fabrication issue.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Codex gpt-5.4 <noreply@openai.com>
… adapters

- StreamTailer interface + TailerManager for lifecycle management
- Zero-dependency FileWatcher with polling, truncation, and rotation handling
- ClaudeCodeTailer normalizes ~/.claude/ JSONL logs to CogBlocks
- OpenClawTailer normalizes OpenClaw JSONL with directory mode (auto-discovers files)
- Both set proper provenance: source_channel, normalized_by

The digestion pipeline converts external harness logs into cog-native events.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Codex gpt-5.4 <noreply@openai.com>
- ConsolidationAction reads recent ledger events, groups by session,
  extracts keyword topics, writes summary CogBlocks
- Wired into process.go heartbeat path during Dormant state (1hr default)
- Archive emission after consolidation records consolidated session_ids
- ArchivedSessions() helper for querying which sessions are consolidated
- Archive events filtered from future consolidation passes (no feedback loops)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Codex gpt-5.4 <noreply@openai.com>
- SyncWatcher polls .cog/sync/inbox/ for BEP-synced SyncEnvelopes
  with structural validation (version, timestamp, hash format, kind)
- ConstellationBridge interface: EmitHeartbeat, TrustSnapshot, Start/Stop
- NilBridge for standalone mode (healthy defaults, zero overhead)
- Wired into process.go: emitHeartbeat() calls bridge with full state payload
  (process state, field size, coherence/nucleus fingerprints, ledger head)
- Bridge receipt hash attached as CogBlock artifact

Per the constellation-kernel bridge specification (D1).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Codex gpt-5.4 <noreply@openai.com>
- Lead with "externalized attention and executive function modulation"
- Added "The model generates. The substrate thinks." framing
- Expanded ecosystem table (5 repos with verb-based descriptions)
- Reframed mod3 as modality bus ("how it ACTS")
- Updated status to reflect Wave 0+1 implementation work
- Added EA/EFM section to Core Ideas

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- TailerManager initialized during Run() from DigestPaths config
- Select-loop case ingests CogBlocks during Receptive/Active states
- Drops ingestion during Consolidating/Dormant (state-gated)
- DigestPaths config: map[string]string of adapter_name -> path (default empty)
- Integration test with mock tailer verifies ledger write

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Codex gpt-5.3-codex <noreply@openai.com>
- Tool loop: wrong-param-type rejection, rejection counter tracking,
  trusted-provider skip parallelized
- Constellation bridge: full payload through NilBridge.EmitHeartbeat
- Sync watcher: non-JSON ignore, empty directory handling
- Claude Code tailer: tool_use/tool_result kind normalization, malformed line safety
- OpenClaw tailer: directory-mode discovery, malformed JSON skipping

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Codex gpt-5.3-codex <noreply@openai.com>
Five test scenarios covering:
1. Standalone kernel (health, chat, ledger, context, shutdown)
2. Gemma 4 integration (local inference, tool-call gate, proprioceptive log)
3. Digestion pipeline (JSONL tailing, CogBlock ingestion, state gating)
4. Constellation bridge (heartbeat payload, SyncEnvelope detection)
5. Full stack (kernel + mod3 + constellation cross-system communication)

Spec document — no test code. Aligned with existing e2e-test.sh patterns.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Codex gpt-5.3-codex <noreply@openai.com>
@chazmaniandinkle chazmaniandinkle merged commit 3f25200 into cogos-dev:main Apr 7, 2026
1 of 3 checks passed
chazmaniandinkle referenced this pull request in chazmaniandinkle/cogos Apr 14, 2026
Foundation layer for the foveated context rendering pipeline:

- cogdoc_service.go: CogDocService with WriteAndSync/PatchAndSync —
  single write-through path ensuring index refresh + field boost +
  ledger emit on every CogDoc mutation (fixes Codex finding #1)
- context_frame.go: ContextFrame type with named blocks (nucleus,
  project, knowledge, node, field, events, focus), tier priorities,
  stability hints for KV cache, budget-aware eviction, and HTML
  comment rendering
- mcp_server.go: 3 MCP Resources (cogos://state, cogos://nucleus,
  cogos://field) alongside the 10 tools — proper tool/resource
  separation per MCP spec
- uri_resolve_test.go: 15 tests covering URI holographic pointer
  round-trips across all forms (cog://, cog:, relative, absolute)

Gate G0→1: go build + go test both pass clean.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
chazmaniandinkle added a commit that referenced this pull request Apr 21, 2026
Track 1 of the Windows dev-preview rollout (PRs #1 and #2 in Agent K's
release audit).

Makefile:
- Add windows-amd64 and windows-arm64 cross-compile targets, mirroring
  release.yml exactly (CGO_ENABLED=0, ./cmd/cogos/ entry point, .exe
  suffix). Extends the existing PLATFORMS list rather than introducing
  a new pattern.

docs/RELEASING.md:
- Add a "Installing on Windows (developer preview)" section covering
  PowerShell download, SmartScreen "More info -> Run anyway" workaround
  for the unsigned binary, %LOCALAPPDATA%\cogos\ install path with User
  PATH update, and a version/serve/health sanity check using the actual
  subcommands exposed by internal/engine/cli.go.
- Note that Windows Service / SCM integration is a follow-up, not part
  of v0.x.

No version tag is cut; no .go code is touched. go build and go vet are
both clean. Windows targets were verified locally to produce valid
PE32+ executables (amd64 and arm64).
chazmaniandinkle pushed a commit that referenced this pull request Apr 22, 2026
… gap

Closes Agent F gap #3 (session management, CRITICAL) — the last of the
eight critical MCP surface gaps. Implements the hybrid design in
cog://mem/semantic/surveys/2026-04-21-consolidation/
agent-P-session-management-evaluation with a few user-approved amendments
(see below).

Kernel changes
--------------
- internal/engine/sessions.go: typed SessionState, SessionRegistry,
  HandoffState, HandoffRegistry with RWMutex / Mutex guards; session-id
  format validation; idempotent-register "update semantics"; atomic
  first-wins claim with TTL enforcement; replay-from-bus at startup so
  the in-memory view rebuilds from bus_sessions + bus_handoffs.
- internal/engine/serve_sessions_mgmt.go: 8 HTTP handlers —
    POST /v1/sessions/register
    POST /v1/sessions/{id}/heartbeat
    POST /v1/sessions/{id}/end
    GET  /v1/sessions/presence
    POST /v1/handoffs/offer
    GET  /v1/handoffs
    POST /v1/handoffs/{id}/claim
    POST /v1/handoffs/{id}/complete
  The existing /v1/sessions and /v1/sessions/{id}[/context] routes (TAA
  inference context, regression-locked) are preserved untouched; the new
  specific patterns coexist thanks to Go 1.22 method-aware routing.
- internal/engine/mcp_sessions.go: 8 cog_* MCP tools over the same
  registries so a future native client (Wave widget, desktop app, cog
  CLI) can use handoff without the Python bridge (amendment #5 — two
  MCP surfaces coexist by design).
- internal/engine/sessions_test.go: 15 unit + integration tests
  (validation, lifecycle 404/409, active-window presence, task-field
  validation, 8-way concurrent claim atomicity, TTL expiry, phantom
  offer, complete-without-claim, replay rebuilds state, claim_rejected
  observability, end-to-end MCP round-trip).

Amendments applied vs the survey
--------------------------------
1. No parallel coexistence. All four consumers are in-tree (this PR,
   the bridge on a local branch, the skill doc, and cmd_bus.go);
   migrated atomically. The survey's Open Question #1 was skipped.
2. Idempotent register = update-semantics (survey's Open Question #2
   recommendation). Re-register during the active window updates the
   in-memory row; re-register after end is allowed if the prior row is
   ended or its heartbeat is outside the active window.
3. `handoff.claim_rejected` event emitted on every rejected claim, with
   reason ∈ {already_claimed, ttl_expired, offer_not_found,
   out_of_order}, attempting_session, and conflicting_session when
   relevant. Cheap; big audit value (amendment #4).
4. Two MCP surfaces coexist by design — 8 cogos_* bridge tools over the
   Python sandbox + 8 cog_* kernel-native tools via /mcp. Both hit the
   same kernel registries (amendment #5).

Bridge migration
----------------
A paired local branch on cog-sandbox-mcp (`feat/sessions-kernel-native-
bridge`, NOT pushed) refactors the 8 cogos_* tools to shim over the new
kernel routes, removes client-side aggregation, and rewrites
tests/test_session_handoff.py for the new wire shape. Bridge MCP
signatures and the never-raise {"success": False, "error": ..., "bus_id"}
envelope are preserved — no breaking change for agents using the bridge.

Testing
-------
- `go build ./...`, `go vet ./...`: silent.
- `go test ./internal/engine/... -short -race -count=1`: green
  (pre-existing + new suite passes under race detector).
- End-to-end smoke on port 6932 with a test workspace: register →
  heartbeat → offer → list → claim → second claim (→ 409 +
  claim_rejected event) → complete. bus_sessions chain: 3 events.
  bus_handoffs chain: 4 events (offer, claim, claim_rejected,
  complete). Bridge tools replayed the same flow against the live
  kernel with back-compat response shapes intact.
- The running kernel at :6931 was NOT touched during this work.

Survey reference: cog://mem/semantic/surveys/2026-04-21-consolidation/
agent-P-session-management-evaluation
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