Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions .machine_readable/STATE.a2ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
;; This file tracks the current state of the project using S-expressions.

(state
(version . "0.1.0")
(phase . "In development")
(updated . "2026-03-15")
(version . "0.1.0-dev")
(phase . "Pre-release verification")
(updated . "2026-04-16")
(status . "active")

(project
(name . "http-capability-gateway")
(completion . 0))
;; 19 Elixir modules implemented, 7 unit test files, 2 Zig FFI parsers,
;; 2 Idris2 ABI modules. Core gateway, policy pipeline, rate limiter,
;; circuit breaker, and proxy are functional. CRG grade C achieved.
;; Blockers: zero security tests, zero E2E tests, zero benchmarks.
(completion . 55)
(crg-grade . "C")
(crg-date . "2026-04-04"))
)
6 changes: 3 additions & 3 deletions IMPLEMENTATION-ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# http-capability-gateway - Implementation Roadmap

> NOTE (2026-03-30): This document is historical. The repository now contains a real Mix application, Elixir modules, and tests. Use `ROADMAP.adoc`, `TEST-NEEDS.md`, and `PROOF-NEEDS.md` as the current source of truth. The main gap is verification and scope control, not initial scaffolding.
> **HISTORICAL DOCUMENT (2026-04-16):** This document was written before any code existed and is no longer accurate. The repository now has 19 Elixir modules, 7 test files, 2 Zig FFI parsers, and 2 Idris2 ABI modules. The "What's Missing" list below is mostly **completed**. See `ROADMAP.adoc` and `STATE.adoc` for the current state.

**Created:** 2026-01-22
**Current Status:** 30% (Design Phase)
**Target:** MVP v0.1.0 (80-90%)
**Status at time of writing:** 30% (Design Phase) — **now ~55% with code implemented, verification lagging**
**Target:** MVP v0.1.0
**Estimated Effort:** 40-60 hours

---
Expand Down
76 changes: 66 additions & 10 deletions ROADMAP.adoc
Original file line number Diff line number Diff line change
@@ -1,21 +1,77 @@
// SPDX-License-Identifier: PMPL-1.0-or-later
= HTTP Capability Gateway Roadmap

== Current Status
== Current Status (2026-04-16)

The repository contains a real Elixir application, tests, and supporting docs, but the verification story still lags the implementation breadth.
Version 0.1.0-dev. CRG grade C (achieved 2026-04-04).

* The best near-term role for this project is a narrow API governance layer, not a universal front-door gateway.
* `TEST-NEEDS.md` and `PROOF-NEEDS.md` define the real confidence gap more accurately than the old template roadmap did.
* The main missing work is security depth, E2E proof, and scope discipline.
The repository contains 19 Elixir modules, 2 Zig FFI parsers, 2 Idris2 ABI
modules, and a growing test suite. The implementation covers the core gateway
pipeline but verification is catching up. See `STATE.adoc` for the full picture.

== MVP Scope Definition (v0.1.0)

The MVP is a *narrow HTTP verb governance prefilter*. It is NOT a general-purpose
API gateway, load balancer, or TLS terminator. The scope is intentionally
constrained so that every claim can be backed by an executed test.

=== What the MVP Does

1. *Policy loading*: Read a YAML policy file (DSL v1) at startup and on reload.
2. *Policy validation*: Reject malformed policies before compilation.
3. *Policy compilation*: Compile validated policy into dual ETS tables (exact O(1) + regex O(r) + global O(1)).
4. *Trust extraction*: Read trust level from `X-Trust-Level` header (stripped for non-trusted proxies).
5. *Verb governance*: For each request, lookup the policy rule for (path, verb) and evaluate `rank(trust) >= rank(exposure)`.
6. *Allow/deny*: Forward allowed requests to a single configured backend via HTTP. Deny with 403 or stealth response.
7. *Stealth mode*: Return configurable status codes (e.g. 404) instead of 403 to hide endpoint existence.
8. *Rate limiting*: Per-client token bucket with trust-level-based quotas.
9. *Health/readiness probes*: `/health`, `/ready` endpoints.
10. *Structured logging*: JSON-formatted access decisions with telemetry.
11. *Atomic policy reload*: Swap to new policy tables without downtime.

=== What the MVP Does NOT Do

* No GraphQL or gRPC governance (handlers exist but are stubs; not MVP scope)
* No multi-backend load balancing
* No TLS termination
* No dynamic trust scoring or control plane
* No plugin system
* No web UI dashboard
* No distributed clustering
* No Kubernetes operator

=== MVP Proof Requirements

Each claim above must have at least one passing test:

[cols="1,2",options="header"]
|===
| Claim | Test File

| Policy loading | `test/policy_loader_test.exs`
| Policy validation | `test/policy_validator_test.exs`
| Policy compilation | `test/policy_compiler_test.exs`
| Trust extraction | `test/security_test.exs` (header handling)
| Verb governance | `test/gateway_test.exs`, `test/e2e_test.exs`
| Allow/deny decisions | `test/e2e_test.exs` (full lifecycle)
| Stealth mode | `test/gateway_test.exs` (stealth describe block)
| Rate limiting | `test/gateway_test.exs` (via plug pipeline)
| Health/readiness | `test/e2e_test.exs` (health and readiness)
| Structured logging | Telemetry events emitted (verified by integration)
| Atomic policy reload | `test/e2e_test.exs` (hot-reload tests)
| Request sanitization | `test/security_test.exs`
| Trust spoofing prevention | `test/security_test.exs` (header stripping)
| No atom exhaustion | `test/fuzz_test.exs` (arbitrary method strings)
| No crash on arbitrary input | `test/fuzz_test.exs` (combined fuzzing)
|===

== P0 Release Blockers

