<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<rfc
  xmlns:xi="http://www.w3.org/2001/XInclude"
  category="info"
  docName="draft-aegisfs-secdispatch-rats-00"
  ipr="trust200902"
  submissionType="IETF"
  xml:lang="en"
  tocInclude="true"
  tocDepth="4"
  symRefs="true"
  sortRefs="true"
  version="3">


  <front>

    <title abbrev="AegisFS Architecture">
      AegisFS: AI-Driven Programmable Secure File Runtime and Intelligent
      Workspace Architecture with Octal OpCode Processing and Policy-Driven
      Language Architecture
    </title>

    <seriesInfo name="Internet-Draft" value="draft-aegisfs-secdispatch-rats-00"/>

    <author fullname="Sripad" initials="S.">
      <organization>AegisFS Project</organization>
      <address>
        <email>sripadkarthik@gmail.com</email>
      </address>
    </author>

    <date year="2026" month="August" day="28"/>

    <area>Security</area>
    <workgroup>SECDISPATCH / RATS</workgroup>

    <keyword>filesystem</keyword>
    <keyword>security</keyword>
    <keyword>policy</keyword>
    <keyword>opcode</keyword>
    <keyword>attestation</keyword>
    <keyword>AI</keyword>
    <keyword>behavioral analysis</keyword>
    <keyword>capability</keyword>
    <keyword>lifecycle</keyword>
    <keyword>provenance</keyword>

    <abstract>
      <t>
        This document specifies AegisFS, a programmable secure file and folder
        runtime that transforms ordinary filesystem objects into intelligent,
        policy-driven, state-aware, execution-aware, and behavior-aware security
        objects.
      </t>
      <t>
        This draft introduces two novel technical contributions:
      </t>
      <ol>
        <li>
          The Octal to OpCode (OtO) Framework: a real-time processing model
          wherein all file operations, state transitions, and intent declarations
          are compiled into a structured 9-bit octal instruction set enabling
          hardware-accelerated, microsecond-latency policy enforcement in the
          runtime kernel.
        </li>
        <li>
          The Aegis Policy Language (APL): a next-generation, policy-driven
          programming architecture featuring custom-defined keywords, strongly
          typed identifiers, and syntax-based operation analysis where the policy
          definition IS the executable architecture. An operation that cannot be
          expressed in valid APL syntax cannot produce a valid OtO opcode and
          therefore cannot execute.
        </li>
      </ol>
      <t>
        This document is submitted for consideration by the SECDISPATCH and
        RATS Working Groups of the IETF.
      </t>
    </abstract>

  </front>


  <middle>

    <section anchor="intro" numbered="true" toc="default">
      <name>Introduction</name>

      <section anchor="motivation" numbered="true" toc="default">
        <name>Motivation and Problem Statement</name>
        <t>
          Modern computing environments demand security primitives that go far
          beyond traditional discretionary or mandatory access control. Existing
          filesystem security models treat files and directories as passive,
          path-identified storage to which permissions are applied statically.
        </t>
        <t>This model is fundamentally inadequate for the following reasons:</t>
        <ol type="a">
          <li>
            Identity is not context-aware. A permission granted to a user applies
            regardless of device, application, network state, or risk context.
          </li>
          <li>
            Access decisions are static. Permissions do not respond to behavioral
            anomalies, ransomware-pattern writes, or data exfiltration flows.
          </li>
          <li>
            Operations are opaque. The filesystem has no concept of the intent
            behind a write or delete operation.
          </li>
          <li>
            Files have no relationships. Dependencies, provenance, and data flow
            relationships are invisible to the security model.
          </li>
          <li>
            There is no execution-level governance. A binary placed in a directory
            can be executed without analysis or sandboxing.
          </li>
        </ol>
        <t>
          AegisFS addresses all of these gaps by replacing the passive file
          abstraction with a governed, intelligent object model where every file
          and folder is a first-class security principal.
        </t>
      </section>

      <section anchor="goals" numbered="true" toc="default">
        <name>Goals and Non-Goals</name>
        <t>Goals:</t>
        <ul>
          <li>Define a portable, extensible model for intelligent file objects.</li>
          <li>
            Specify the Octal to OpCode (OtO) framework for real-time policy
            enforcement with minimal latency overhead.
          </li>
          <li>
            Define the Aegis Policy Language (APL) as a policy-driven programming
            architecture where policy syntax defines executable behavior.
          </li>
          <li>
            Specify lifecycle, transaction, provenance, dependency, resource,
            collaborative, and AI behavioral models for filesystem objects.
          </li>
        </ul>
        <t>Non-Goals:</t>
        <ul>
          <li>
            This document does not specify a general-purpose filesystem protocol
            such as an NFS or SMB extension.
          </li>
          <li>
            This document does not specify cryptographic algorithm suites.
          </li>
          <li>
            This document does not address cloud storage APIs directly.
          </li>
        </ul>
      </section>

      <section anchor="dispatch" numbered="true" toc="default">
        <name>Working Group Dispatch Rationale</name>
        <t>
          <strong>SECDISPATCH:</strong> AegisFS introduces a broad, multi-domain
          security architecture touching access control, behavioral analysis,
          attestation, and policy enforcement. SECDISPATCH is the appropriate
          initial venue to evaluate which sub-components should be advanced to
          dedicated Working Groups such as SACM, RATS, OAUTH, or a potential
          new WG.
        </t>
        <t>
          <strong>RATS (Remote ATtestation procedureS):</strong> The AegisFS
          Identity and Context Engine relies on device trust attestation and
          application identity verification that align directly with the RATS
          architecture <xref target="RFC9334"/>. The Secure Object Identity model,
          contextual access chain, and capability token attestation are strong
          candidates for alignment with RATS Entity Attestation Tokens (EAT).
        </t>
      </section>
    </section>


    <section anchor="terminology" numbered="true" toc="default">
      <name>Terminology and Conventions</name>
      <t>
        The key words <bcp14>MUST</bcp14>, <bcp14>MUST NOT</bcp14>,
        <bcp14>REQUIRED</bcp14>, <bcp14>SHALL</bcp14>, <bcp14>SHALL NOT</bcp14>,
        <bcp14>SHOULD</bcp14>, <bcp14>SHOULD NOT</bcp14>,
        <bcp14>RECOMMENDED</bcp14>, <bcp14>MAY</bcp14>, and
        <bcp14>OPTIONAL</bcp14> in this document are to be interpreted as
        described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/>.
      </t>
      <dl>
        <dt>AegisFS Object (AFO):</dt>
        <dd>
          A file or folder registered with the AegisFS runtime and elevated from
          a passive storage item to a governed security object with identity,
          policy, lifecycle state, and behavioral profile.
        </dd>
        <dt>Octal to OpCode (OtO) Framework:</dt>
        <dd>
          The real-time instruction encoding system used by AegisFS to compile
          all operations, state transitions, and intents into a 9-bit octal
          instruction for hardware-accelerated processing.
        </dd>
        <dt>Aegis Policy Language (APL):</dt>
        <dd>
          The policy-driven DSL used to define workspace security boundaries,
          access rules, resource limits, execution constraints, and lifecycle
          governance. APL is the primary programming interface for AegisFS.
        </dd>
        <dt>Policy-Driven Architecture (PDA):</dt>
        <dd>
          An architectural model in which the policy definition, expressed in
          APL, is compiled directly into executable runtime behavior. No
          operation can execute unless a valid APL policy permits it.
        </dd>
        <dt>Capability Token (CT):</dt>
        <dd>
          A short-lived, cryptographically bound permission artifact granting a
          specific principal the right to perform a specific operation on a
          specific object for a constrained duration.
        </dd>
        <dt>Digital Twin:</dt>
        <dd>
          A runtime model of the expected structural and behavioral state of a
          workspace or file object, used for anomaly detection by comparing
          expected state against observed state.
        </dd>
        <dt>SCSWP:</dt>
        <dd>
          Secure Collaborative Staging Workspace Protocol — the sub-protocol
          managing multi-user collaborative access to protected workspaces
          through controlled staging areas.
        </dd>
        <dt>Lifecycle State:</dt>
        <dd>
          One of eight defined states in the AegisFS object state machine:
          CREATED, STAGING, ANALYZING, APPROVED, ACTIVE, QUARANTINED, ARCHIVED,
          DESTROYED.
        </dd>
        <dt>Intent Declaration:</dt>
        <dd>
          A structured, pre-operation declaration by a principal indicating the
          intended operation category, expected file scope, and expected
          behavioral profile.
        </dd>
      </dl>
    </section>


    <section anchor="architecture" numbered="true" toc="default">
      <name>High-Level Architecture</name>

      <section anchor="system-layers" numbered="true" toc="default">
        <name>System Layers</name>
        <t>The AegisFS system is organized into four horizontal layers:</t>
        <ol>
          <li>
            <strong>Application / Web UI Layer:</strong> The user-facing interface.
            Never directly exposed to the filesystem.
          </li>
          <li>
            <strong>Secure Access Gateway:</strong> Handles authentication,
            session management, secure HTTPS/TLS API, and tunnel management.
          </li>
          <li>
            <strong>AegisFS Runtime:</strong> Contains the Programmable Folder
            Engine, Identity Engine, Policy/ACL Engine, Capability Engine,
            Resource Engine, Transaction Engine, Dependency Engine, Data Flow
            Engine, Collaboration/SCSWP Engine, Provenance Engine, AI
            Intelligence Layer, Decision Engine, and the OtO OpCode Execution Bus.
          </li>
          <li>
            <strong>OS / Filesystem Adapter:</strong> Interfaces with the
            underlying OS security primitives, storage, and filesystem.
          </li>
        </ol>
      </section>

      <section anchor="file-object-model" numbered="true" toc="default">
        <name>The Intelligent File Object Model</name>
        <t>
          Every file registered with AegisFS is elevated to an Intelligent File
          Object (IFO). Unlike a traditional file which is identified only by
          path, an IFO carries the following mandatory attributes:
        </t>
        <ul>
          <li>Object ID (UUID v7, immutable from creation)</li>
          <li>Structured Metadata block</li>
          <li>Verified Owner identity</li>
          <li>Dynamic Contextual ACL</li>
          <li>Active Capability Token rules</li>
          <li>Security Classification (PUBLIC through CRITICAL)</li>
          <li>Lifecycle State (from the 8-state FSM)</li>
          <li>Content Integrity Hash (SHA-256 or SHA-3-256)</li>
          <li>Immutable Version History chain</li>
          <li>Provenance lineage graph</li>
          <li>Dependency map</li>
          <li>Resource consumption profile</li>
          <li>Behavioral baseline profile</li>
          <li>Data Flow Policy</li>
          <li>AI Risk Profile (score 0-100)</li>
          <li>Append-only Audit History</li>
        </ul>
      </section>

      <section anchor="folder-structure" numbered="true" toc="default">
        <name>Workspace Folder Structure</name>
        <t>
          A conformant AegisFS workspace <bcp14>MUST</bcp14> maintain the
          following logical structure:
        </t>
        <artwork name="" type="" align="left" alt=""><![CDATA[
/project
|
+-- .aegis/
|   +-- metadata/       (Object metadata store)
|   +-- policies/       (Compiled APL policy bundles)
|   +-- acl/            (ACL definitions)
|   +-- capabilities/   (Active capability tokens)
|   +-- lifecycle/      (State machine state records)
|   +-- transactions/   (Transaction journals)
|   +-- provenance/     (Provenance graphs)
|   +-- dependencies/   (Dependency maps)
|   +-- snapshots/      (Pre-operation snapshots)
|   +-- intelligence/   (AI model outputs, risk profiles)
|   +-- audit/          (Append-only tamper-evident log)
|
+-- staging/
|   +-- user_A/
|   +-- user_B/
|
+-- active/
+-- immutable/
+-- quarantine/
+-- archive/
        ]]></artwork>
      </section>
    </section>

    <section anchor="oto-framework" numbered="true" toc="default">
      <name>Octal to OpCode (OtO) Framework</name>

      <section anchor="oto-rationale" numbered="true" toc="default">
        <name>Design Rationale</name>
        <t>
          String-based or JSON-based intent descriptions impose unacceptable
          latency in high-throughput real-time security enforcement. Parsing a
          JSON intent descriptor may take hundreds of microseconds; policy
          enforcement decisions <bcp14>MUST</bcp14> complete in microseconds to
          avoid becoming a denial-of-service vector.
        </t>
        <t>
          The OtO Framework solves this by compiling all intents, states, and
          domain contexts into a single 9-bit octal integer at policy compile
          time. The runtime processes all enforcement decisions using bitwise
          operations on this compact opcode, leveraging hardware-level
          instruction pipelines and CPU branch predictors with O(1) jump-table
          dispatch.
        </t>
        <t>
          OtO opcodes are immutable once compiled. A change in policy requires
          recompilation and re-issuance of all affected opcodes, providing a
          strong auditability boundary.
        </t>
      </section>

      <section anchor="oto-structure" numbered="true" toc="default">
        <name>OpCode Bit Field Structure</name>
        <t>
          The OtO OpCode is a 9-bit value expressed in octal notation with three
          3-bit fields:
        </t>
        <artwork name="" type="" align="left" alt=""><![CDATA[
  Bit positions:  [8 7 6] [5 4 3] [2 1 0]
                  ------- ------- -------
                  DOMAIN  STATE   INTENT

  Octal notation: 0o X Y Z
  Where:
    X = Domain field  (bits 8:6)  -- What engine is acting
    Y = State field   (bits 5:3)  -- Current object lifecycle state
    Z = Intent field  (bits 2:0)  -- Operation being requested

  Maximum representable operations: 8 x 8 x 8 = 512 unique opcodes.

  Example: 0o241
    X = 2  (Policy/ACL Domain)
    Y = 4  (ACTIVE lifecycle state)
    Z = 1  (WRITE intent)
  --> Policy engine evaluating a WRITE on an ACTIVE object.
        ]]></artwork>
      </section>

      <section anchor="oto-domain" numbered="true" toc="default">
        <name>Domain Codes (X Field)</name>
        <table align="center">
          <thead>
            <tr>
              <th>Code</th>
              <th>Domain Name</th>
              <th>Description</th>
            </tr>
          </thead>
          <tbody>
            <tr><td>0o0xx</td><td>KERNEL / SYSTEM</td><td>Kernel-level and OS primitives</td></tr>
            <tr><td>0o1xx</td><td>METADATA</td><td>Metadata read/write operations</td></tr>
            <tr><td>0o2xx</td><td>POLICY / ACL</td><td>Policy evaluation and ACL checks</td></tr>
            <tr><td>0o3xx</td><td>TRANSACTION ENGINE</td><td>Commit, rollback, stage operations</td></tr>
            <tr><td>0o4xx</td><td>CAPABILITY ENGINE</td><td>Token issue, validate, revoke</td></tr>
            <tr><td>0o5xx</td><td>AI / INTELLIGENCE</td><td>Static, dynamic, behavioral ops</td></tr>
            <tr><td>0o6xx</td><td>PROVENANCE / DEPENDENCY</td><td>Graph reads and writes</td></tr>
            <tr><td>0o7xx</td><td>FORENSICS / AUDIT</td><td>Audit log writes and queries</td></tr>
          </tbody>
        </table>
      </section>

      <section anchor="oto-state" numbered="true" toc="default">
        <name>Object State Codes (Y Field)</name>
        <table align="center">
          <thead>
            <tr>
              <th>Code</th>
              <th>State Name</th>
              <th>Description</th>
            </tr>
          </thead>
          <tbody>
            <tr><td>0ox0x</td><td>CREATED</td><td>Object registered, not yet staged</td></tr>
            <tr><td>0ox1x</td><td>STAGING</td><td>In staging workspace, unvalidated</td></tr>
            <tr><td>0ox2x</td><td>ANALYZING</td><td>Under static or AI analysis</td></tr>
            <tr><td>0ox3x</td><td>APPROVED</td><td>Analysis passed, pending activation</td></tr>
            <tr><td>0ox4x</td><td>ACTIVE</td><td>In production, fully governed</td></tr>
            <tr><td>0ox5x</td><td>QUARANTINED</td><td>Restricted due to anomaly or policy failure</td></tr>
            <tr><td>0ox6x</td><td>ARCHIVED</td><td>Read-only, end-of-life</td></tr>
            <tr><td>0ox7x</td><td>DESTROYED</td><td>Scheduled for cryptographic erasure</td></tr>
          </tbody>
        </table>
      </section>

      <section anchor="oto-intent" numbered="true" toc="default">
        <name>Operation Intent Codes (Z Field)</name>
        <table align="center">
          <thead>
            <tr>
              <th>Code</th>
              <th>Intent Name</th>
              <th>Description</th>
            </tr>
          </thead>
          <tbody>
            <tr><td>0oxx0</td><td>READ</td><td>Content or metadata read operation</td></tr>
            <tr><td>0oxx1</td><td>WRITE</td><td>Content modification</td></tr>
            <tr><td>0oxx2</td><td>LOCK</td><td>Shared, exclusive, or transaction lock</td></tr>
            <tr><td>0oxx3</td><td>SNAPSHOT</td><td>Point-in-time snapshot creation</td></tr>
            <tr><td>0oxx4</td><td>ROLLBACK</td><td>Restore to prior snapshot or version</td></tr>
            <tr><td>0oxx5</td><td>COMMIT</td><td>Finalize and promote a transaction</td></tr>
            <tr><td>0oxx6</td><td>ELEVATE</td><td>Privilege escalation request</td></tr>
            <tr><td>0oxx7</td><td>DESTROY</td><td>Secure deletion or cryptographic erasure</td></tr>
          </tbody>
        </table>
      </section>

      <section anchor="oto-examples" numbered="true" toc="default">
        <name>OpCode Encoding Examples</name>
        <table align="center">
          <thead>
            <tr>
              <th>OpCode</th>
              <th>Scenario Description</th>
              <th>Decision Route</th>
            </tr>
          </thead>
          <tbody>
            <tr><td>0o241</td><td>Policy engine WRITE on ACTIVE object</td><td>ACL + Capability check</td></tr>
            <tr><td>0o340</td><td>Transaction engine READ in STAGING</td><td>Staging read handler</td></tr>
            <tr><td>0o355</td><td>Transaction COMMIT in QUARANTINE</td><td>DENY (invalid state)</td></tr>
            <tr><td>0o520</td><td>AI READ on ANALYZING object</td><td>Analysis pipeline</td></tr>
            <tr><td>0o471</td><td>Capability engine WRITE on ACTIVE</td><td>Token validation</td></tr>
            <tr><td>0o100</td><td>Metadata READ on CREATED object</td><td>Always permitted</td></tr>
            <tr><td>0o047</td><td>Kernel DESTROY on ARCHIVED object</td><td>Policy + Human Approval</td></tr>
            <tr><td>0o700</td><td>Forensics READ (audit query)</td><td>Audit chain required</td></tr>
          </tbody>
        </table>
      </section>

      <section anchor="oto-pipeline" numbered="true" toc="default">
        <name>Real-Time Execution Pipeline</name>
        <t>
          When a principal requests an operation, the OtO pipeline executes the
          following steps:
        </t>
        <ol>
          <li>
            <strong>CONTEXT CAPTURE:</strong> Capture principal identity, device
            attestation, session token, application identity, and timestamp.
          </li>
          <li>
            <strong>OPCODE RESOLUTION:</strong> Resolve domain from operation
            type, query current object state from lifecycle engine, encode intent.
            Construct: 0o[D][S][I].
          </li>
          <li>
            <strong>OPCODE DISPATCH:</strong> Feed opcode to jump table in O(1)
            time. The jump table routes to the appropriate enforcement handler.
          </li>
          <li>
            <strong>POLICY EVALUATION:</strong> Handler evaluates dynamic ACL
            conditions, capability tokens, resource budgets, and AI risk scores
            against the compiled APL policy bundle.
          </li>
          <li>
            <strong>DECISION EMIT:</strong> One of: ALLOW | RESTRICT | STAGE |
            SANDBOX | QUARANTINE | DENY | REQUIRE_APPROVAL.
          </li>
          <li>
            <strong>AUDIT RECORD:</strong> Write atomic audit record regardless
            of decision outcome: {timestamp, opcode, principal_id, object_id,
            decision}.
          </li>
        </ol>
      </section>

      <section anchor="oto-faults" numbered="true" toc="default">
        <name>OpCode Fault Handling</name>
        <t>
          If an opcode corresponds to a state transition that is invalid per the
          lifecycle state machine (e.g., 0o355 — COMMIT while QUARANTINED), the
          OtO pipeline <bcp14>MUST</bcp14>:
        </t>
        <ol type="a">
          <li>Immediately return DENY without further evaluation.</li>
          <li>Write a fault audit record with the malformed opcode.</li>
          <li>Increment the principal's anomaly score.</li>
          <li>Notify the behavioral risk engine.</li>
        </ol>
      </section>
    </section>

        
    <section anchor="apl" numbered="true" toc="default">
      <name>Aegis Policy Language (APL) — Policy-Driven Architecture</name>

      <section anchor="apl-philosophy" numbered="true" toc="default">
        <name>Language Design Philosophy</name>
        <t>
          APL is a next-generation, statically typed, declarative policy
          programming language. It is NOT a configuration format — it is a
          programming language where the source code defines the complete
          operational and security architecture of a workspace.
        </t>
        <t>
          <strong>Core Principle:</strong> An operation that does not have a
          valid, syntactically correct APL expression granting it permission
          cannot produce a valid OtO opcode. Policy definition IS execution
          authorization.
        </t>
        <t>APL has the following design properties:</t>
        <ol type="a">
          <li>
            <strong>Declarative:</strong> Policies express WHAT is permitted,
            not HOW to enforce it. The runtime translates declarations to OtO
            opcodes.
          </li>
          <li>
            <strong>Strongly typed:</strong> All identifiers have declared types;
            type mismatches are compilation errors, not runtime failures.
          </li>
          <li>
            <strong>Deterministic:</strong> Given the same policy and context,
            APL <bcp14>MUST</bcp14> always produce the same OtO opcode and
            enforcement decision.
          </li>
          <li>
            <strong>Non-Turing-complete:</strong> APL deliberately excludes loops
            and arbitrary computation. All policies terminate in bounded time.
          </li>
          <li>
            <strong>Auditable:</strong> Every APL compilation event
            <bcp14>MUST</bcp14> be logged with the policy hash, compiler version,
            and resulting opcode set.
          </li>
        </ol>
      </section>

      <section anchor="apl-keywords" numbered="true" toc="default">
        <name>Custom Keywords</name>
        <t>
          APL defines the following reserved keywords that
          <bcp14>MUST NOT</bcp14> be used as identifiers:
        </t>
        <t>
          <strong>Primary Structural Keywords:</strong>
          workspace, domain, group, object, intent
        </t>
        <t>
          <strong>Configuration Block Keywords:</strong>
          classification, storage, access, resources, execution,
          lifecycle, dataflow, capability, ai
        </t>
        <t>
          <strong>Condition Keywords:</strong>
          if, unless, when, requires, permits, denies, elevates
        </t>
        <t>
          <strong>Value Constants:</strong>
          true, false, null, required, conditional, optional,
          critical, restricted, confidential, internal, public,
          allow, deny, stage, sandbox, quarantine, restrict,
          read, write, execute, audit, lock, snapshot,
          commit, rollback, destroy, approve, reject
        </t>
      </section>

      <section anchor="apl-types" numbered="true" toc="default">
        <name>Custom Identifiers and Types</name>
        <table align="center">
          <thead>
            <tr>
              <th>Type Name</th>
              <th>Description</th>
            </tr>
          </thead>
          <tbody>
            <tr><td>Principal</td><td>A human user, service account, or device identity</td></tr>
            <tr><td>PrincipalGroup</td><td>A named collection of Principals</td></tr>
            <tr><td>FileObject</td><td>An AegisFS-governed file or directory</td></tr>
            <tr><td>Classification</td><td>An enumerated data sensitivity level</td></tr>
            <tr><td>Permission</td><td>An enumerated operation type</td></tr>
            <tr><td>Capability</td><td>A time-bound, scoped permission token definition</td></tr>
            <tr><td>ResourceLimit</td><td>A quantified resource constraint</td></tr>
            <tr><td>LifecycleState</td><td>An enumerated lifecycle state value</td></tr>
            <tr><td>RiskThreshold</td><td>An integer 0-100 representing an AI risk score</td></tr>
            <tr><td>Duration</td><td>A time duration (e.g., 10m, 1h, 30d)</td></tr>
            <tr><td>Extension</td><td>A file extension string (e.g., ".c", ".json")</td></tr>
            <tr><td>OpCode</td><td>A compiled 9-bit octal opcode reference</td></tr>
          </tbody>
        </table>
      </section>

      <section anchor="apl-compilation" numbered="true" toc="default">
        <name>APL Compilation Model</name>
        <t>
          APL source <bcp14>MUST</bcp14> be compiled before deployment.
          The compilation pipeline:
        </t>
        <artwork name="" type="" align="left" alt=""><![CDATA[
APL Source File
     |
     v
[LEXER]
  Tokenizes source into keyword/identifier/literal stream.
  Rejects: unknown keywords, type mismatches.
     |
     v
[PARSER]
  Builds Abstract Syntax Tree (AST).
  Validates: grammar rules, block nesting, required fields.
     |
     v
[SEMANTIC ANALYZER]
  Validates: type correctness, group references,
  resource limit units, risk score ranges (0-100).
     |
     v
[OPCODE EMITTER]
  Translates each policy permission into the set of OtO
  opcodes that it authorizes.
     |
     v
[POLICY BUNDLE]
  Cryptographically signed {AST + OpCode Authorization Table}.
  Written to .aegis/policies/
        ]]></artwork>
        <t>
          Compilation <bcp14>MUST</bcp14> fail with a descriptive error if:
        </t>
        <ul>
          <li>A keyword is used in an invalid syntactic position.</li>
          <li>A PrincipalGroup is referenced but not defined.</li>
          <li>A resource limit value has an ambiguous or missing unit.</li>
          <li>
            An intent block references a permission not granted in the parent
            access block.
          </li>
          <li>
            A capability expires before its minimum use count can be reached.
          </li>
        </ul>
      </section>

      <section anchor="apl-translation" numbered="true" toc="default">
        <name>APL to OtO OpCode Translation</name>
        <t>
          The APL compiler generates an opcode authorization table during
          compilation. Each table entry maps:
        </t>
        <artwork name="" type="" align="left" alt=""><![CDATA[
  (PrincipalGroup, ObjectPattern, Permission, StateConstraint)
  --> set of authorized OtO opcodes

  Example:
    APL rule:
      access {
          developers = [read, write]
          if file_state = active
      }

    Compiled to authorized opcodes: {0o240, 0o241}
    (Policy domain, ACTIVE state, READ + WRITE)

  At runtime, developer requests WRITE on ACTIVE object:
    Requested opcode : 0o241
    Table lookup     : 0o241 in {0o240, 0o241} -> MATCH -> ALLOW
        ]]></artwork>
      </section>

      <section anchor="apl-example" numbered="true" toc="default">
        <name>Full APL Example</name>
        <t>
          The following is a complete, production-grade APL workspace policy:
        </t>
        <sourcecode type="apl"><![CDATA[
workspace Banking_Project {

    classification = critical

    storage {
        allowed_extensions = [".c", ".h", ".json", ".toml"]
        max_file_size      = 100MB
        max_workspace_size = 20GB
        immutable          = false
    }

    access {
        developers    = [read, write]
        security_team = [read, audit]
        admin         = [read, write, execute, approve]
        ci_system     = [read, execute]
        when device_trusted = true
        when session_valid  = true
    }

    resources {
        max_memory    = 2GB
        max_cpu       = 40%
        max_io        = 200MBps
        max_network   = 50MBps
        max_processes = 20
        max_handles   = 500
    }

    execution {
        static_analysis  = required
        dynamic_analysis = conditional
        sandbox_on_risk  = true
        risk_threshold   = 60
        approved_apps    = [AegisEditor, AegisCompiler, AegisBuild]
    }

    lifecycle {
        staging_required  = true
        approval_required = true
        auto_archive      = 365d
        auto_destroy      = 2555d
    }

    dataflow {
        permits = [AegisWorkspace, SecureExport]
        denies  = [ExternalDrive, PublicCloud, Email]
    }

    ai {
        behavioral_baseline = required
        anomaly_threshold   = 75
        digital_twin        = enabled
    }

    capability write_cap {
        grants    = [write]
        on_object = "active/*"
        expires   = 10m
        max_uses  = 5
        principal = developers
    }

    object "immutable/security/*" {
        access {
            admin = [read, approve]
        }
        intent SECURE_UPDATE {
            permits  = [read, snapshot, write, commit]
            requires = [approval, integrity_check, staging]
        }
    }
}
        ]]></sourcecode>
      </section>
    </section>

    <section anchor="identity-engine" numbered="true" toc="default">
      <name>Identity and Context Engine</name>

      <section anchor="identity-chain" numbered="true" toc="default">
        <name>Multi-Dimensional Identity Chain</name>
        <t>
          AegisFS does not rely on a flat user-to-permission mapping. Access
          decisions are computed from a multi-dimensional identity chain:
        </t>
        <artwork name="" type="" align="left" alt=""><![CDATA[
  Principal (User)
       |
       v
  Device (attested via RATS EAT token [RFC9334])
       |
       v
  Application / Process (code identity, signature)
       |
       v
  Runtime Context (session state, network zone, time window)
       |
       v
  File Object (classification, lifecycle state, risk score)
        ]]></artwork>
      </section>

      <section anchor="context-attributes" numbered="true" toc="default">
        <name>Context Evaluation Attributes</name>
        <t>
          An access decision <bcp14>MUST</bcp14> evaluate ALL of the following:
        </t>
        <table align="center">
          <thead>
            <tr><th>Attribute</th><th>Source</th></tr>
          </thead>
          <tbody>
            <tr><td>Principal Identity</td><td>Authenticated credential (OIDC/SAML)</td></tr>
            <tr><td>Authentication Strength</td><td>MFA factor level</td></tr>
            <tr><td>Device Trust Level</td><td>RATS attestation token</td></tr>
            <tr><td>Application Identity</td><td>Code signing certificate</td></tr>
            <tr><td>Process Context</td><td>PID, parent process, arguments</td></tr>
            <tr><td>Current APL Policy Match</td><td>Compiled policy bundle</td></tr>
            <tr><td>Object Lifecycle State</td><td>State machine current state</td></tr>
            <tr><td>Object AI Risk Score</td><td>Most recent risk engine output</td></tr>
            <tr><td>Session Validity</td><td>Session token expiry and integrity</td></tr>
            <tr><td>Network Zone</td><td>Internal/external/VPN status</td></tr>
          </tbody>
        </table>
      </section>

      <section anchor="decision-outcomes" numbered="true" toc="default">
        <name>Decision Outcomes</name>
        <t>The Identity Engine emits one of:</t>
        <ul>
          <li><strong>ALLOW</strong> — All conditions satisfied; proceed.</li>
          <li><strong>RESTRICT</strong> — Allow with reduced permissions or rate limits.</li>
          <li><strong>REQUIRE_APPROVAL</strong> — Valid but needs human approval.</li>
          <li><strong>DENY</strong> — One or more mandatory conditions not satisfied.</li>
        </ul>
      </section>
    </section>

    <section anchor="dcal" numbered="true" toc="default">
      <name>Dynamic Contextual ACL Engine</name>
      <t>
        Unlike traditional static ACLs, AegisFS implements Dynamic Contextual
        ACLs (DCALs). A DCAL entry takes the form:
      </t>
      <artwork name="" type="" align="left" alt=""><![CDATA[
  PERMIT <PrincipalGroup> <Permission> ON <ObjectPattern>
  WHEN   <condition_1> AND <condition_2> ... AND <condition_n>
      ]]></artwork>
      <t>
        All conditions are evaluated at the moment of each access request.
        A permission valid at time T is not assumed valid at T+1.
      </t>
      <t>
        ACL evaluation follows a DENY-by-default model:
      </t>
      <ol type="a">
        <li>If no PERMIT rule matches the current context, DENY.</li>
        <li>If a DENY rule explicitly matches, DENY (overrides PERMIT).</li>
        <li>
          If multiple PERMIT rules match, grant the union of permissions
          ONLY IF no DENY rule conflicts.
        </li>
        <li>All evaluations are logged regardless of outcome.</li>
      </ol>
    </section>

    <section anchor="capability-engine" numbered="true" toc="default">
      <name>Capability Engine</name>
      <t>
        <strong>ACL answers:</strong> "Who MAY access this object in principle?"
        <strong>Capability Tokens answer:</strong> "What access is authorized RIGHT NOW?"
      </t>
      <t>A Capability Token <bcp14>MUST</bcp14> contain:</t>
      <table align="center">
        <thead>
          <tr><th>Field</th><th>Description</th></tr>
        </thead>
        <tbody>
          <tr><td>token_id</td><td>UUID v7 unique token identifier</td></tr>
          <tr><td>issuer</td><td>AegisFS Capability Engine instance ID</td></tr>
          <tr><td>principal</td><td>Bound principal identity (non-transferable)</td></tr>
          <tr><td>object_id</td><td>Target file object UUID</td></tr>
          <tr><td>permitted_opcodes</td><td>Set of authorized OtO opcodes</td></tr>
          <tr><td>issued_at</td><td>Unix timestamp (UTC)</td></tr>
          <tr><td>expires_at</td><td>Unix timestamp (UTC)</td></tr>
          <tr><td>max_uses</td><td>Maximum permitted invocations</td></tr>
          <tr><td>use_count</td><td>Current invocation count</td></tr>
          <tr><td>approved_application</td><td>Bound application identity</td></tr>
          <tr><td>signature</td><td>ECDSA-P256 signature over all above fields</td></tr>
        </tbody>
      </table>
      <t>
        Revocation <bcp14>MUST</bcp14> be propagated to all runtime nodes within
        100ms. A revoked token presented to the engine <bcp14>MUST</bcp14> be
        rejected and generate a security alert event.
      </t>
    </section>

    
    
    
    <section anchor="intent" numbered="true" toc="default">
      <name>Intent-Based File Operations</name>
      <t>
        For sensitive or classified objects, principals <bcp14>MUST</bcp14>
        declare an Intent before initiating a complex operation. The runtime
        monitors the actual OtO opcode stream against the declared intent:
      </t>
      <artwork name="" type="" align="left" alt=""><![CDATA[
  DECLARED INTENT
       |
       v
  EXPECTED OPERATION MODEL (from APL intent block)
       |
       v
  REAL EXECUTION (monitored via OtO opcode stream)
       |
       v
  COMPARE
       |
       +-- MATCH     --> Continue; update audit log.
       +-- DEVIATION --> INTENT VIOLATION
                        Actions: RESTRICT, REVOKE CAPABILITY,
                        QUARANTINE OBJECT, GENERATE ALERT,
                        REQUIRE HUMAN APPROVAL
      ]]></artwork>
    </section>

    
    
    <section anchor="lifecycle" numbered="true" toc="default">
      <name>Object Lifecycle State Machine</name>
      <t>
        Every AegisFS File Object <bcp14>MUST</bcp14> exist in exactly one of
        eight lifecycle states. Valid transitions are:
      </t>
      <artwork name="" type="" align="left" alt=""><![CDATA[
  CREATED    --> STAGING      (registration complete)
  STAGING    --> ANALYZING    (validation triggered)
  ANALYZING  --> APPROVED     (analysis passed)
  ANALYZING  --> QUARANTINED  (analysis failed or risk exceeded)
  APPROVED   --> ACTIVE       (admin approval granted)
  ACTIVE     --> STAGING      (modification initiated; re-staging)
  ACTIVE     --> QUARANTINED  (anomaly detected at runtime)
  ACTIVE     --> ARCHIVED     (lifecycle auto-archive policy)
  QUARANTINED--> STAGING      (manual admin recovery initiated)
  QUARANTINED--> DESTROYED    (policy: destroy on quarantine)
  ARCHIVED   --> DESTROYED    (retention policy expired)

  All other transitions MUST be rejected by the OtO pipeline.
      ]]></artwork>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 11: TRANSACTION AND VERSIONING ENGINE               -->
    <!-- ========================================================== -->
    <section anchor="transactions" numbered="true" toc="default">
      <name>Transaction and Versioning Engine</name>
      <t>
        Modifications to objects <bcp14>MUST</bcp14> be performed within an
        atomic transaction:
      </t>
      <artwork name="" type="" align="left" alt=""><![CDATA[
  BEGIN TRANSACTION (acquire TRANSACTION LOCK: 0o342)
       |
       +-- Create pre-modification SNAPSHOT (0o343)
       +-- Perform operations (WRITE: 0o341, etc.)
       |
       v
  VALIDATE
       +-- Integrity: Verify content hash of each modified object
       +-- Permissions: Re-evaluate ACL for all touched objects
       +-- Dependencies: Check no dependency constraints violated
       +-- Policies: Re-evaluate APL rules post-modification
       |
       v
  COMMIT (0o3x5) --> New version record created, lock released
       OR
  ROLLBACK (0o3x4) --> Snapshot restored, lock released
      ]]></artwork>
      <t>
        Each COMMIT produces an immutable, hash-linked Version Record.
        Tampering with any record breaks the chain and
        <bcp14>MUST</bcp14> generate a critical forensics alert.
      </t>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 12: PROVENANCE GRAPH                                -->
    <!-- ========================================================== -->
    <section anchor="provenance" numbered="true" toc="default">
      <name>File Provenance Graph</name>
      <t>
        AegisFS maintains a directed provenance graph where nodes represent
        Principals, Processes, and File Objects; and edges represent Created,
        Modified, Derived-From, and Used-By relationships.
      </t>
      <t>The provenance engine <bcp14>MUST</bcp14> support:</t>
      <ul>
        <li>ANCESTORS(object_id): All upstream principals and processes.</li>
        <li>DESCENDANTS(object_id): All downstream derived objects.</li>
        <li>IMPACT(process_id): All objects touched by a process.</li>
        <li>LINEAGE(object_id, version_id): Full creation-to-state chain.</li>
      </ul>
    </section>

    
    <!-- SECTION 13: DEPENDENCY GRAPH ENGINE                         -->
    
    <section anchor="dependency" numbered="true" toc="default">
      <name>Dependency Graph Engine</name>
      <t>
        When a modification is requested on any object, the engine
        <bcp14>MUST</bcp14>:
      </t>
      <ol type="a">
        <li>Query the dependency graph for all objects consuming or referencing the target.</li>
        <li>Compute the full transitive impact set.</li>
        <li>Report the impact set to the principal before permitting modification.</li>
        <li>
          Evaluate whether dependent objects' policies require revalidation,
          testing, or approval before the change commits.
        </li>
      </ol>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 14: METADATA ENGINE                                 -->
    <!-- ========================================================== -->
    <section anchor="metadata" numbered="true" toc="default">
      <name>Metadata Engine</name>
      <t>Every AegisFS File Object carries a mandatory metadata block:</t>
      <sourcecode type="c"><![CDATA[
typedef struct AegisObjectMetadata {
    char        object_id[64];       /* UUID v7 string            */
    char        owner_id[64];        /* Principal UUID            */
    uint64_t    creation_time;       /* Unix timestamp (UTC)      */
    uint64_t    modification_time;   /* Unix timestamp (UTC)      */
    uint64_t    file_size;           /* Bytes                     */
    uint64_t    version;             /* Monotonic version number  */
    uint32_t    permissions;         /* Encoded ACL bitmask       */
    uint8_t     integrity_hash[32];  /* SHA-256 content hash      */
    uint8_t     classification;      /* 0=PUBLIC .. 4=CRITICAL    */
    uint8_t     lifecycle_state;     /* 0=CREATED .. 7=DESTROYED  */
    uint32_t    ai_risk_score;       /* 0-100                     */
    uint8_t     metadata_hash[32];   /* SHA-256 of this struct    */
} AegisObjectMetadata;
      ]]></sourcecode>
      <t>
        Any modification to metadata <bcp14>MUST</bcp14> occur within a
        transaction, recompute the metadata_hash, and log the change event.
      </t>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 15: RESOURCE GOVERNANCE ENGINE                      -->
    <!-- ========================================================== -->
    <section anchor="resources" numbered="true" toc="default">
      <name>Resource Governance Engine</name>
      <t>
        Each workspace is assigned a hard resource budget enforced by the
        Resource Governance Engine. Exceeding any limit
        <bcp14>MUST</bcp14> result in throttling, a governance audit event,
        notification to the AI behavioral engine, and potential escalation to
        QUARANTINE state if the pattern is sustained.
      </t>
      <t>
        AegisFS provides tracked memory allocation APIs for runtime modules:
        ag_malloc(), ag_calloc(), ag_realloc(), ag_free(). Every allocation
        is tracked with: Allocation ID, Context ID, Size, Owner application,
        Timestamp, and Declared lifetime.
      </t>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 16: PROCESS AND EXECUTION AWARENESS                 -->
    <!-- ========================================================== -->
    <section anchor="execution-awareness" numbered="true" toc="default">
      <name>Process and Execution Awareness Engine</name>
      <t>
        For any application accessing AegisFS objects, the runtime constructs an
        Execution Context tracking: files accessed, resources consumed, child
        processes spawned, network activity, and OS interaction profile.
      </t>
      <t>
        AegisFS implements Adaptive Locking that dynamically selects the locking
        strategy — ALLOW CONCURRENT, WAIT, STAGE COPY, MERGE LATER, or DENY —
        based on current context and risk level, avoiding unnecessary hard
        locking in collaborative environments.
      </t>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 17: SCSWP                                           -->
    <!-- ========================================================== -->
    <section anchor="scswp" numbered="true" toc="default">
      <name>SCSWP Collaborative Workspace Engine</name>
      <t>
        The Secure Collaborative Staging Workspace Protocol (SCSWP) governs
        multi-user collaboration. Users <bcp14>NEVER</bcp14> directly access
        the protected production source. All collaboration occurs in
        policy-controlled staging areas. Conflicts (structural, dependency,
        or policy) <bcp14>MUST</bcp14> be resolved explicitly before commit.
      </t>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 18: DATA CLASSIFICATION AND FLOW                    -->
    <!-- ========================================================== -->
    <section anchor="classification" numbered="true" toc="default">
      <name>Data Classification and Flow Control</name>
      <t>AegisFS defines five classification levels:</t>
      <ul>
        <li>0 = PUBLIC: Freely sharable.</li>
        <li>1 = INTERNAL: Internal use only; no external export.</li>
        <li>2 = CONFIDENTIAL: Restricted distribution; encryption required.</li>
        <li>3 = RESTRICTED: Very limited distribution; approval required.</li>
        <li>4 = CRITICAL: Maximum protection; all controls mandatory.</li>
      </ul>
      <t>
        Classification <bcp14>MUST</bcp14> be propagated to derived objects.
        The Data Flow Engine evaluates all data movement operations against the
        APL dataflow block and intercepts unauthorized transfers to unapproved
        destinations, cloud endpoints, external storage, or clipboard.
      </t>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 19: IMMUTABLE SECURITY ZONES                        -->
    <!-- ========================================================== -->
    <section anchor="immutable-zones" numbered="true" toc="default">
      <name>Immutable Security Zones</name>
      <t>
        Objects in immutable zones require an authorized request, a staging
        version, integrity validation, policy approval, and a new signed version
        before any write commits. Direct writes that bypass this workflow
        <bcp14>MUST</bcp14> be rejected at the OtO pipeline level with a
        CRITICAL audit event. The previous version <bcp14>MUST</bcp14> be
        retained indefinitely for recovery.
      </t>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 20: SECURE OBJECT IDENTITY                          -->
    <!-- ========================================================== -->
    <section anchor="object-identity" numbered="true" toc="default">
      <name>Secure Object Identity</name>
      <t>
        An AegisFS File Object <bcp14>MUST NOT</bcp14> be identified by
        filesystem path alone. Object identity is composed of:
      </t>
      <artwork name="" type="" align="left" alt=""><![CDATA[
  OBJECT IDENTITY = {
      object_id   : UUID v7 (immutable from creation)
      content_hash: SHA-256 of current content
      version_id  : Current version integer
      owner_id    : Creating principal UUID
      signature   : ECDSA-P256 signature by the issuing AegisFS node
  }
      ]]></artwork>
      <t>
        If a file is renamed, its object_id and identity remain unchanged.
        This model aligns with the RATS <xref target="RFC9334"/> concept of
        stable Endorsement targets whose identity persists across environment
        changes.
      </t>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 21: DIGITAL TWIN ENGINE                             -->
    <!-- ========================================================== -->
    <section anchor="digital-twin" numbered="true" toc="default">
      <name>Digital Twin Engine</name>
      <t>
        The Digital Twin Engine maintains a runtime model of the expected
        structural and behavioral state of each workspace and file object,
        including: structure model, file relationships, dependency graph,
        access patterns, resource patterns, behavioral baseline, and security
        state.
      </t>
      <t>
        On HIGH ANOMALY detection (e.g., mass write rates exceeding baseline
        by orders of magnitude — a ransomware indicator), the engine
        <bcp14>MUST</bcp14>: immediately freeze writes, create an emergency
        snapshot, elevate the object to QUARANTINED state, revoke all active
        capability tokens for the workspace, and notify the Forensics and
        Incident Response Engine.
      </t>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 22: AI INTELLIGENCE LAYER                           -->
    <!-- ========================================================== -->
    <section anchor="ai-layer" numbered="true" toc="default">
      <name>AI Intelligence Layer</name>

      <section anchor="static-analysis" numbered="true" toc="default">
        <name>Static Analysis Module</name>
        <t>
          Before any object transitions from ANALYZING to APPROVED, the static
          analysis module performs type detection, content inspection, dependency
          enumeration, Control Flow Graph (CFG) construction, Call Graph
          construction, and Data Flow Graph construction to produce a STATIC
          RISK PROFILE (score 0-100).
        </t>
      </section>

      <section anchor="dynamic-analysis" numbered="true" toc="default">
        <name>Dynamic Behavioral Analysis Module</name>
        <t>
          During sandboxed execution, the module monitors file activity,
          resource consumption, memory behavior, network connections, child
          processes, and system calls. Expected (from static analysis) is
          compared against Actual. Discrepancies elevate the dynamic risk score.
        </t>
      </section>

      <section anchor="predictive-impact" numbered="true" toc="default">
        <name>Predictive Impact Engine</name>
        <t>
          Before execution, a pre-flight impact report is generated with
          estimated memory, CPU, disk I/O, network usage, number of files
          affected, and an overall risk score. Decision routing:
        </t>
        <ul>
          <li>0-30 (LOW): ALLOW</li>
          <li>31-60 (MEDIUM): ALLOW WITH RESOURCE LIMITS</li>
          <li>61-80 (HIGH): SANDBOX REQUIRED</li>
          <li>81-100 (CRITICAL): DENY or QUARANTINE</li>
        </ul>
        <t>
          For CRITICAL objects, deterministic policy limits
          <bcp14>MUST</bcp14> take precedence over probabilistic AI estimates.
        </t>
      </section>

      <section anchor="behavioral-risk" numbered="true" toc="default">
        <name>Behavioral Risk Engine</name>
        <t>
          Every file object develops a behavioral baseline. The risk engine
          monitors for deviations: mass write bursts (ransomware pattern), mass
          rename operations (encryption attack pattern), off-hours access
          (credential compromise indicator). On detection: freeze writes,
          snapshot, restrict session, move to QUARANTINED state, generate
          CRITICAL alert, require human approval to resume.
        </t>
      </section>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 23: CANARY OBJECTS                                  -->
    <!-- ========================================================== -->
    <section anchor="canary" numbered="true" toc="default">
      <name>Deception and Canary Object Framework</name>
      <t>
        Canary Objects are decoy files that appear legitimate but trigger
        immediate incident response upon access. They <bcp14>MUST NOT</bcp14>
        contain real sensitive data and <bcp14>MUST</bcp14> log every access
        attempt. Any access by a non-audit principal generates a CRITICAL alert.
        The mere attempt to access a canary object is treated as a high-
        confidence indicator of unauthorized access or threat actor presence.
      </t>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 24: INCIDENT RESPONSE ENGINE                        -->
    <!-- ========================================================== -->
    <section anchor="incident-response" numbered="true" toc="default">
      <name>Autonomous Incident Response Engine</name>
      <t>
        The engine executes bounded, policy-defined automated responses:
        LOG, ALERT, RESTRICT, REVOKE_CAPABILITY, FREEZE_WRITES, SNAPSHOT,
        QUARANTINE, REQUIRE_APPROVAL.
      </t>
      <t>
        Destructive response actions (DESTROY, WIPE) <bcp14>MUST</bcp14>
        require explicit human approval regardless of the AI risk score or
        anomaly severity. Autonomous destruction of data is NOT permitted.
      </t>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 25: FORENSICS ENGINE                                -->
    <!-- ========================================================== -->
    <section anchor="forensics" numbered="true" toc="default">
      <name>Forensics and Audit Engine</name>
      <t>
        Every significant operation <bcp14>MUST</bcp14> produce an audit event
        written to an append-only, integrity-protected log. Each event contains:
        event_id, timestamp (nanosecond UTC), principal_id, device_id,
        application_id, object_id, opcode (e.g., 0o241), operation, intent_id,
        decision, policy_bundle_hash, integrity_reference, and chain_hash
        (SHA-256 of event_id concatenated with prev_chain_hash).
      </t>
      <t>
        The chain_hash field creates a tamper-evident audit chain. Any gap or
        hash mismatch <bcp14>MUST</bcp14> trigger an immediate forensics alert.
      </t>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 26: SNAPSHOT AND RECOVERY                           -->
    <!-- ========================================================== -->
    <section anchor="snapshot" numbered="true" toc="default">
      <name>Snapshot and Recovery Engine</name>
      <t>
        Before high-risk operations, the engine <bcp14>MUST</bcp14> create a
        snapshot capturing: files, metadata, ACL, capabilities, policies,
        dependency state, provenance state, and transaction state.
      </t>
      <t>
        Snapshots <bcp14>MUST</bcp14> be: stored in an integrity-protected
        location outside the workspace; indexed by (object_id, transaction_id,
        timestamp); retained for a minimum period defined in the APL lifecycle
        block; and verifiable via their own integrity hash chain.
      </t>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 27: SECURE WEB ACCESS GATEWAY                       -->
    <!-- ========================================================== -->
    <section anchor="web-gateway" numbered="true" toc="default">
      <name>Secure Web Access Gateway</name>
      <t>
        The AegisFS web interface <bcp14>MUST NEVER</bcp14> expose the
        filesystem directly. All access flows through the AegisFS Access
        Gateway which performs: authentication (OIDC/SAML), session control
        (JWT with short TTL), authorization (ACL + Capability check), object
        policy check (APL evaluation), and pre-response audit logging.
      </t>
      <t>
        CORS configuration restricts which web origins may call the API, but
        CORS is NOT a security boundary — it is a browser enforcement hint only.
        The authentication and authorization layer <bcp14>MUST</bcp14> be the
        primary security control. Internal tunneling <bcp14>MUST</bcp14> be
        explicitly authorized in APL policy and logged for its full duration.
      </t>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 28: END-TO-END OPERATIONAL LIFECYCLE                -->
    <!-- ========================================================== -->
    <section anchor="e2e-lifecycle" numbered="true" toc="default">
      <name>Complete End-to-End Operational Lifecycle</name>
      <t>
        The following describes the complete lifecycle of a single protected
        file operation request across 25 steps:
      </t>
      <artwork name="" type="" align="left" alt=""><![CDATA[
  STEP 01: USER / APPLICATION REQUEST
  STEP 02: IDENTITY VALIDATION (OIDC/SAML + RATS attestation)
  STEP 03: CONTEXT VALIDATION (device, session, network zone)
  STEP 04: APL POLICY + DCAL CHECK (syntax match + condition eval)
  STEP 05: CAPABILITY TOKEN VALIDATION (scope, expiry, use count)
  STEP 06: OtO OPCODE GENERATION (domain + state + intent encoding)
  STEP 07: OBJECT STATE CHECK (lifecycle state machine query)
  STEP 08: INTENT DECLARATION (for sensitive/critical objects)
  STEP 09: DEPENDENCY ANALYSIS (impact set computation)
  STEP 10: RESOURCE AVAILABILITY CHECK (budget enforcement)
  STEP 11: AI STATIC/PREDICTIVE ANALYSIS (if required by APL)
  STEP 12: DECISION ENGINE
           |
     +-----+-----+
     |     |     |
   ALLOW  STAGE SANDBOX
     |
     v
  STEP 13: TRANSACTION BEGIN + PRE-OPERATION SNAPSHOT
  STEP 14: EXECUTION / FILE OPERATION
  STEP 15: RUNTIME BEHAVIORAL MONITORING (digital twin comparison)
  STEP 16: INTENT VERIFICATION (expected vs. actual opcode stream)
  STEP 17: INTEGRITY + DATA FLOW VALIDATION
  STEP 18: TRANSACTION VALIDATION
           |
     +-----+------+
     |            |
   COMMIT       ROLLBACK
     |            |
     v            v
  STEP 19: VERSION RECORD CREATION  |  SNAPSHOT RESTORE
  STEP 20: DIGITAL TWIN UPDATE
  STEP 21: PROVENANCE GRAPH UPDATE
  STEP 22: DEPENDENCY GRAPH UPDATE
  STEP 23: AUDIT EVENT WRITE (chain hash update)
  STEP 24: CAPABILITY TOKEN USE COUNT INCREMENT
  STEP 25: FINAL STATE NOTIFICATION TO PRINCIPAL
      ]]></artwork>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 29: SECURITY CONSIDERATIONS                         -->
    <!-- ========================================================== -->
    <section anchor="security" numbered="true" toc="default">
      <name>Security Considerations</name>

      <section anchor="sec-policy-engine" numbered="true" toc="default">
        <name>Policy Engine Attack Surface</name>
        <t>
          The Policy Engine and APL compiler are the highest-value attack
          targets. Implementations <bcp14>MUST</bcp14>: run the APL compiler in
          an isolated sandboxed process; validate all policy bundles with ECDSA
          signatures before loading; reject any policy bundle that does not
          chain to a trusted root; and log all policy compilation and loading
          events to the audit chain.
        </t>
      </section>

      <section anchor="sec-opcode-injection" numbered="true" toc="default">
        <name>OtO OpCode Injection</name>
        <t>
          Malformed or spoofed OtO opcodes <bcp14>MUST NOT</bcp14> be accepted
          from external or untrusted sources. All opcodes <bcp14>MUST</bcp14>
          be generated internally by the AegisFS runtime. External opcode
          injection attempts <bcp14>MUST</bcp14> generate a CRITICAL forensics
          event.
        </t>
      </section>

      <section anchor="sec-ai-manipulation" numbered="true" toc="default">
        <name>AI Risk Score Manipulation</name>
        <t>
          Adversaries may attempt to slowly train the behavioral baseline to
          accept anomalous behavior (slow-walk attacks). Implementations
          <bcp14>SHOULD</bcp14>: maintain multiple rolling baseline windows
          (1h, 24h, 30d); require anomaly scores to decrease gradually; and
          flag rapid baseline shifts as anomalies in themselves.
        </t>
      </section>

      <section anchor="sec-capability-theft" numbered="true" toc="default">
        <name>Capability Token Theft</name>
        <t>
          Capability Tokens <bcp14>MUST</bcp14> be bound to the specific
          principal, device, and application. Tokens <bcp14>MUST</bcp14> be
          non-transferable. Implementations <bcp14>MUST</bcp14> verify the full
          binding context on every token presentation, not only the signature
          and expiry.
        </t>
      </section>

      <section anchor="sec-ransomware" numbered="true" toc="default">
        <name>Ransomware and Mass Encryption Defense</name>
        <t>
          The Digital Twin mass-write detection and Behavioral Risk Engine's
          ransomware pattern detection provide structural defenses. Thresholds
          <bcp14>MUST</bcp14> be set conservatively and tested explicitly, as
          false-negative failures have catastrophic consequences.
        </t>
      </section>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 30: PRIVACY CONSIDERATIONS                          -->
    <!-- ========================================================== -->
    <section anchor="privacy" numbered="true" toc="default">
      <name>Privacy Considerations</name>
      <t>
        The audit log, provenance graph, and behavioral profiles contain
        detailed records of user activity. Implementations <bcp14>MUST</bcp14>:
        apply data minimization; enforce access control on audit and provenance
        data; define and enforce retention periods; comply with applicable data
        protection regulations (e.g., GDPR); and ensure AI behavioral profiles
        cannot be used to infer sensitive personal attributes beyond the stated
        security purpose.
      </t>
    </section>

    <!-- ========================================================== -->
    <!-- SECTION 31: IANA CONSIDERATIONS                             -->
    <!-- ========================================================== -->
    <section anchor="iana" numbered="true" toc="default">
      <name>IANA Considerations</name>
      <t>
        This document requests no immediate IANA actions. Future versions
        MAY request:
      </t>
      <ul>
        <li>A registry for AegisFS OtO Domain Codes.</li>
        <li>A registry for AegisFS OtO Intent Codes.</li>
        <li>A media type registration for APL source files (text/x-apl).</li>
        <li>
          A media type registration for APL policy bundles
          (application/x-aegisfs-policy).
        </li>
        <li>A well-known URI suffix for AegisFS Access Gateways.</li>
      </ul>
    </section>

  </middle>

  <!-- ============================================================ -->
  <!-- BACK MATTER                                                   -->
  <!-- ============================================================ -->
  <back>

    <!-- ========================================================== -->
    <!-- REFERENCES                                                  -->
    <!-- ========================================================== -->
    <references>
      <name>References</name>

      <references>
        <name>Normative References</name>

        <reference anchor="RFC2119" target="https://www.rfc-editor.org/info/rfc2119">
          <front>
            <title>Key words for use in RFCs to Indicate Requirement Levels</title>
            <author initials="S." surname="Bradner" fullname="S. Bradner">
              <organization/>
            </author>
            <date year="1997" month="March"/>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="2119"/>
        </reference>

        <reference anchor="RFC8174" target="https://www.rfc-editor.org/info/rfc8174">
          <front>
            <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
            <author initials="B." surname="Leiba" fullname="B. Leiba">
              <organization/>
            </author>
            <date year="2017" month="May"/>
          </front>
          <seriesInfo name="BCP" value="14"/>
          <seriesInfo name="RFC" value="8174"/>
        </reference>

        <reference anchor="RFC9334" target="https://www.rfc-editor.org/info/rfc9334">
          <front>
            <title>Remote ATtestation procedureS (RATS) Architecture</title>
            <author initials="H." surname="Birkholz" fullname="H. Birkholz">
              <organization/>
            </author>
            <author initials="D." surname="Thaler" fullname="D. Thaler">
              <organization/>
            </author>
            <author initials="M." surname="Richardson" fullname="M. Richardson">
              <organization/>
            </author>
            <date year="2023" month="January"/>
          </front>
          <seriesInfo name="RFC" value="9334"/>
        </reference>

        <reference anchor="RFC5234" target="https://www.rfc-editor.org/info/rfc5234">
          <front>
            <title>Augmented BNF for Syntax Specifications: ABNF</title>
            <author initials="D." surname="Crocker" fullname="D. Crocker">
              <organization/>
            </author>
            <author initials="P." surname="Overell" fullname="P. Overell">
              <organization/>
            </author>
            <date year="2008" month="January"/>
          </front>
          <seriesInfo name="STD" value="68"/>
          <seriesInfo name="RFC" value="5234"/>
        </reference>

      </references>

      <references>
        <name>Informative References</name>

        <reference anchor="RFC7519" target="https://www.rfc-editor.org/info/rfc7519">
          <front>
            <title>JSON Web Token (JWT)</title>
            <author initials="M." surname="Jones" fullname="M. Jones">
              <organization/>
            </author>
            <author initials="J." surname="Bradley" fullname="J. Bradley">
              <organization/>
            </author>
            <author initials="N." surname="Sakimura" fullname="N. Sakimura">
              <organization/>
            </author>
            <date year="2015" month="May"/>
          </front>
          <seriesInfo name="RFC" value="7519"/>
        </reference>

        <reference anchor="RFC6749" target="https://www.rfc-editor.org/info/rfc6749">
          <front>
            <title>The OAuth 2.0 Authorization Framework</title>
            <author initials="D." surname="Hardt" fullname="D. Hardt">
              <organization/>
            </author>
            <date year="2012" month="October"/>
          </front>
          <seriesInfo name="RFC" value="6749"/>
        </reference>

        <reference anchor="RFC4949" target="https://www.rfc-editor.org/info/rfc4949">
          <front>
            <title>Internet Security Glossary, Version 2</title>
            <author initials="R." surname="Shirey" fullname="R. Shirey">
              <organization/>
            </author>
            <date year="2007" month="August"/>
          </front>
          <seriesInfo name="FYI" value="36"/>
          <seriesInfo name="RFC" value="4949"/>
        </reference>

      </references>
    </references>

    <!-- ========================================================== -->
    <!-- APPENDIX A: FULL OtO OPCODE TABLE                           -->
    <!-- ========================================================== -->
    <section anchor="appendix-a" numbered="false" toc="default">
      <name>Appendix A: Full OtO OpCode Table (Representative Entries)</name>
      <table align="center">
        <thead>
          <tr>
            <th>OpCode</th>
            <th>Domain</th>
            <th>State</th>
            <th>Intent</th>
            <th>Notes</th>
          </tr>
        </thead>
        <tbody>
          <tr><td>0o000</td><td>KERNEL</td><td>CREATED</td><td>READ</td><td>Permitted</td></tr>
          <tr><td>0o041</td><td>KERNEL</td><td>ACTIVE</td><td>WRITE</td><td>Kernel write on active obj</td></tr>
          <tr><td>0o100</td><td>META</td><td>CREATED</td><td>READ</td><td>Always permitted</td></tr>
          <tr><td>0o141</td><td>META</td><td>ACTIVE</td><td>WRITE</td><td>Metadata write</td></tr>
          <tr><td>0o240</td><td>POLICY</td><td>ACTIVE</td><td>READ</td><td>Policy-evaluated read</td></tr>
          <tr><td>0o241</td><td>POLICY</td><td>ACTIVE</td><td>WRITE</td><td>Policy-evaluated write</td></tr>
          <tr><td>0o255</td><td>POLICY</td><td>QUARANTINED</td><td>COMMIT</td><td>INVALID — DENY</td></tr>
          <tr><td>0o340</td><td>TRANS</td><td>ACTIVE</td><td>READ</td><td>Transaction read</td></tr>
          <tr><td>0o343</td><td>TRANS</td><td>ACTIVE</td><td>SNAPSHOT</td><td>Pre-op snapshot</td></tr>
          <tr><td>0o344</td><td>TRANS</td><td>ACTIVE</td><td>ROLLBACK</td><td>Transaction rollback</td></tr>
          <tr><td>0o345</td><td>TRANS</td><td>ACTIVE</td><td>COMMIT</td><td>Transaction commit</td></tr>
          <tr><td>0o440</td><td>CAP</td><td>ACTIVE</td><td>READ</td><td>Capability-gated read</td></tr>
          <tr><td>0o471</td><td>CAP</td><td>DESTROYED</td><td>WRITE</td><td>INVALID — DENY</td></tr>
          <tr><td>0o520</td><td>AI</td><td>ANALYZING</td><td>READ</td><td>Analysis pipeline read</td></tr>
          <tr><td>0o541</td><td>AI</td><td>ACTIVE</td><td>WRITE</td><td>AI-governed write</td></tr>
          <tr><td>0o640</td><td>PROV</td><td>ACTIVE</td><td>READ</td><td>Provenance graph read</td></tr>
          <tr><td>0o700</td><td>AUDIT</td><td>CREATED</td><td>READ</td><td>Audit query</td></tr>
          <tr><td>0o747</td><td>AUDIT</td><td>ACTIVE</td><td>DESTROY</td><td>Requires human approval</td></tr>
        </tbody>
      </table>
      <t>
        Opcodes involving QUARANTINED (Y=5) or DESTROYED (Y=7) states with
        WRITE, COMMIT, or ELEVATE intents <bcp14>MUST</bcp14> be treated as
        INVALID and <bcp14>MUST</bcp14> cause the OtO pipeline to emit DENY
        without further evaluation.
      </t>
    </section>

    <!-- ========================================================== -->
    <!-- APPENDIX B: APL ABNF GRAMMAR                                -->
    <!-- ========================================================== -->
    <section anchor="appendix-b" numbered="false" toc="default">
      <name>Appendix B: APL Grammar (ABNF per RFC 5234)</name>
      <sourcecode type="abnf"><![CDATA[
apl-document     = 1*workspace-decl

workspace-decl   = "workspace" SP identifier SP "{" NL
                   workspace-body "}" NL

workspace-body   = classification-stmt
                   [storage-block]
                   [access-block]
                   [resource-block]
                   [execution-block]
                   [lifecycle-block]
                   [dataflow-block]
                   *capability-block
                   [ai-block]
                   *object-block

classification-stmt = "classification" SP "=" SP class-value NL
class-value      = "public" / "internal" / "confidential" /
                   "restricted" / "critical"

storage-block    = "storage" SP "{" NL *storage-stmt "}" NL
storage-stmt     = ext-list-stmt / size-stmt / bool-stmt

access-block     = "access" SP "{" NL *access-stmt *condition-stmt "}" NL
access-stmt      = identifier SP "=" SP "[" perm-list "]" NL
perm-list        = permission *("," SP permission)
permission       = "read" / "write" / "execute" / "audit" /
                   "approve" / "lock" / "snapshot" / "commit" /
                   "rollback" / "destroy"

condition-stmt   = ("when" / "if" / "unless") SP condition-expr NL
condition-expr   = identifier SP ("=" / "!=" / "<" / ">") SP value
                 / condition-expr SP "and" SP condition-expr
                 / condition-expr SP "or" SP condition-expr

resource-block   = "resources" SP "{" NL *resource-stmt "}" NL
resource-stmt    = identifier SP "=" SP resource-value NL
resource-value   = integer ("GB" / "MB" / "KB" / "%" / "MBps" / "")

execution-block  = "execution" SP "{" NL *execution-stmt "}" NL
execution-stmt   = "static_analysis" SP "=" SP analysis-level NL
                 / "dynamic_analysis" SP "=" SP analysis-level NL
                 / "sandbox_on_risk" SP "=" SP bool-value NL
                 / "risk_threshold" SP "=" SP integer NL
                 / "approved_apps" SP "=" SP "[" id-list "]" NL
analysis-level   = "required" / "conditional" / "disabled"

lifecycle-block  = "lifecycle" SP "{" NL *lifecycle-stmt "}" NL
lifecycle-stmt   = bool-stmt / duration-stmt

capability-block = "capability" SP identifier SP "{" NL
                   *cap-stmt "}" NL
cap-stmt         = "grants" SP "=" SP "[" perm-list "]" NL
                 / "on_object" SP "=" SP quoted-string NL
                 / "expires" SP "=" SP duration NL
                 / "max_uses" SP "=" SP integer NL
                 / "principal" SP "=" SP identifier NL

object-block     = "object" SP quoted-string SP "{" NL
                   [access-block] *intent-block "}" NL

intent-block     = "intent" SP identifier SP "{" NL
                   *intent-stmt "}" NL
intent-stmt      = "permits" SP "=" SP "[" perm-list "]" NL
                 / "requires" SP "=" SP "[" req-list "]" NL
req-list         = identifier *("," SP identifier)

ai-block         = "ai" SP "{" NL *ai-stmt "}" NL
ai-stmt          = bool-stmt / integer-stmt / level-stmt

identifier       = ALPHA *( ALPHA / DIGIT / "_" / "-" )
quoted-string    = DQUOTE *(%x20-21 / %x23-7E) DQUOTE
bool-value       = "true" / "false"
bool-stmt        = identifier SP "=" SP bool-value NL
duration         = integer ("d" / "h" / "m" / "s")
duration-stmt    = identifier SP "=" SP duration NL
integer          = 1*DIGIT
integer-stmt     = identifier SP "=" SP integer NL
id-list          = identifier *("," SP identifier)
ext-list-stmt    = identifier SP "=" SP "[" quoted-string
                   *("," SP quoted-string) "]" NL
size-stmt        = identifier SP "=" SP resource-value NL
level-stmt       = identifier SP "=" SP
                   ("enabled" / "disabled" / "required") NL
      ]]></sourcecode>
    </section>

  </back>

</rfc>
