feat: resilience, governance ceiling, and audit trail - #180
Open
Patel230 wants to merge 4 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)Verify()detects any altered or missing entry; key generated on first use.2. Governance POLICY ∩ PROFILE ceiling (
internal/governance)PermissionEngineand auto-loaded at session bootstrap.3. TaskRunner persistence + retry/replan (
internal/tool)TaskStoredisk persistence (atomic snapshot, load/resume, id-counter preservation).MarkFailedrequeues while attempts remain, parks tasks in a newfailedstate for replanning when exhausted;Requeueresets the budget;Checkpointstores resumable progress.failedlisting action.4. Persist failure reflections to the lesson store (
internal/engine,cmd/chat.go)SelfImprover.Learnwas never called.Session.Learncallback (propagated to sub-sessions) now persists them; chat wires it so lessons survive sessions and feed back viaForPrompt.SelfImprovermade thread-safe, nil-safe, bounded at 200 entries.Verification
go build ./..., fullgo test ./...,make lint, andhawk verifyall pass.internal/(lefthookforbidden-strings+ emoji audit green).