Architecture, Security & Multi-Agent Review Model
EPURE is built from the ground up around Defense-in-Depth, Least Privilege, and Out-of-Branch Deterministic State. Every automation boundary is enforced both by GitHub Repository Rulesets and by local runtime sandboxing.
Interactive Event & Custom Actions Pipeline Diagram: See the
epure-ci-actions-flowdiagram in Commands Reference for the complete mapping of GitHub events (issue_comment,check_suite,workflow_run,pull_request,workflow_dispatch), secretlessauthorize-command, environment-scopedorchestrate-command(environment: <llm-env>), andreleasepromotion.
1. Security & Trust Boundaries Architecture
Loading interactive Archify blueprint…
Key Architectural Invariants
- Dual GitHub App Separation & Environment-Scoped Secrets (
<owner>-epure-agentvs.<owner>-epure-release, Q82 & Q91):- The Agent App mints short-lived RS256 installation tokens scoped to day-to-day orchestration (
plan/*,task/*,feature/*). Its credentials (EPURE_AGENT_APP_ID,EPURE_AGENT_APP_PRIVATE_KEY) andLLM_API_KEYare scoped to the dedicated agent GitHub Environment (<llm-env>) and never exposed toauthorize-commandor public PR workflows. It is a Bypass Actor only onepure-feature-governance(refs/heads/feature/*), allowing autonomous integration of verified atomic tasks while physically blocking it from merging application code intodevor pushing tomain. - The Release App is invoked exclusively by
release-promote.yml/release.ymlunder humanworkflow_dispatchinside the protectedreleaseGitHub Environment (EPURE_RELEASE_APP_ID,EPURE_RELEASE_APP_PRIVATE_KEY). It is the sole Bypass Actor onepure-release-immutability(refs/heads/mainandrefs/tags/v*).
- The Agent App mints short-lived RS256 installation tokens scoped to day-to-day orchestration (
- Secretless Sandbox Execution (Q74):
- When EPURE runs
npm test,npm run build, orpyteston atask/*branch, the child process environment is scrubbed ofLLM_API_KEY,EPURE_AGENT_APP_PRIVATE_KEY, andEPURE_RELEASE_APP_PRIVATE_KEY. - A malicious or compromised test script cannot exfiltrate credentials. If sandbox isolation fails, EPURE aborts fail-closed.
- When EPURE runs
- Out-of-Branch CAS State (
refs/epure/state/<issue>, Q76):- State transitions (
last_processed_comment_id, signedspec_sha, retry counters, ticket status table, and active CI continuation subphases) are stored as JSON blobs insiderefs/epure/state/<issue-number>updated via atomicgit update-refCompare-And-Swap. devandmainremain 100% free of machine-state commit noise.
- State transitions (
2. Multi-Agent PR Review, Impeccable Gate & AI Squash Pipeline
Loading interactive Archify blueprint…
How the Review Pipeline Works (Q92–Q96)
- Trusted
devRoster Loading & Prompt-Injection Defense (OWASP LLM01):- Reviewer prompts (
<reviewers_dir>/*.md, default.agents/reviewers/*.md) are always loaded from the trusteddevbranch (with fallback to EPURE's embedded canonical templates), never from the untrustedtask/*branch under review. - All PR diffs, commit messages, and issue comments are wrapped inside
<untrusted_pr_diff>XML delimiters with explicit instructions to ignore any embedded prompt-override directives.
- Reviewer prompts (
- Dynamic Selection (Up to 4 Specialists +
spec-parity-reviewer):- Based on the files touched in the PR diff, EPURE selects up to 4 relevant reviewers from the roster (
domain-backend-reviewer,frontend-reviewer,infra-reviewer,architecture-reviewer,security-reviewer,standards-reviewer,accessibility-reviewer,design-reviewer,user-advocate) alongside the mandatoryspec-parity-reviewer.
- Based on the files touched in the PR diff, EPURE selects up to 4 relevant reviewers from the roster (
- Read-Only Codebase Inspection Tools:
- Reviewers are not restricted to a narrow unified diff: they can invoke 4 read-only tools (
list_files,read_file,read_line_range,search_code) to trace callers, types, and domain invariants across the repository.
- Reviewers are not restricted to a narrow unified diff: they can invoke 4 read-only tools (
- Targeted Auto-Remediation (
max_code_fix_attempts = 3):- If any reviewer emits a
must_fixitem, EPURE runs a targeted code fix in the secretless sandbox and re-runs only the reviewers that failed in the previous round plusspec-parity-reviewer. - On
feature/* -> devsynthesis PRs, any remediation is routed through atask/review-fix-*PR soepure-feature-governanceis respected.
- If any reviewer emits a
- AI Semantic Squash Synthesis (Q94):
- Immediately before merging a validated PR, a zero-temperature call synthesizes a clean Conventional Commit title (
type(scope): summary (#PR)) and bulleted body (Refs #<ticket>onfeature/*,Closes #<issue>/Closes #<ticket>ondev).
- Immediately before merging a validated PR, a zero-temperature call synthesizes a clean Conventional Commit title (
- Integrated Upstream Quality & Audit Engines:
- Matt Pocock Agent Skills (
mattpocock/skills) — Specification-driven skills (grill-with-docs,to-spec,to-tickets,tdd,code-review) pinned inskills-lock.json. - Impeccable (
pbakaus/impeccable) — Design system (DESIGN.md) and WCAG 2.1 AA frontend quality gate (actions/impeccable). - iFixAi (
ifixai-ai/iFixAi) — Deterministic authorization trajectory auditing (actions/ifixai). - Archify (
tt-a1i/archify) — Showcase-validated interactive architecture diagrams (scripts/archify/). - zizmor (
woodruffw/zizmor) — GitHub Actions workflow static security analysis (actions/zizmor-audit). - Renovate (
renovatebot/renovate) — Automated updates of SHA-pinned workflows and dependencies (auto_migrate).
- Matt Pocock Agent Skills (
3. Multi-Provider LLMClient, Native Structured Outputs & Modular Orchestrator (ADR-0029)
- Multi-Provider HTTP Router (
src/llm/):- Zero-dependency TypeScript
LLMClientrouting<provider>/<model>identifiers across Google Gemini (google/,gemini/), OpenAI (openai/), Azure OpenAI (azure/), Azure AI Foundry (azure_ai/), and Anthropic (anthropic/), withos.environ/VAR_NAMElazy resolution from.github/agents.yml. - Enforces ADR-0012 fail-fast resilience: HTTP
401/403(AuthenticationError) and402(QuotaExhaustedError) immediately halt without silent fallback, while transient408/429/5xxerrors apply bounded exponential backoff.
- Zero-dependency TypeScript
- Native Schema-Enforced Structured Outputs (
ResponseSchemaSpec<T>) & 2-Phase Gemini Tool Loop:- All structured LLM calls (
GrillRoundEvaluation,GeneratedPlanningBundle,GeneratedTicketImplementation, multi-agent reviewer findings,user-advocate, and squash commit synthesis) send formal JSON Schemas (responseSchema,response_format.json_schemawith recursiveadditionalProperties: false, oroutput_config.format) paired with runtime TypeScript validators insrc/orchestrator/prompts/schemas.ts. - When Google Gemini calls combine repository exploration tools (
list_repo_files,search_in_repo_file,read_repo_file) with aResponseSchemaSpec, Phase 1 executes tool rounds withfunctionDeclarations(preserving Gemini 3thoughtSignaturetokens), and Phase 2 finalizes withfunctionCallingConfig.mode = "NONE"+responseMimeType: "application/json"+responseSchema.
- All structured LLM calls (
- Modular
src/orchestrator/Architecture & Wired Safety Guards:src/orchestrator/issue-orchestrator.tsacts as a clean coordinator delegating togithub/rest-client.ts,workspace/repo-tools.ts,prompts/schemas.ts,formatting/comments.ts, and the phase modulesphases/grill-and-plan.ts,phases/ticket-execution.ts, andphases/feature-integration.ts.- Enforces DAG cycle detection (
validatePlanningArtifactsAndGraph), proven blocker resolution (reconcileProvenTicketDependencies, escalating toneeds-humanonnot_plannedclosures), mid-run/epure cancelbatch cursor checks (processPendingIssueCommentsBatch), and commit-SHA review loop guards (evaluateReviewFeedbackTrigger).
4. 3-Stage Verification Pipeline, Ubuntu 26.04 Kernel Sandbox & Event-Driven CI Continuation (ADR-0028, ADR-0030, ADR-0031)
- Stage 1 — 2-Phase Linux Kernel Sandbox, Stateless
rtkCondensation & Per-Ticket Goldfish Isolation:- Runs on
ubuntu-26.04(Linux kernel 7.0) inside a persistent local Git clone before any commit is pushed totask/*:- Phase A (
install,networkPolicy: "https_only"): Executes dependency installation underlandrun(Landlock ABI v8), restricting outbound TCP to port443and filesystem writes toworkDir,/tmp, and package caches. - Phase B (
codegen,typecheck,lint,test,build,networkPolicy: "offline"): Executes completely offline underbubblewrap(bwrap --unshare-net --unshare-pid --unshare-ipc --tmpfs /tmp --die-with-parent, with automatic fallback to offlinelandrun).
- Phase A (
- Stateless
rtkOutput Condensation (formatAndCondenseStage1CommandOutput): Strips ANSI sequences, progress bars, and noisy test logs in 100% stateless mode (RTK_TELEMETRY_DISABLED=1,RTK_RECALL=0,RTK_TEE=0, no SQLite database) while preserving the raw 4,000-character error tail wheneverexit_code !== 0. - 3-Way Git Branch Sync (
/epure sync) & Goldfish Isolation: Keepsdev -> feature/* -> task/*synchronized with 3-way LLM conflict resolution validated by Stage 1, and executes each ticket in a fresh zero-context Goldfish session (runGoldfishSpecAuditduring/epure to-spec).
- Runs on
- Stage 2 — Event-Driven External CI Continuation (
waiting_ticket_ci/waiting_feature_ci):- Once Stage 1 passes and the
task/* -> feature/*orfeature/* -> devPull Request is opened alongside theai-reviewcheck, EPURE recordssubphase: "waiting_ticket_ci"(or"waiting_feature_ci"),active_pr_number, andactive_head_shainrefs/epure/state/<issue>and immediately exits0(async_ci_continuation: true). - No runner sits idle polling external workflows. When GitHub emits
check_suite.completedorworkflow_run.completed(or a human posts/epure continue), EPURE resumes from the exact persisted state.
- Once Stage 1 passes and the
- Stage 3 — Trusted
devMulti-Agent Review Roster & AI Semantic Squash:- Correlates external CI results with the multi-agent specialist review roster loaded from
dev. If external CI or any reviewer fails, EPURE extracts sanitized failure logs (~12 KB) and executes up tomax_code_fix_attempts = 3unified remediation rounds before AI semantic squash-mergingtask/* -> feature/*.
- Correlates external CI results with the multi-agent specialist review roster loaded from
5. Incremental Workspace Mutation Tools, Inter-Ticket Guard & Multi-Phase Epic Convergence (ADR-0032, ADR-0033)
- Transactional Incremental Workspace Mutation (
StagedTicketImplementationBuffer):- During ticket implementation and remediation tool loops, the model mutates files incrementally via
write_repo_file,patch_repo_file, anddelete_repo_fileinside an in-memory transactional buffer (StagedTicketImplementationBuffer), isolated fromfeature/*untilvalidateWorkspaceFileOperations,validateTicketIntegrityGuard, and Stage 1 sandbox checks succeed. - Chunked File-by-File Fallback (
ChunkedTicketImplementationFallback): If a multi-file ticket hitsMAX_TOKENSoutput truncation, EPURE automatically decomposes the remainingfilesToTouchentries into file-by-file sub-calls (preserving already staged mutations in the buffer and rolling back atomically if any sub-call fails). - Zero-Truncation Context Catalog (
CompactWorkspaceFilesContext): Injects full, untruncated file contents only for files modified by the ticket or listed infilesToTouch, and exposes the rest of the repository as a compactpath (N lines)index inspectable on demand viaread_repo_fileandsearch_in_repo_file.
- During ticket implementation and remediation tool loops, the model mutates files incrementally via
- Native GitHub Relational Graph, Inter-Ticket Integrity Guard & Semantic ADR Reconciliation:
/epure to-ticketswires native GitHubsub_issuesanddependencies/blocked_byrelationships alongside the Markdown tasklist on the tracking issue.validateTicketIntegrityGuardblocks any ticket from deleting or emptying pre-existing test files, truncating >30% of lines/exports on out-of-scope files, or downgrading manifestbuild/test/lint/typecheckscripts into no-op commands.renumberCollidingAdrsandreconcileAdrsWithLlmdeduplicate ADR slugs across concurrent branches, renumber collidingdocs/adr/NNNN-*.mdfiles monotonically, and align cross-references in specs andGLOSSARY.md.
- Zero-Context
EpicConvergenceAudit& Multi-Phase Remediation (max_epic_phases):- Before opening the final
feature/* -> devPR, an isolated zero-context session (runEpicConvergenceAudit) verifies the feature branch against the specification'sEpicGoalContract(required_entrypoints, absence offorbidden_stubs, andend_to_end_verification_criteria). - If unwired modules or stubs are detected (
verdict: "INCOMPLETE") andepic_phase < max_epic_phases(default2), EPURE automatically generates, links, and executes bounded Phase 2 convergence tickets ([Phase 2 - Ticket N]) before opening the final PR; otherwise it escalates withepic_convergence_exhausted(needs-human).
- Before opening the final

