Skip to content

feat: resilience, governance ceiling, and audit trail - #180

Open
Patel230 wants to merge 4 commits into
mainfrom
feat/resilience-governance-audit
Open

feat: resilience, governance ceiling, and audit trail#180
Patel230 wants to merge 4 commits into
mainfrom
feat/resilience-governance-audit

Conversation

@Patel230

@Patel230 Patel230 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements three resilience/governance/audit capabilities plus a self-improvement wiring fix, based on the gap analysis against comparable agent platforms.

1. Hash-chained Security Event Log (internal/securitylog)

  • HMAC-SHA256 hash-chained, tamper-evident event log with a head-pointer file to catch tail truncation.
  • Verify() detects any altered or missing entry; key generated on first use.
  • Tests: append/reopen/tamper/truncation/append-after-close.

2. Governance POLICY ∩ PROFILE ceiling (internal/governance)

  • Two-layer tightest-wins model: admin POLICY (platform trust-root) can only be narrowed by the session PROFILE, never loosened.
  • Evaluated before hooks, spec stage, rules, autonomy, and the bypass kill-switch — an un-disableable org ceiling.
  • Fail-closed policy files, flat denied-tool lists, sensitive-path floors, scope catalog.
  • Wired into PermissionEngine and auto-loaded at session bootstrap.

3. TaskRunner persistence + retry/replan (internal/tool)

  • TaskStore disk persistence (atomic snapshot, load/resume, id-counter preservation).
  • Retry budget: MarkFailed requeues while attempts remain, parks tasks in a new failed state for replanning when exhausted; Requeue resets the budget; Checkpoint stores resumable progress.
  • Task tools expose attempts/lastError/checkpoint and a failed listing action.

4. Persist failure reflections to the lesson store (internal/engine, cmd/chat.go)

  • The Reflector's structured lessons were ephemeral; SelfImprover.Learn was never called. Session.Learn callback (propagated to sub-sessions) now persists them; chat wires it so lessons survive sessions and feed back via ForPrompt.
  • SelfImprover made thread-safe, nil-safe, bounded at 200 entries.

Verification

  • go build ./..., full go test ./..., make lint, and hawk verify all pass.
  • No emoji in internal/ (lefthook forbidden-strings + emoji audit green).

Adds internal/securitylog with an HMAC-SHA256 hash-chained event log and a
head-pointer file to catch tail truncation. Verify() detects tampering or
missing entries; the chain key is generated on first use and stored beside
the log. Includes append/verify/reopen/tamper/truncation tests.
Adds internal/governance: a two-layer permission model where the admin-set
POLICY (loaded from a platform trust-root) can only be narrowed, never
loosened, by the session PROFILE. Evaluated before hooks, spec stage, rules,
autonomy, and the bypass kill-switch, so nothing an agent or user grants at a
lower layer can override the org ceiling. Includes fail-closed policy files,
flat denied-tool lists, sensitive-path floors, and a scope catalog. Wired
into PermissionEngine as an un-disableable pre-gate and auto-loaded from the
managed path at session bootstrap.
Adds disk persistence to TaskStore (atomic snapshot, load/resume, id counter
preservation) plus a retry budget: MarkFailed requeues while attempts remain
and parks tasks in a new failed state for replanning once exhausted. Requeue
resets the budget, Checkpoint stores resumable progress, and the task tools
expose attempts/lastError/checkpoint and a failed listing action.
Closes the self-improvement loop: the engine's Reflector already produced
structured WhatFailed/WhyFailed/WhatToDo lessons on tool failures, but they
were only appended to the output and never stored. Session now exposes a
Learn callback (propagated to sub-sessions) invoked after a successful
reflection, and the chat client wires it to SelfImprover.Learn so lessons
survive across sessions and feed back via ForPrompt. SelfImprover is now
thread-safe, nil-safe, and bounded at 200 entries.
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