* [ ] Reconcile contradictory status docs so the repo has one truthful current-state story.
* [ ] Add real security tests for request sanitization, header handling, SSRF resistance, and capability-token validation.
* [ ] Add end-to-end tests for request lifecycle, policy hot reload, and upstream proxy behavior.
* [ ] Remove or replace `tests/fuzz/placeholder.txt`.
* [ ] Define the supported MVP narrowly enough that it can be proven.
* [x] Reconcile contradictory status docs so the repo has one truthful current-state story.
* [x] Add real security tests for request sanitization, header handling, SSRF resistance, and capability-token validation.
* [x] Add end-to-end tests for request lifecycle, policy hot reload, and upstream proxy behavior.
* [x] Remove `tests/fuzz/placeholder.txt` and add real property-based fuzz tests.
* [x] Define the supported MVP narrowly enough that it can be proven.

== P1 Gateway Hardening

Expand Down
55 changes: 55 additions & 0 deletions STATE.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// SPDX-License-Identifier: PMPL-1.0-or-later
= HTTP Capability Gateway — Current State
:date: 2026-04-16

== Version

0.1.0-dev (pre-release)

== CRG Grade

C (achieved 2026-04-04)

== What Exists

=== Elixir Modules (19)

Core gateway pipeline, policy loader/validator/compiler, rate limiter,
circuit breaker, proxy, GraphQL handler, gRPC handler, protocol router,
structured logging, Minikaran anomaly detection, VeriSimDB audit client,
SafeTrust (formally specified trust hierarchy), K9 service contracts.

=== FFI

* 2 Zig parsers: `ffi/zig/graphql/parser.zig`, `ffi/zig/grpc/parser.zig`
* 2 Idris2 ABI modules: `src/abi/Protocol.idr`, `src/abi/Types.idr`

=== Tests

* 7 unit test files covering: gateway, policy_compiler, policy_loader,
policy_validator, policy_property, performance, http_capability_gateway
* 0 integration tests
* 0 end-to-end tests
* 0 security tests
* 0 benchmarks

== What's Missing (P0 Release Blockers)

See `ROADMAP.adoc` for full details. Summary:

1. Security tests (request sanitization, header handling, SSRF, capability tokens)
2. End-to-end tests (request lifecycle, policy hot-reload, upstream proxy)
3. Benchmarks
4. Real fuzz harness (placeholder exists, not real)

== Authoritative Documents

* `ROADMAP.adoc` — Current roadmap (canonical)
* `TEST-NEEDS.md` — Test gap analysis
* `PROOFS_NEEDED.md` — Formal proof gap analysis
* `.machine_readable/STATE.a2ml` — Machine-readable state

== Historical Documents

* `IMPLEMENTATION-ROADMAP.md` — Written before code existed; no longer reflects reality
* `ROADMAP-v2.md` — Aspirational v2 feature list; not current work
17 changes: 9 additions & 8 deletions TEST-NEEDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

> Generated 2026-03-29 by punishing audit.

## Current State
## Current State (updated 2026-04-16)

| Category | Count | Notes |
|-------------|-------|-------|
| Unit tests | 7 | gateway, policy_compiler, policy_loader, policy_validator, policy_property, performance, http_capability_gateway |
| Integration | 0 | Fuzz dir exists but is placeholder only |
| E2E | 0 | No end-to-end tests |
| Security | 1 | security_test.exs: sanitization, headers, SSRF, capability tokens (30+ tests) |
| E2E | 1 | e2e_test.exs: full lifecycle, policy hot-reload, upstream proxy, health probes (20+ tests) |
| Fuzz | 1 | fuzz_test.exs: property-based fuzzing with StreamData (6 properties) |
| Benchmarks | 0 | None |

**Source modules:** ~19 Elixir modules (gateway, circuit_breaker, proxy, rate_limiter, safe_trust, graphql_handler, grpc_handler, policy_*, minikaran, logging, etc.) + 2 Idris2 ABI + 4 Zig FFI.
Expand All @@ -30,7 +31,7 @@
- [ ] Health check / readiness probe validation

### Aspect Tests
- **Security:** Request sanitization, header injection, SSRF prevention, capability token validation — ZERO tests
- **Security:** Request sanitization, header injection, SSRF prevention, capability token validation — covered in `test/security_test.exs`
- **Performance:** No load tests, no latency benchmarks, no throughput measurement
- **Concurrency:** No tests for concurrent connections, race conditions in rate limiter, circuit breaker under contention
- **Error handling:** No tests for upstream timeout, malformed requests, policy parse failures
Expand All @@ -55,8 +56,8 @@

**CRITICAL.** 19 modules with 7 unit tests = 37% coverage by file count. A security gateway with ZERO security tests is a contradiction. No benchmarks for a performance-sensitive proxy is unacceptable. No concurrency tests for a concurrent system is negligent.

## FAKE-FUZZ ALERT
## FUZZ STATUS

- `tests/fuzz/placeholder.txt` is a scorecard placeholder inherited from rsr-template-repo — it does NOT provide real fuzz testing
- Replace with an actual fuzz harness (see rsr-template-repo/tests/fuzz/README.adoc) or remove the file
- Priority: P2 — creates false impression of fuzz coverage
- `tests/fuzz/placeholder.txt` has been removed (was a scorecard placeholder, not real fuzzing).
- Real property-based fuzz tests added in `test/fuzz_test.exs` using StreamData.
- Covers: arbitrary HTTP methods, trust strings, paths, policies, and combined input fuzzing.
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule HttpCapabilityGateway.MixProject do
def project do
[
app: :http_capability_gateway,
version: "1.0.0",
version: "0.1.0-dev",
elixir: "~> 1.19",
start_permanent: Mix.env() == :prod,
deps: deps(),
Expand Down
Loading
Loading