Skip to content

Architecture Deepening: Unified Execution, Scope, Transport & Sealed Graph Seams (Pass 1 & Pass 2) #11

Done

Description

@h45sh

Problem Statement

Operators and autonomous AI agents running Ether encounter silent execution defects, contradictory security boundaries, and persistence leaks:

  • Tool flags passed through CLI or MCP are silently dropped before reaching adapters and gateway policy checks, while non-zero tool exit codes are masked as completed runs and Audit Manifest entries are silently skipped.
  • Scope and SSRF rules contradict each other across preflight, gateway, HTTP probes, and fuzzer baseline calibration, while legacy prompt-neutralization and static tool-list shims remain active in the codebase.
  • Multi-stage Reactive Pipeline chains treat Tier B Adapter tools as empty no-ops and double-upsert Finding records.
  • CLI and MCP duplicate Tool Arsenal and Graph Analytics wiring while harboring transport-only runtime crashes, unmasked credentials, and broken disk log lookups.
  • Tier A Adapter modules are silently downgraded to subprocess when their manifests omit execution_tier, and diagnostics fail to inspect coroutine tools accurately.
  • Entity Graph persistence leaks raw database connections across callers and tests, leaves most mutators outside Write Queue Worker and Forensic Sealing, truncates Finding RAG vector search across sessions, and forces downstream callers to repeatedly deserialize JSON payloads.
  • Wordlist resolution is split across incompatible interfaces that ignore $ETHER_WORDLISTS_DIR and SecLists during preflight, and the default test suite runs contended benchmarks on every PR.

Solution

Deepen Ether's core modules in two coordinated passes so callers and tests interact through a minimal set of authoritative seams:

  • Pass 1 unifies command flag normalization, single-owner LogSpooler and Audit Manifest recording, ExitCode failure propagation, and real Tier B Adapter execution in Reactive Pipeline; consolidates target, CIDR, metadata, loopback, and pre-connect DNS checks behind Scope Validator; thins CLI and MCP to pure transport adapters over shared headless engines; aligns Tier A Adapter manifests; purges retired legacy shims; and separates fast PR gates from benchmark/scenario runs.
  • Pass 2 seals Entity Graph persistence by removing raw database handle leaks, routing all mutations through Write Queue Worker with universal Forensic Sealing, moving all pure reads to the read pool, hydrating pik and data records, scoping vec0 Virtual Table search per session, and consolidating wordlist/macro resolution behind Asset Resolver.

User Stories

  1. As an operator running a scan from the CLI, I want extra tool flags to reach the Tool Adapter and Action Gateway, so that custom scan options actually execute and are policy-checked.
  2. As an autonomous MCP agent calling execute_tool, I want tool flags to be normalized identically to CLI invocations, so that agent-supplied flags are never silently dropped.
  3. As an operator or agent running a tool that exits with a non-zero status, I want the action to be marked failed with its exit_code and NON_ZERO_EXIT diagnostic category, so that failed scans are never misreported as successful.
  4. As a forensic auditor, I want every Execution Session action to open a single LogSpooler and record its Audit Manifest entry upon completion, so that the cryptographic chain of custody is intact and verifiable.
  5. As an operator using --data-dir, I want session logs, Audit Manifest files, and log compression to respect the configured data directory across CLI and MCP, so that isolated workspaces never write to or read from the wrong directory.
  6. As an autonomous agent reading historical action logs via MCP, I want read_action_log to locate session-partitioned .log and .log.gz files on disk, so that completed or archived action telemetry remains accessible.
  7. As an operator closing a session via CLI, I want log compression to run once and report an accurate integer count, so that closing a session does not double-compress or print raw path lists.
  8. As an operator running a Reactive Pipeline containing Tier B Adapter tools, I want those stages to execute real subprocesses via the runner seam rather than empty strings, so that chained pipelines produce real findings.
  9. As an operator or agent running a Reactive Pipeline, I want each discovered Finding to be persisted once by PipelineEngine, so that observation_count, Event Log rows, and vector indexing are not duplicated.
  10. As a security-conscious operator running under Gate Policy SAFE, I want loopback targets (127.0.0.1, ::1) to be blocked by default unless explicitly permitted by Engagement Scope (allow_loopback=True) or Gate Policy UNRESTRICTED, so that local host services are protected from unintended SSRF.
  11. As a red-team operator running under Gate Policy UNRESTRICTED, I want stored graph targets and http_probe requests to honor context.policy without artificial blocks, so that authorized engagements are never obstructed.
  12. As an operator running web fuzzers with Baseline Calibration, I want calibration HTTP probes to pass through Scope Validator pre-connect checks, so that calibration cannot bypass SSRF protections.
  13. As a developer writing tests for scope and SSRF, I want Scope Validator to accept an injectable DNS resolver adapter, so that DNS rebinding and resolution checks are tested hermetically without live network calls.
  14. As an adapter author adding a new tool manifest, I want PreflightVerifier to derive target validation solely from manifest target_types without static tool dictionaries, so that new tools work without modifying gateway code.
  15. As an operator running ether run, I want preflight errors and warnings to render cleanly and accurately, so that invalid invocations do not crash with attribute errors.
  16. As an operator running ether logs --crashes, I want recent fatal crash blocks to display cleanly without key errors, so that system diagnostics work when needed.
  17. As an operator inspecting Tool Arsenal via ether tool list or ether doctor, I want Tier A Adapter coroutine readiness to reflect actual validate_install() results rather than hardcoded "yes" or shutil.which binary checks, so that health diagnostics are accurate.
  18. As an operator running ether graph commands, I want credential attributes to be masked by default unless --unmask is supplied, so that sensitive secrets are not leaked in terminal output.
  19. As a maintainer of CLI and MCP surfaces, I want Tool Arsenal summaries, target inference, Graph Analytics envelopes, and session listing to live in headless engine modules, so that CLI and MCP share one behavior contract.
  20. As an operator running audit_drift, I want baseline inputs to accept both file paths and JSON strings and check strict HTTP security headers, so that MCP and CLI drift audits behave consistently.
  21. As a contributor reading the codebase, I want retired legacy modules (PromptNeutralizer, static preflight tool lists, legacy flat log path helpers) removed outright, so that dead shims do not cause confusion.
  22. As a developer running PR verification, I want the fast gate (tier0 and fast) to complete in under 5 seconds without benchmark contention, while benchmarks and live scenarios run in an isolated job.
  23. As a maintainer of Entity Graph storage (Pass 2), I want GraphStore to seal its raw database connection so no external caller or test can bypass the module interface.
  24. As an operator running 50+ concurrent subagents (Pass 2), I want all graph and timeline mutations to serialize through Write Queue Worker inside BEGIN IMMEDIATE transactions, so that concurrent writes never hit SQLite lock contention.
  25. As a forensic auditor (Pass 2), I want every graph, belief, decay, note, and timeline mutator to enforce Forensic Sealing on CLOSED sessions, so that sealed sessions are strictly immutable.
  26. As an operator querying the Entity Graph (Pass 2), I want pure read operations to execute on the read connection pool without blocking behind active write batches.
  27. As a consumer of GraphStore queries (Pass 2), I want returned node records to include hydrated pik and data dictionaries, so that callers do not repeatedly deserialize JSON strings.
  28. As an autonomous agent running Finding RAG in a multi-session database (Pass 2), I want vec0 Virtual Table KNN queries scoped by session_id, so that findings from other sessions never crowd out relevant results.
  29. As an operator or adapter using wordlists (Pass 2), I want Asset Resolver to resolve macros, $ETHER_WORDLISTS_DIR, SecLists, and minimal.txt uniformly across preflight and runtime without shipping bloated .txt.gz dictionaries.

