Riley Branch · Draft v0.1 · draft
Published 2026-06-24
A proposal for separating generative reasoning from versioned, executable constraints at explicit AI action boundaries.
The Logic Firewall for AI Agents
A deterministic governance layer for AI-generated work
Draft: v0.1 Prepared for: Kybercel Product Codex Date: 2026-06-24
Abstract
AI agents are moving from advisory chat interfaces into operational systems that write code, call tools, modify documents, draft regulated communications, open pull requests, and execute commands. That shift changes the risk profile of enterprise AI. The primary failure mode is no longer only that a model may produce an inaccurate answer. It is that a model may produce a plausible action that violates business logic, architecture rules, compliance obligations, security expectations, or approval workflows.
Most organizations try to control this behavior by putting more instructions into prompts. That approach does not scale. Prompt-based control is probabilistic, vendor-specific, hard to audit, and fragile under model changes. The more critical the workflow, the less acceptable it becomes to depend on a model remembering the rules.
This paper proposes the logic firewall: a deterministic governance layer that sits between AI intent and operational action. A logic firewall represents organizational rules as versioned axioms, checks generated work at explicit action boundaries, blocks or warns deterministically, and preserves audit evidence without exposing sensitive content. It does not replace human review, legal judgment, secure software practices, or model risk management. It makes those controls executable.
Product Codex is a working example of this pattern: a local-first axiom engine, CLI, MCP server, AI I/O review surface, governed runtime wrapper, workbench, and source-backed Domain Codex Packs for regulated or high-risk workflows.
Executive Summary
The enterprise AI problem is often framed as a model problem: choose the right provider, tune the prompt, retrieve better context, or evaluate outputs more carefully. Those steps matter, but they do not solve the deeper governance issue. Business rules should not live only inside prompts, because prompts are interpreted by the same probabilistic system they are meant to constrain.
Organizations need a separate layer that is:
- deterministic enough to enforce hard rules;
- local or privately deployable enough to protect sensitive context;
- source-backed enough to support compliance and audit review;
- provider-neutral enough to survive model changes;
- workflow-aware enough to know whether an AI output is merely displayed, written to a file, executed, committed, approved, or forwarded to another tool.
The logic firewall supplies that layer.
The key move is to separate reasoning from rules. Models provide generative reasoning: drafting, summarizing, transforming, planning, coding, and explaining. The logic firewall provides executable constraints: what must be present, what must not be present, which transitions require approval, which artifacts require evidence, and which action boundaries are too risky to cross without review.
For software teams, this means AI-generated code can be checked against Secure SDLC axioms before it lands. For regulated communications, advisor, healthcare, government, or financial claims can be checked against disclosure, evidence, and approval requirements before publication. For AI operations, requests and responses can be reviewed before provider execution, display, acceptance, tool forwarding, shell execution, commit, pull request creation, or workbench approval.
The result is not “AI safety” as a slogan. It is an operational pattern for AI governance: versioned rules, deterministic checks, explicit action boundaries, redaction-aware audit trails, and domain-specific policy packs.
1. The Problem: Rules Are Trapped in Prompts
Modern AI agents are increasingly capable. They can inspect repositories, generate diffs, write implementation plans, run tests, draft customer communications, summarize incidents, update policies, and call external tools. The agent is no longer just a text generator. It is becoming an operational actor.
That creates a mismatch between capability and control.
Most AI governance inside products and engineering teams still relies on some combination of:
- long system prompts;
- policy reminders;
- human review after the fact;
- static code scanners that do not understand the agent workflow;
- vendor-specific safety filters;
- informal team norms.
These controls are useful but incomplete. They suffer from a common flaw: the rules are either advisory, late, or disconnected from the exact boundary where the AI system causes change.
Prompt instructions are especially fragile. They can guide behavior, but they do not reliably enforce behavior. A prompt can say “do not modify authorization code without tests,” but the model can still produce an authorization change without tests. A prompt can say “do not make performance claims without evidence,” but the model can still draft persuasive unsupported language. A prompt can say “never expose secrets,” but the response can still include credentials, private URLs, or sensitive customer details if they were present in context.
The problem becomes worse as organizations adopt multiple AI tools. A rule written for one model, editor, coding assistant, or workflow may not transfer cleanly to another. When rules live in prompts, organizations are effectively renting their own business logic from each AI surface they use.
The enterprise needs a way to own its rules independently from the model.
2. Why Existing Controls Are Not Enough
AI governance is not a blank slate. Mature organizations already have secure development programs, compliance review, audit logs, approval workflows, incident processes, and policy documents. Public frameworks reinforce the same direction. NIST’s AI Risk Management Framework emphasizes structured approaches for managing AI risks across design, development, use, and evaluation.1 NIST’s Secure Software Development Framework provides high-level secure software practices that can be integrated into software development life cycles.2 OWASP SAMM gives organizations a model for assessing and improving software assurance.3 CISA’s secure-by-design work pushes software manufacturers toward building security into products rather than attaching it afterward.4
The gap is not that organizations lack control concepts. The gap is that those controls are often not executable inside AI-assisted workflows.
Consider a few common examples.
An engineering organization may have a rule that sensitive mutations must emit audit events. A coding agent can create a new admin route, but the rule may live in a security policy document or reviewer memory. Unless the AI-generated diff is checked before merge, the violation may not be caught.
A fintech or wealth-management team may require specific disclosures for testimonials, endorsements, hypothetical performance, or recommendation-like language. An AI writing assistant can generate a polished draft, but the compliance rule may live in a manual review checklist. Unless the draft is checked before publication or approval, the risk scales with content volume.
An SRE team may require runbooks to include detection criteria, escalation owner, rollback steps, and verification steps. An AI agent can generate a confident runbook in seconds. Unless those requirements are enforced, the artifact may look complete while being operationally weak.
A product team may require acceptance criteria, non-goals, metrics, and decision records. AI can generate a well-formatted PRD that still fails to make a testable product decision.
Static scanners and general-purpose AI evaluation tools do not fully solve this because they usually operate without the workflow context. They may see a file, a prompt, a response, or an output, but not the action boundary: is this being displayed, copied, written, executed, committed, approved, or forwarded to another system?
Governance has to happen at the boundary where intent becomes action.
3. The Logic Firewall Pattern
A logic firewall is a deterministic control layer between AI-generated intent and operational effect.
It does four things:
- It represents rules as versioned axioms.
- It evaluates generated work against those axioms.
- It gates explicit action boundaries.
- It records audit evidence in a privacy-aware way.
The term “firewall” is intentional but limited. A network firewall controls traffic across network boundaries. A logic firewall controls AI-generated work across semantic and operational boundaries. It does not merely ask whether bytes are allowed. It asks whether a proposed action violates the organization’s declared logic.
Examples:
- This diff modifies an authorization guard. Does it include required tests?
- This route creates a sensitive mutation. Does it emit an audit event?
- This query reads tenant-scoped data. Does it include an owner or tenant filter?
- This advisor communication includes a performance claim. Does it include evidence, time period, assumptions, and required disclosures?
- This generated runbook describes rollback. Does it include detection, escalation, rollback, verification, and owner fields?
- This AI response includes shell commands. Are they safe to display, copy, or execute?
- This request contains secrets or regulated customer information. Can it be forwarded to an external provider?
The logic firewall should be model-independent. It should not depend on whether the model is OpenAI, Anthropic, Google, local, or a future runtime. It should evaluate the generated artifact and the intended action boundary using rules the organization owns.
4. Axioms: Business Logic as Executable Control
An axiom is a durable rule the organization wants to preserve across tools, models, teams, and time.
In Product Codex, axioms are represented as structured, versioned rule definitions. They may be sourced from architecture decisions, internal policies, regulatory requirements, secure development expectations, compliance checklists, operational standards, or customer-specific overlays.
A good axiom has several properties:
- It has an identifier and version.
- It has a source basis.
- It applies to a known artifact type or workflow.
- It can be evaluated deterministically or semi-deterministically.
- It produces clear findings.
- It distinguishes blocking failures from warnings.
- It can be audited.
- It can be overridden only through an explicit, reviewable process where appropriate.
The goal is not to encode every human judgment. Some decisions require legal, clinical, financial, security, or executive review. The goal is to encode the rules that should not depend on a model’s memory or a reviewer’s luck.
For software delivery, initial axiom families can include:
- required calls;
- forbidden calls;
- required ownership or tenant filters;
- mutation requires audit;
- forbidden state transitions;
- forbidden patterns;
- forbidden dependencies;
- required test fixtures.
For AI I/O governance, axiom families can include:
- secrets and sensitive data handling;
- unsafe shell or production access requests;
- code-change governance;
- regulated deployment claims;
- compliance claim discipline;
- response review before display, execution, or acceptance.
For domain-specific governance, axioms can be packaged into Domain Codex Packs. A Secure SDLC pack might draw from NIST SSDF, OWASP SAMM, OWASP ASVS, and CISA secure-by-design principles. A Finance RIA communications pack might draw from SEC, eCFR, and FINRA sources. A Gov Defense evidence pack might draw from FedRAMP, CMMC, NIST SP 800-171, NIST SP 800-53, and acquisition sources.
The pack model matters because regulated and high-risk domains need source-backed rules, lifecycle states, review evidence, synthetic fixtures, disclaimers, and customer overlays. A pack is not just a folder of rules. It is a governance artifact.
5. Action Boundaries: Where Governance Becomes Real
AI systems become risky when generated content crosses an action boundary.
Product Codex models action boundaries explicitly. Representative boundaries include:
- displayed;
- copied or exported;
- written to file;
- shell command executed;
- committed;
- pull request opened;
- workbench approved;
- forwarded to tool.
This distinction is essential. A blocked response that was never shown to a user has a different risk profile from a blocked response that was streamed to the terminal before post-review could happen. A dangerous shell command included in a response is different from that command being executed. A draft compliance statement is different from an approved customer-facing communication.
The logic firewall should report whether it controls the boundary or can only observe it.
For example:
- A CLI wrapper can prevent a request from being forwarded to a runtime and can withhold buffered output before display.
- An MCP tool can report a blocked verdict, but the host application may decide whether to enforce it.
- A browser or editor extension may control some actions but not all.
- A workbench import may preserve evidence after the fact but is not a live enforcement boundary.
This avoids a common governance trap: claiming enforcement where the system only has visibility. Mature AI governance should be honest about control strength.
6. Reference Architecture
A practical logic firewall can be built as a layered system.
6.1 Core Rule Engine
The core engine owns deterministic rule semantics. It loads axioms, parses configuration, scans repositories or documents, checks diffs or artifacts, evaluates rule families, and returns normalized findings.
The core should be isolated from delivery surfaces. The CLI, MCP server, workbench, editor extension, and CI workflow should all call the same core behavior rather than duplicating rule logic.
6.2 Delivery Surfaces
Different workflows need different surfaces:
- CLI for local developer and automation workflows;
- governed runtime wrapper for AI command execution;
- MCP server for agent-client integration;
- web workbench for review queues, rule sets, approvals, remediation, and audit timelines;
- CI integration for pull requests and release gates;
- future plugins or extensions for editor and browser workflows.
The delivery surface should translate context into a shared review envelope. The core should return stable human-readable and machine-readable results.
6.3 AI I/O Review
AI I/O review evaluates both sides of an AI interaction:
- request preflight before a prompt, command, or context packet is forwarded to a provider or runtime;
- response postflight before model output is displayed, accepted, applied, executed, committed, or forwarded.
This is where the logic firewall becomes especially useful. It can stop secrets from being sent out. It can prevent unsafe responses from crossing controlled boundaries. It can require confirmation or redaction. It can preserve local audit evidence.
6.4 Runtime Adapter Registry
AI tooling is fragmented and will remain so. A logic firewall should expect multiple runtimes: Codex CLI, local shell, MCP clients, editor extensions, browser extensions, Claude CLI, Gemini CLI, internal agents, and future provider-specific surfaces.
A runtime adapter registry records capabilities and limitations. Can the runtime buffer output? Can it stream only? Can it accept a governed working directory? Can it run with a conservative environment allowlist? Can it provide structured metadata? Can it enforce before display, or only observe after display?
Without this registry, organizations risk pretending every AI surface has the same enforcement strength.
6.5 Audit and Redaction
Audit is not a byproduct. It is a first-class function.
The logic firewall should record:
- event type;
- rule and axiom IDs;
- pack ID and version where applicable;
- source basis;
- artifact hash;
- finding severity;
- verdict;
- action boundary;
- actor;
- runtime metadata;
- override justification where allowed;
- redaction classes;
- timestamps;
- related request and response event IDs.
But audit must not become a data leak. Sensitive request and response content should be captured according to explicit modes: hashes only, redacted excerpt, full redacted, or caller-supplied safe content. Raw secrets, credentials, tokens, passwords, customer financial data, protected health information, or regulated private data should not be durably stored by default.
7. Product Codex as a Working Example
Product Codex implements the logic firewall pattern as a local-first governance layer.
The current architecture includes:
- a TypeScript core package for axioms, scanner, diff review, rule evaluation, violations, AI I/O governance, redaction, action boundaries, runtime compatibility, policy packs, and Domain Codex Pack manifests;
- a CLI for repository checks, AI request and response review, governed AI runtime execution, audit persistence, and workbench sync;
- an MCP server that exposes Product Codex checks and AI governance tools to agent clients;
- a Next.js governance workbench for submissions, rule sets, findings, remediation suggestions, approvals, demo flows, audit timelines, AI I/O import, and Domain Codex Pack visibility;
- a governed runtime wrapper that can preflight AI requests, execute allowed runtime commands, capture output, review responses before display in buffered mode, and record paired request/response audit sessions.
BadgerLane, an independently built fintech application, has provided practical pressure for the pattern. The app includes onboarding, financial account aggregation, subscription billing, role-aware internal operations, advisor and admin surfaces, tenant/org management, security-sensitive authentication flows, and release-hardening work. That environment makes the governance problem concrete: rules around auth, billing entitlement, account aggregation, advisory surfaces, audit logging, route gates, and sensitive data handling are not theoretical. They are the kinds of rules AI-generated work can accidentally violate.
Product Codex does not need to be on the runtime path of the application it governs. In this independent-project model, the governed product remains separate. Product Codex acts as a development, review, CI, agent, and audit layer around generated work.
That separation is important. A logic firewall should reduce risk without becoming an availability dependency for the product being governed.
8. Domain Codex Packs
The next step is to make rule sets portable by domain.
Domain Codex Packs are source-backed rule portfolios with lifecycle state, source inventory, fixture references, overlay semantics, disclaimers, and audit metadata expectations. They allow organizations to start from a vetted baseline while retaining local overlays.
Initial high-value packs include:
- Secure SDLC / AI Code Governance;
- Finance RIA / Advisor Communications Compliance;
- Cybersecurity GRC Control Evidence;
- Government Defense / FedRAMP / CMMC Evidence;
- Healthcare Documentation Governance;
- Marketing / Brand / Communications Compliance;
- SRE Reliability.
The strongest first pack is Secure SDLC because the artifact is inspectable and the rules map well to deterministic checks. A generated diff either touches an auth guard or does not. A sensitive mutation either emits an audit event or does not. A query either includes a tenant filter or does not. A security-sensitive change either includes tests or does not.
The second strong pack is Finance RIA communications compliance because AI increases the volume and confidence of advisor communications while the review burden remains high. The pack can govern claims, disclosures, approvals, testimonials, endorsements, hypothetical performance language, and books-and-records evidence without providing financial advice.
The key constraint is source discipline. Public authoritative sources can provide source basis. Licensed or proprietary material may be cited for internal review but should not be copied or transformed into bundled rules without legal review. Pack content should use Kybercel-authored rule language with source metadata, and fixtures should be synthetic.
9. What the Logic Firewall Is Not
The logic firewall pattern is powerful, but it should not be oversold.
It is not a replacement for secure software engineering. It should complement tests, code review, dependency review, threat modeling, incident response, and secure design.
It is not a replacement for legal, medical, financial, compliance, or security judgment. It can require evidence, disclosures, approvals, or review states. It should not claim to certify compliance or make professional judgments outside its scope.
It is not a universal semantic reasoner. Some rules are deterministic. Some are probabilistic. Some require human review. The system should be explicit about which is which.
It is not a guarantee that all AI risk is controlled. It can block at boundaries it controls. It can report degraded enforcement where it only observes. It should never claim full enforcement over surfaces it cannot govern.
It is not only a content filter. A content filter checks text. A logic firewall checks text, code, metadata, workflow state, action boundaries, source basis, and audit requirements.
10. Implementation Roadmap
Organizations can adopt the pattern incrementally.
Phase 1: Start With Local Deterministic Checks
Begin with repository, diff, and document checks that can run locally. Focus on rules with low ambiguity:
- required tests for high-risk changes;
- forbidden secrets and production values;
- required tenant or owner filters;
- required audit calls;
- forbidden dependencies;
- required approval metadata;
- required document sections.
This phase proves value without depending on a hosted service or model provider.
Phase 2: Add AI Request and Response Review
Introduce request preflight and response postflight review around AI-assisted workflows. Start in advisory mode, then enforce only the rules with strong confidence and clear remediation.
Capture local audit events with redacted content. Pair request and response events into sessions so teams can reconstruct governed interactions without storing sensitive raw data.
Phase 3: Gate Action Boundaries
Move from passive findings to controlled boundaries:
- block unsafe requests before provider execution;
- withhold unsafe buffered responses before display;
- require confirmation for risky but allowable actions;
- prevent blocked content from being written, executed, committed, or approved where the integration controls that boundary;
- report degraded state where enforcement is not technically possible.
Phase 4: Introduce Domain Packs
Package repeatable domain rules into source-backed packs. Use lifecycle states such as research, MVP candidate, pilot, commercial, watch, and deferred.
Require SME, legal, and compliance review evidence before regulated-domain packs are marked pilot or commercial. Support customer overlays without silently weakening default rules.
Phase 5: Connect to Workbench and CI
Make findings visible in review queues, pull requests, approval workflows, and audit timelines. Allow teams to inspect rule source, remediation, overrides, and evidence.
The goal is not to create another dashboard. The goal is to make AI-generated work reviewable in the same operational places where work already moves.
11. Evaluation Criteria
A logic firewall should be evaluated on operational qualities, not only model metrics.
Useful questions include:
- Can rules be traced to source basis?
- Can rule changes be versioned and reviewed?
- Can the system run locally or in a private environment?
- Can it distinguish warn, block, require redaction, require confirmation, and review failure?
- Can it explain findings clearly enough for a human or agent to remediate?
- Can it preserve audit evidence without storing raw sensitive content?
- Can it report which action boundary was controlled?
- Can it honestly report degraded enforcement?
- Can the same core rule semantics be reused by CLI, MCP, CI, workbench, and future extensions?
- Can customer overlays add, disable, tighten, or weaken rules with explicit rationale?
- Can regulated packs require SME, legal, and compliance review evidence?
These criteria are more important than whether the system uses a particular model, vector database, graph database, or agent framework. The architecture should remain open to those implementation choices, but the governance contract should stay stable.
12. Conclusion
AI agents make software and business operations faster. That speed is valuable, but it also compresses the time between idea and action. The faster an agent can act, the more important it becomes to govern the boundary where generated work becomes operational reality.
Prompts alone are not enough. They are a useful instruction surface, but they are too soft, too vendor-specific, and too hard to audit as the primary home for enterprise rules.
The logic firewall gives organizations a more durable pattern. It separates reasoning from rules. It turns business logic into versioned axioms. It checks generated work deterministically where possible. It gates action boundaries. It preserves audit evidence. It supports local-first and provider-neutral deployment. It gives domain experts a way to package source-backed requirements without embedding them in every prompt.
The future of enterprise AI governance will not be won by the longest system prompt. It will be won by teams that can make their rules executable.
References
Footnotes
-
NIST, “AI Risk Management Framework,” official source ↩
-
NIST Special Publication 800-218, “Secure Software Development Framework (SSDF) Version 1.1,” official source ↩
-
OWASP, “Software Assurance Maturity Model,” official source ↩
-
CISA, “Software Must Be Secure by Design, and Artificial Intelligence Is No Exception,” official source ↩