Skip to content

fix: state persistence path, enforcer blocked logic, console bleed, test fixes, subagent enforcement#12

Merged
htafolla merged 2 commits intomasterfrom
fix/logging-persistence-enforcer-overhead
Mar 29, 2026
Merged

fix: state persistence path, enforcer blocked logic, console bleed, test fixes, subagent enforcement#12
htafolla merged 2 commits intomasterfrom
fix/logging-persistence-enforcer-overhead

Conversation

@htafolla
Copy link
Copy Markdown
Owner

Changes

1. State persistence path fix

  • StateManager default was .opencode/state (directory), causing writeFileSync to create a file named state instead of writing to state.json. Changed to .opencode/state/state.json.
  • Added resolveStateFilePath() helper to config-paths.ts.

2. Enforcer blocked logic cleanup

  • blocked was only set if error contained "required" or "violation" strings, letting real errors slip through. Simplified to: any error = blocked.
  • codexEnforcement now explicitly sets blocked based on combined errors instead of relying on spread of validationResult.
  • contextAnalysisValidation was double-blocking — removed redundant check.

3. Console.* bleed-through elimination

  • Replaced all console.log/warn/error in framework runtime code with frameworkLogger.log() across 30+ files.
  • frameworkLogger writes to file only (.opencode/logs/framework/), never outputs to console.
  • .catch(console.error).catch(() => {}) for process-level handlers.
  • Plugin file strray-codex-injection.js updated.

4. Test fixes

  • 6 tests asserting console.* calls updated to spy on frameworkLogger.log() instead.

5. Subagent (delegate_task) enforcement — Hermes plugin v2.2

  • Subagents bypass all StringRay hooks. Added post-hoc enforcement via snapshot-and-diff.
  • pre_tool_call: snapshots git diff --name-only HEAD
  • post_tool_call: re-diffs, validates all new source changes through bridge quality gate
  • Stats tracked: dispatches, validations, blocks (visible via /strray stats)

Verification

  • ✅ 127/127 test files (2399/2399 tests) pass
  • ✅ 5/5 pipelines pass
  • ✅ Zero TypeScript errors
  • ✅ Dist rebuilt clean

…est fixes, subagent enforcement

1. State persistence path fix
   - StateManager default was '.opencode/state' (directory), causing
     writeFileSync to create a file named 'state' instead of writing
     to state.json. Changed to '.opencode/state/state.json'.
   - Added resolveStateFilePath() helper to config-paths.ts.

2. Enforcer blocked logic cleanup
   - Blocked was only set if error contained 'required' or 'violation'
     strings, letting real errors (e.g. 'missing semicolon') slip through.
     Simplified to: any error = blocked.
   - codexEnforcement now explicitly sets blocked based on combined errors
     instead of relying on spread of validationResult (which had its own
     inconsistent blocked calc).
   - contextAnalysisValidation was double-blocking (|| contextIssues.errors)
     when ruleValidation already covered it. Removed redundant check.

3. Console.* bleed-through elimination
   - Replaced all console.log/warn/error in framework runtime code with
     frameworkLogger.log() across 30+ files: core, security, processors,
     postprocessor, performance, mcps (connections + 15 knowledge-skills
     servers), integrations, utils, validation.
   - frameworkLogger writes to file only (.opencode/logs/framework/),
     never outputs to console, preventing noise in OpenCode agent UI.
   - .catch(console.error) patterns replaced with .catch(() => {}) for
     process-level handlers where frameworkLogger may not be available.
   - .opencode/plugins/strray-codex-injection.js: replaced console.warn
     with frameworkLogger for config-paths and system-prompt-generator
     load failures.

4. Test fixes
   - 6 tests were asserting console.log/warn calls that no longer fire
     after the console.* cleanup. Updated to spy on frameworkLogger.log()
     instead: EscalationEngine (1), SuccessHandler (4), security-headers (1).

5. Subagent (delegate_task) enforcement in Hermes plugin
   - Subagents bypass all StringRay hooks since they run in isolated
     contexts. Added post-hoc enforcement via snapshot-and-diff:
       - pre_tool_call: snapshots git diff --name-only HEAD
       - post_tool_call: re-diffs, validates all new source changes
         through the bridge quality gate
   - Blocked files logged as [subagent-validate] BLOCKED in activity.log
   - Stats tracked: dispatches, validations, blocks (visible via /strray stats)
   - Plugin v2.1 → v2.2. Canonical source: src/integrations/hermes-agent/.

All 127 test files (2399 tests) pass. All 5 pipelines pass. Zero TS errors.
@htafolla htafolla merged commit 044a0e3 into master Mar 29, 2026
16 of 17 checks passed
@htafolla htafolla deleted the fix/logging-persistence-enforcer-overhead branch March 31, 2026 15:40
htafolla added a commit that referenced this pull request Apr 2, 2026
- Add validators for terms #12, #19, #16, #3, #13 (early returns, small functions, DRY, over-engineering, error boundaries)
- Wire processor-pipeline MCP to use CodexLoader for richer validation
- Fix orchestrator config loading and conflict resolution wiring
- Total 16 active validators now (was 11)
htafolla added a commit that referenced this pull request Apr 2, 2026
- Add skipped tests for validators #12, #19, #16, #3, #13 (need real codex.json)
- Add MCP integration tests for codex-loader wiring
- Tests validate CodexLoader and processor-pipeline use the same rules
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