Implementation Decisions

Pass 1: Execution, Scope, Transport & Tier Alignment (Tier 2/3 + Additive Tier-1 Helpers)

  • Canonical Execution & Flag Seam: Normalize flags and raw_flags once at the ActionRequest / Action Gateway seam into canonical raw_flags: str before policy validation, variable interpolation, and Tool Adapter dispatch. Reuse ActionGateway.infer_target_finding across CLI and PipelineEngine.
  • Single-Owner Spooling & Exit Codes: Collapse SubprocessCommandRunner into Executor implementing CommandRunner. Add exit_code: Optional[int] to JobStatus, transition non-zero exits to JobStatusEnum.FAILED (emitting ExecutionFailed and MCP NON_ZERO_EXIT) unless an adapter marks an exit code non-fatal, and assign Execution Session sole LogSpooler ownership with data_dir propagated through Execution Session, GraphStore.close_session, ForensicLogManager.find_action_log, and create_mcp_server.
  • Reactive Pipeline Execution & Persistence: Inject a CommandRunner / Execution Session seam into PipelineEngine so Tier B Adapter stages execute real commands, and make PipelineEngine the sole owner of store.upsert_finding when session_id is present (removing duplicate upserts from CLI and MCP callers).
  • Authoritative Scope Validator Seam: Consolidate target, CIDR, metadata, loopback, and pre-connect async DNS checks into Scope Validator with an injectable DNS resolver port. Under Gate Policy SAFE, block loopback by default unless Engagement Scope sets allow_loopback=True (ADR 0012). Enforce context.policy and Scope Validator uniformly across Action Gateway, http_probe, tls_probe, and fuzzer Baseline Calibration.
  • Manifest-Driven Preflight & Tier Alignment: Populate explicit target_types and execution_tier = "coroutine" on all applicable tool manifests, enforce manifest-adapter consistency in tier0 checks, and delete PromptNeutralizer, static preflight tool sets, and legacy flat action-log path helpers.
  • Thin CLI & MCP Transport Adapters: Push Tool Arsenal summaries, session-scoped Graph Analytics (with choke_points), list_all_sessions, and --unmask credential masking into engine modules; fix CLI crashes in run, logs, tool, and session close; make DriftEngine accept JSON-string baselines and strict HTTP header checks.

Pass 2: Sealed Entity Graph Persistence & Asset Resolver (Tier-1 + Docs)

  • Sealed GraphStore Interface: Replace external store.connection() callers (session list, GraphAnalyticsEngine.evaluate_and_persist, ActionTimelineRepository) with first-class GraphStore methods and remove connection() from the public interface. Delete unreachable dead code and duplicate anchor_hash derivation.
  • Universal Write Serialization & Forensic Sealing: Route all GraphStore and ActionTimelineRepository mutations through Write Queue Worker (BEGIN IMMEDIATE batches) with a centralized CLOSED-session guard raising PermissionError, and route all pure reads to _get_read_conn().
  • Hydrated Records & Scoped Vector Index Engine: Return hydrated pik and data dictionaries from GraphStore node queries, unify batch embedding sync in Vector Index Engine, and partition/scope vec_findings KNN queries by session_id (ADR 0012).
  • Consolidated Asset Resolver: Merge macro expansion and wordlist lookup into Asset Resolver with injectable search roots, wire PreflightVerifier and Action Gateway to it, and remove legacy wordlists shim and .txt.gz bundles per ADR 0011 Part 5.
  • Documentation Sync: Keep GLOSSARY.md, ADR 0012, and architecture/database/CLI/MCP guides synchronized with the final contracts.

Testing Decisions

  • Testing Philosophy: Test exclusively through public module interfaces and observable outcomes; never inspect private attributes (_get_conn(), _tool_manager, _buf, _session, _get_tool_target_types) or re-implement internal logic in tests. Delete placebo or retired-code tests (test_prompt_neutralizer) rather than layering over them.
  • Primary Test Seams:
    1. CLI & MCP Transport Seam: Exercise cli entrypoint and create_mcp_server tools end-to-end against real :memory: GraphStore and temporary data directories (covering run, logs, session close, tool list/info, graph --unmask, read_action_log on .log/.log.gz, and audit_drift with JSON strings).
    2. Action Gateway & Execution Session Seam: Exercise ActionGateway + Execution Session + PipelineEngine using an in-memory CommandRunner adapter and an injectable DNS resolver adapter on Scope Validator (covering flags normalization, non-zero exit failure, Audit Manifest verification, Gate Policy SAFE loopback default vs Engagement Scope(allow_loopback=True), and DNS rebinding/calibration SSRF).
    3. GraphStore & Asset Resolver Seam: Exercise GraphStore (with :memory: SQLite), Vector Index Engine multi-session search isolation, universal Forensic Sealing across all mutators, and Asset Resolver with injectable temp directories.
  • Prior Art & Gate Separation: Follow existing Hypothesis state-machine tests, universal adapter fuzzing, and MCP/CLI integration tests. Separate tier0 or fast (<5s PR gate) from benchmark and scenario suites so benchmarks never fail due to parallel suite contention.

Out of Scope

  • Any UI, Textual, or presentation widget code (preserving Ether's strict headless invariant).
  • Cloud vector databases or remote embedding APIs (preserving the 100% offline invariant).
  • Changing Primary Identity Key (PIK) SHA-256 identity derivation or schema schema_type naming contracts.

Further Notes

  • Domain terms (Engagement Scope, Reactive Pipeline, Asset Resolver) are recorded in GLOSSARY.md.
  • Hard-to-reverse contract changes (Gate Policy SAFE loopback default, NON_ZERO_EXIT semantics, Pass 2 sealed GraphStore and session-partitioned vec_findings) are recorded in ADR 0012.

Activity

  1. h45sh commented on Nov 25, 2026

    @h45sh
    OwnerAuthor

    Completed in full across Pass 1 & Pass 2 and landed on dev (commits c1f5de4 through d3036d6):

    Pass 1: Unified Execution, Scope & Transports

    • Execution & Spooling: Unified flag normalization (flags / raw_flags) at ActionRequest/ActionGateway seam, implemented non-zero exit code failure semantics (JobStatus.exit_code, ExecutionErrorCategory.NON_ZERO_EXIT), and single-owner LogSpooler with Audit Manifest recording.
    • Unified Scope & Manifests: Consolidated CIDR, metadata, loopback, and DNS pre-connect validation into ScopeValidator (GatePolicy.SAFE default-deny loopback unless EngagementScope(allow_loopback=True)). Aligned PreflightVerifier and tool manifests (execution_tier = "coroutine").
    • Thin Transports & Pipelines: Decomposed CLI and MCP to pure transport shims over headless execution engines, fixed real Tier B execution in Reactive Pipeline, and hardened DriftEngine.

    Pass 2: Sealed GraphStore Persistence & AssetResolver

    • Sealed GraphStore Seam: Removed raw connection() leaks from the public API, routed all mutators through WriteQueueWorker with universal CLOSED-session forensic sealing (PermissionError), and routed pure reads to _get_read_conn().
    • Hydrated Findings & Scoped Vector Index: Hydrated pik and data JSON dicts on node lookups, and partitioned vec_findings KNN search per session_id.
    • Consolidated AssetResolver: Unified wordlist discovery and macro expansion in ether.registry.assets and removed legacy wordlist bundles.
    • Documentation: Synced GLOSSARY.md and ADR 0012 (0012-sealed-graph-persistence-unified-scope-and-execution-seams.md).

    All 472 unit and integration tests passing with 76.61% branch coverage and 100% green CI across all matrix environments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions