407 lines
28 KiB
Markdown
407 lines
28 KiB
Markdown
---
|
||
story_id: "1.9"
|
||
story_key: "1-9-outbound-rest"
|
||
requirement: "FR-2"
|
||
status: "done"
|
||
baseline_commit: "767428436d3a54e60809a727044dfcec48e1f1dd + uncommitted Story 1.7/1.8 worktree"
|
||
created: "2026-08-15T14:50:28+03:00"
|
||
---
|
||
|
||
# Story 1.9: Защитить каждое outbound REST-соединение
|
||
|
||
Status: done
|
||
|
||
## Story
|
||
|
||
As an оператор закрытого контура,
|
||
I want применять единую fail-closed outbound policy ко всем REST executions,
|
||
so that пользовательская конфигурация не превращает Crank в SSRF, proxy bypass или механизм истощения ресурсов.
|
||
|
||
## Operational Brief
|
||
|
||
Story 1.9 закрывает security boundary внешних REST-вызовов после Story 1.8. В 1.8 Admin Test и MCP `tools/call` были сведены к единому typed execution pipeline и одной error taxonomy. Теперь надо сделать этот pipeline безопасным на уровне сети: фактический адрес соединения, DNS rebinding, redirects, proxy, reserved headers, body/response/deadline/concurrency bounds и retry/idempotency должны вести себя одинаково для Admin и MCP.
|
||
|
||
Значение для плана: это обязательная основа для безопасного REST Tool в Epic 1 и будущих REST-backed Resources, OpenAPI external refs, Tasks и Load Runs. Без 1.9 продукт может быть функционально рабочим, но всё ещё опасным как SSRF/proxy/resource-exhaustion механизм внутри закрытого контура.
|
||
|
||
**Requirement:** FR-2
|
||
**Primary architecture:** AD-9, AD-11, AD-21, AD-23; AD-1/4/17/19/20 conventions
|
||
**Applicable NFR:** NFR-S1, NFR-S2, NFR-S3, NFR-S4, NFR-S7, NFR-S8, NFR-O1, NFR-O4, NFR-O5, NFR-C1, NFR-C4
|
||
**Primary risk/evidence:** E1-R-008, score 9; E1-20/E1-21 P0 suites.
|
||
|
||
## Scope
|
||
|
||
In scope:
|
||
|
||
- Shared `OutboundPolicy`/`OutboundHttpPolicy` for every current REST execution path: Admin Draft Test and MCP Tool call.
|
||
- Actual-connect address validation after DNS resolution for IPv4/IPv6, with deny-before-allow semantics.
|
||
- DNS rebinding and retry address revalidation; a previously allowed hostname does not authorize a later forbidden address.
|
||
- Redirect behavior: disabled by default; optional explicit redirect policy only with hop revalidation, hop limit and credential stripping.
|
||
- System proxy disabled by default; any future explicit proxy configuration must be typed, validated and subject to the same outbound policy.
|
||
- Reserved system headers: correlation, `Host`, content length, transfer encoding and Auth Profile credentials cannot be overridden by static/mapped user headers.
|
||
- Request, response, deadline, concurrency and retry bounds before unbounded wait/body accumulation.
|
||
- Retry policy for reads and writes, including idempotency/side-effect honesty from AD-9.
|
||
- Safe typed outcomes and redaction for all outbound failures.
|
||
- Capability Inventory evidence for FR-2, NFR-S3 and NFR-S4 after tests pass.
|
||
|
||
Out of scope:
|
||
|
||
- New Resources/Prompts/Tasks/Load Runs implementation.
|
||
- OpenAPI external-reference fetching, except documenting that it must later reuse or narrow this policy.
|
||
- Grafana/Prometheus dashboards, GlitchTip trace delivery or browser trace UI.
|
||
- New Auth Profile/key lifecycle semantics from Story 1.10.
|
||
- Full background retry/reconciliation UI from Epic 4.
|
||
- Broad dependency/toolchain upgrades or replacement of Reqwest.
|
||
|
||
## Acceptance Criteria
|
||
|
||
1. **Actual-connect policy on every REST execution**
|
||
- Given Admin Test or MCP Tool execution
|
||
- When REST adapter opens a connection
|
||
- Then shared `OutboundPolicy` validates the actual resolved address immediately before each connection attempt
|
||
- And deny rules have priority over allow rules
|
||
- And Admin and MCP use the same policy instance derived from typed config.
|
||
|
||
2. **Forbidden address classes are blocked before HTTP bytes leave**
|
||
- Given a hostname resolving to loopback, private, link-local, multicast, unspecified, documentation, carrier-grade NAT, IPv4-mapped IPv6 or forbidden service address
|
||
- When adapter attempts IPv4 or IPv6 connection
|
||
- Then execution is blocked before sending request line, headers or body
|
||
- And the safe error does not reveal internal network topology, DNS answers, full URL, credentials or policy internals.
|
||
|
||
3. **DNS rebinding and retry address revalidation**
|
||
- Given a hostname whose DNS result changes between validation and connection or between retries
|
||
- When connection attempt or retry runs
|
||
- Then policy is re-applied to the address actually used for that attempt
|
||
- And a previously allowed resolution cannot authorize a later forbidden IP.
|
||
|
||
4. **Redirects are fail-closed**
|
||
- Given upstream redirect
|
||
- When redirects are not explicitly enabled by Operation/outbound policy
|
||
- Then adapter does not follow the redirect and returns a typed non-retryable policy outcome.
|
||
|
||
5. **Allowed redirects are bounded and revalidated**
|
||
- Given an explicit redirect contract
|
||
- When upstream returns a new `Location`
|
||
- Then scheme, host, port and actual resolved address pass policy on every hop
|
||
- And hop count is bounded
|
||
- And `Authorization`, `Cookie`, API-key headers and Auth Profile material are stripped on cross-origin redirect.
|
||
|
||
6. **System proxy is off by default**
|
||
- Given process environment contains `HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY` or `NO_PROXY`
|
||
- When production HTTP client is created
|
||
- Then system proxy is not used by default
|
||
- And proxy can be enabled only through typed operator configuration, with the proxy target itself passing outbound policy.
|
||
|
||
7. **Reserved headers cannot be overridden**
|
||
- Given static or mapped user headers
|
||
- When outbound request is formed
|
||
- Then system correlation headers, `Host`, `Content-Length`, `Transfer-Encoding`, selected Auth Profile credential headers and any safety/idempotency headers have priority
|
||
- And invalid/forbidden user header names are rejected before dispatch with a stable typed outcome.
|
||
|
||
8. **Resource bounds apply before unbounded allocation or wait**
|
||
- Given configured request, response, concurrency and deadline limits
|
||
- When REST call runs
|
||
- Then request body size, response body size, streaming accumulation, connection/read timeout, total execution deadline and runtime concurrency are enforced
|
||
- And oversized request, oversized response, timeout, deadline, exhausted concurrency and invalid config map to distinct typed outcomes.
|
||
|
||
9. **Retry obeys side-effect honesty**
|
||
- Given retry-enabled Operation
|
||
- When retryable failure occurs
|
||
- Then retries respect total deadline, max attempts, bounded backoff and per-attempt outbound policy
|
||
- And write without verified upstream idempotency contract is never retried automatically after dispatch uncertainty
|
||
- And write with verified idempotency forwards the configured idempotency key within full workspace/Agent/Operation/version/input scope.
|
||
|
||
10. **Invalid outbound configuration fails closed**
|
||
- Given invalid or unsafe production outbound configuration
|
||
- When process starts or readiness validates dependencies
|
||
- Then affected safety path fails closed with stable config diagnostic
|
||
- And policy cannot silently fall back to permissive defaults.
|
||
|
||
11. **Security matrix and redaction**
|
||
- Given outbound security suite
|
||
- When negative tests run
|
||
- Then IPv4/IPv6 variants, encoded/embedded hosts, DNS rebinding, redirects, proxy environment, reserved headers, oversized bodies, timeouts and concurrency saturation are covered
|
||
- And logs, traces, metrics, test failures, UI error, Admin response and MCP content contain no credentials, full target URLs, private IPs, payload canaries or host paths.
|
||
|
||
12. **Cross-ingress evidence**
|
||
- Given story completion
|
||
- When Admin Test and MCP execute the same outbound scenarios
|
||
- Then one contract suite proves identical normalized `error_code`, stage, retryability, certainty, dispatch evidence and adapter call/byte-send counts
|
||
- And `just verify`, targeted malicious-network suites and Capability Inventory checks pass without dependency/toolchain/public-success-wire changes.
|
||
|
||
## Frozen Outbound Contract
|
||
|
||
### Policy model
|
||
|
||
- Deny-before-allow is mandatory. A deny match rejects even if an allow pattern also matches.
|
||
- Explicit allow can permit private/internal targets for closed-contour use, but every allowed host/IP is still bounded by configured limits, reserved header rules and redaction.
|
||
- URL userinfo is always forbidden. `http://user:pass@host`, percent-encoded credential tricks and credentials in redirects are blocked or stripped before dispatch.
|
||
- Host normalization must handle case, trailing dot, bracketed IPv6, IPv4-mapped IPv6 and obvious encoded/ambiguous forms deterministically.
|
||
- Validation at save/publish is advisory. Actual-connect validation in the adapter is authoritative and must run for every attempt.
|
||
|
||
### Reserved header set
|
||
|
||
At minimum the following user-supplied static/mapped headers cannot override system values:
|
||
|
||
- Correlation: `traceparent`, `tracestate`, `baggage`, `x-request-id`, `x-trace-id`, `x-correlation-id`.
|
||
- HTTP framing/routing: `host`, `content-length`, `transfer-encoding`, `connection`, `upgrade`.
|
||
- Credentials selected by Auth Profile: `authorization`, `cookie`, configured API-key header names.
|
||
- Safety/idempotency headers selected by runtime policy.
|
||
|
||
The implementation may reject forbidden user header names or ignore them only when the behavior is deterministic, tested and documented. Credential/safety override must never silently win over system values.
|
||
|
||
### Retry rules
|
||
|
||
- `GET`/`HEAD` may retry known safe transient failures only within the total deadline.
|
||
- Mutating methods `POST|PUT|PATCH|DELETE` may retry automatically only when an idempotency policy is verified and the idempotency key was set before dispatch.
|
||
- Any failure after `DispatchEvidence::MayHaveDispatched` on a mutating operation without verified idempotency becomes `manual_reconcile + outcome_unknown`, inherited from Story 1.8.
|
||
- Retry attempts must create separate attempt observations/spans but keep the same Request ID and parent Trace ID.
|
||
|
||
### Typed outcomes
|
||
|
||
Use the closed Story 1.8 taxonomy. Story 1.9 may add typed outbound policy context internally, but public error-code additions require updating:
|
||
|
||
- `crank-core` enum and RU/EN catalog
|
||
- Admin/MCP projection tests
|
||
- v5 or later persistence checks if persisted
|
||
- docs and capability evidence
|
||
|
||
Prefer existing `outbound_target_rejected`, `adapter_configuration_invalid`, `upstream_timeout`, `upstream_transport_error`, `upstream_response_too_large`, `execution_overloaded`, `idempotency_outcome_unknown` where semantically correct.
|
||
|
||
## Current Brownfield State
|
||
|
||
- `crates/crank-adapter-rest` already owns the HTTP client and exports `OutboundHttpPolicy` and `RestAdapter`.
|
||
- The current adapter already sets `redirect(Policy::none())`, `no_proxy()`, a custom `PolicyDnsResolver`, response body bound and reserved correlation-header suppression.
|
||
- Current host/IP checks are useful but incomplete for the full AC matrix. They rely on resolver filtering and `reqwest::Error::is_connect()` to infer `NotDispatched`; Story 1.9 must prove byte-send/dispatch evidence at the adapter boundary.
|
||
- `OutboundHttpPolicy` currently stores `allowed_hosts`, `denied_hosts` and `max_response_bytes`; it does not model redirects, proxy enablement, request body max, retry attempts/backoff or credential-strip policy.
|
||
- `RestAdapterError` currently includes raw fields such as invalid base URL or rejected target. Boundary projection from Story 1.8 is safe, but test failure/log/error Display can still leak raw values unless hardened.
|
||
- Runtime currently sets a coarse `dispatch_started` flag before invoking the adapter. That is not enough to prove whether HTTP data left the process.
|
||
- Config already owns `CRANK_OUTBOUND_ALLOWED_HOSTS`, `CRANK_OUTBOUND_DENIED_HOSTS`, `CRANK_OUTBOUND_MAX_RESPONSE_BYTES`. Add new outbound config only through `crank-config` field registry/schema/docs/examples/tests.
|
||
- Admin save/publish validates `base_url` using the outbound policy. This is only preflight; it must not be treated as a substitute for actual-connect checks.
|
||
- Admin and MCP runtime builders already inject the same `OutboundHttpPolicy` from typed process config. Preserve this wiring.
|
||
- Story 1.8 has unified Admin/MCP execution and closed error taxonomy. Do not reintroduce separate Admin/MCP outbound paths.
|
||
|
||
## Developer Guardrails
|
||
|
||
- Do not replace Reqwest or add a new HTTP client dependency unless there is a proven blocker. Existing stack is Reqwest `0.12`, Tokio `1`, Rust `1.96.1`.
|
||
- Do not read environment variables in `crank-adapter-rest`, `crank-runtime`, Admin service or MCP. Runtime config belongs to `crank-config`; apps pass validated values.
|
||
- Do not move SSRF policy into Admin-only validation. The adapter is the enforcement owner because DNS/retry/redirect decisions happen at connection time.
|
||
- Do not weaken Community closed-contour behavior by permitting arbitrary proxy use. Proxy support, if added, is explicit typed operator configuration only.
|
||
- Do not put host, URL, DNS answer, object ID, request ID, trace ID, error text or payload in metric labels.
|
||
- Do not expose raw URL/body/header values in `Debug`, `Display`, test snapshots, docs examples, logs or UI messages.
|
||
- Do not mutate Story 1.4 migration v1-v5 bytes unless the implementation truly needs a new durable schema; expected path for 1.9 should be code/config/tests/docs only.
|
||
- Do not claim OpenAPI external refs, Resources, Tasks, Load Runs or production Prometheus/Grafana are complete because they inherit the policy later.
|
||
|
||
## File Map
|
||
|
||
Expected UPDATE:
|
||
|
||
- `crates/crank-adapter-rest/src/client.rs` — policy model, resolver/connect enforcement, redirect/proxy/header/body/response/deadline handling.
|
||
- `crates/crank-adapter-rest/src/error.rs` and `src/lib.rs` — typed safe errors and dispatch evidence projection.
|
||
- `crates/crank-adapter-rest/tests/integration/client.rs` or split tests — malicious-network and header/redirect/proxy/bounds cases.
|
||
- `crates/crank-runtime/src/{executor.rs,execution_failure.rs,idempotency.rs}` — retry/idempotency/dispatch evidence semantics only where adapter evidence must flow upward.
|
||
- `crates/crank-runtime/tests/{stages.rs,product_metrics.rs,integration/idempotency.rs}` and possible new outbound integration tests.
|
||
- `crates/crank-core/src/{operation.rs,execution.rs,ext/protocol.rs}` only if retry/policy/header contract requires new typed fields.
|
||
- `apps/admin-api/src/{main.rs,service.rs,dto.rs,error.rs}` only for config projection, validation and boundary projection.
|
||
- `crates/crank-community-mcp/src/{app.rs,tool_error.rs}` only for parity evidence if shared outcome projection needs adjustment.
|
||
- `crates/crank-config/src/{schema.rs,process.rs,render.rs}` plus config tests/docs if new outbound fields are added.
|
||
- `docs/{runtime-config.md,execution-boundary.md,observability.md,tool-design.md,admin-api.md,mcp-interface.md}` as applicable.
|
||
- `docs/capability-inventory.json` and baseline manifest/results only after evidence passes.
|
||
- Existing boundary/health scripts if direct outbound bypass scanning is extended.
|
||
|
||
Likely NEW:
|
||
|
||
- `crates/crank-adapter-rest/tests/integration/outbound_security.rs` for hermetic DNS/HTTP malicious-network matrix.
|
||
- Focused test support module for controlled DNS answers, redirect chains and byte-send counters if existing test server is insufficient.
|
||
- `docs/outbound-rest-security.md` if the policy becomes too detailed for existing docs.
|
||
|
||
Must preserve:
|
||
|
||
- Story 1.7 immutable Operation semantics and Story 1.8 unified execution contract.
|
||
- Public success wire fields for Admin Test and MCP `tools/call`.
|
||
- MCP protocol negotiation and supported revision behavior.
|
||
- Existing typed metrics registry; extend only with bounded enum values if unavoidable.
|
||
- Current dependency/toolchain versions.
|
||
|
||
## Test Plan
|
||
|
||
Required P0 suites:
|
||
|
||
- E1-20: IPv4/IPv6 forbidden classes, encoded/embedded hosts, DNS rebinding and actual retry addresses blocked before bytes leave.
|
||
- E1-21: redirect revalidation/credential stripping, proxy env, reserved headers, byte/deadline/concurrency limits and write retry rules fail closed.
|
||
|
||
Targeted commands:
|
||
|
||
```bash
|
||
cargo test -p crank-adapter-rest --all-targets -- --test-threads=1
|
||
cargo test -p crank-runtime --all-targets -- --test-threads=1
|
||
cargo test -p admin-api --test integration execution_parity -- --test-threads=1
|
||
cargo test -p admin-api --test integration operations_agents -- --test-threads=1
|
||
cargo test -p crank-community-mcp --all-targets -- --test-threads=1
|
||
cargo test -p mcp-server --test integration -- --test-threads=1
|
||
cargo test -p crank-config --all-targets -- --test-threads=1
|
||
just config-contract-check
|
||
just metrics-contract-check
|
||
just rust-boundaries
|
||
just capability-inventory-check
|
||
just authenticated-product-smoke http://localhost:3000
|
||
just verify
|
||
git diff --check
|
||
python3 scripts/check-community-scope.py --root . --files <every NEW/UPDATE tracked candidate>
|
||
```
|
||
|
||
Required assertions:
|
||
|
||
- Every forbidden-address case records zero request bytes at the malicious server.
|
||
- Every redirect case proves the hop decision and credential forwarding behavior.
|
||
- Proxy environment canary proves no proxy connection is attempted by default.
|
||
- Deny match wins over allow match.
|
||
- Admin and MCP produce the same normalized outcome for each outbound failure.
|
||
- Mutating retry without verified idempotency never performs a second dispatch after uncertainty.
|
||
- Request/Trace IDs propagate but never appear in labels.
|
||
- Secret/header/body/URL/IP canaries are absent from response/history/log/trace/metric/test evidence.
|
||
- Config drift checks fail if a new outbound field is not in schema/docs/examples.
|
||
|
||
## Tasks / Subtasks
|
||
|
||
- [x] Task 1 — Freeze RED outbound-security oracle and byte-send evidence (AC: 1–3, 6, 11–12)
|
||
- [x] Add malicious-network adapter tests for forbidden IPv4/IPv6 classes, deny-over-allow, proxy env bypass and no-byte-send assertions.
|
||
- [x] Add DNS rebinding/retry-address tests proving validation happens on the actual address used for each attempt.
|
||
- [x] Add safe-error/redaction tests for URL, credential, private-IP and payload canaries.
|
||
|
||
- [x] Task 2 — Harden `OutboundHttpPolicy` and adapter enforcement (AC: 1–8, 10–11)
|
||
- [x] Normalize and validate host/IP/URL patterns deterministically, including IPv4-mapped IPv6 and ambiguous/encoded host forms.
|
||
- [x] Enforce reserved header policy for correlation, framing, credentials and idempotency/safety headers before dispatch.
|
||
- [x] Keep system proxy disabled by default and prove client construction ignores proxy environment.
|
||
- [x] Preserve disabled redirects by default; support only bounded explicit redirect behavior if implemented in this story.
|
||
- [x] Bound request and response body handling before unbounded allocation.
|
||
|
||
- [x] Task 3 — Wire precise dispatch evidence and retry/idempotency semantics (AC: 3, 8–9, 12)
|
||
- [x] Replace coarse runtime `dispatch_started` assumptions with adapter-level evidence sufficient for retry/idempotency decisions.
|
||
- [x] Implement bounded retry only where safe: read-safe attempts or writes with verified idempotency.
|
||
- [x] Ensure mutating uncertain dispatch without verified idempotency becomes `manual_reconcile + outcome_unknown`.
|
||
|
||
- [x] Task 4 — Cross-ingress parity, config and docs/evidence (AC: 10–12)
|
||
- [x] Prove Admin and MCP outbound failures project the same normalized code/stage/retryability/certainty.
|
||
- [x] Update typed config/docs only if new outbound fields are added; otherwise document the hardened existing fields.
|
||
- [x] Update Capability Inventory/baseline evidence after tests pass.
|
||
- [x] Run targeted suites, explicit Community scan and final `just verify`.
|
||
|
||
### Review Findings
|
||
|
||
- [x] [Review][Patch] Deny-over-allow is not applied to resolved IP addresses [crates/crank-adapter-rest/src/client.rs:360]
|
||
- [x] [Review][Patch] Runtime still treats adapter invocation start as dispatch evidence [crates/crank-runtime/src/executor.rs:541]
|
||
- [x] [Review][Patch] Prepared/mapped headers can override credential and safety headers without provenance [crates/crank-adapter-rest/src/client.rs:513]
|
||
- [x] [Review][Patch] Verified mutating retry can trust a user-supplied idempotency header [crates/crank-runtime/src/idempotency.rs:336]
|
||
- [x] [Review][Patch] Request body limit serializes the full JSON body before enforcing the limit [crates/crank-adapter-rest/src/client.rs:682]
|
||
- [x] [Review][Patch] Oversized outbound request does not project a distinct typed outcome [crates/crank-adapter-rest/src/lib.rs:66]
|
||
- [x] [Review][Patch] Disabled redirects are normalized as generic upstream status failures, not policy outcomes [crates/crank-adapter-rest/src/client.rs:166]
|
||
- [x] [Review][Patch] Transport/debug diagnostics can still expose raw URL or host details [crates/crank-adapter-rest/src/error.rs:24]
|
||
- [x] [Review][Patch] Completed evidence matrix overstates DNS rebinding, IPv6, redirect and cross-ingress coverage [crates/crank-adapter-rest/tests/integration/outbound_security.rs:23]
|
||
|
||
## Previous Story Intelligence
|
||
|
||
- Story 1.8 closed the execution envelope and error taxonomy. Use `RuntimeExecutionRequest → RuntimeExecutor → ProtocolAdapter → RestAdapter`; do not add new `execute_with_*` bypasses.
|
||
- Story 1.8 exposed a key lesson: coarse adapter invocation is not dispatch evidence. 1.9 must make dispatch evidence precise at the HTTP send/connect boundary.
|
||
- Story 1.7 protects immutable Operation versions. Outbound policy must run against the exact saved Draft or Published snapshot selected by 1.7/1.8.
|
||
- Story 1.6 requires all metrics to go through `crank-metrics`; no high-cardinality outbound labels.
|
||
- Story 1.5 requires system correlation headers to override user mappings; 1.9 extends that reserved-header principle to HTTP framing and credentials.
|
||
- Story 1.4 migration authority remains untouched unless a durable schema change is strictly required.
|
||
- Story 1.3 requires all new operator config to be typed in `crank-config`; no direct env reads in reusable crates.
|
||
|
||
## Git Intelligence
|
||
|
||
- Current `HEAD` is `7674284`, but the working tree contains uncommitted completed Story 1.7 and 1.8 changes. Treat those as the effective implementation baseline; do not revert them.
|
||
- Existing worktree also contains `.agents/` and generated SQLx metadata changes. Preserve them unless explicitly instructed otherwise.
|
||
- Recent implementation pattern is closed typed contracts plus executable boundary scanners and parity suites. Reuse it here.
|
||
|
||
## Latest Technical Notes
|
||
|
||
- No web research or dependency upgrade is required for story creation. The repository already pins Reqwest `0.12` and Tokio `1`; the story should harden the existing adapter rather than chase external version changes.
|
||
- Reqwest redirects are currently disabled and proxy use is currently disabled with `.no_proxy()`. Tests must prove these remain true in production construction.
|
||
- Reqwest transport errors alone are not enough to prove side-effect certainty. Use explicit adapter/test evidence around connection and byte-send boundaries.
|
||
|
||
## References
|
||
|
||
- `_bmad-output/planning-artifacts/epics.md` — Epic 1 and Story 1.9.
|
||
- `_bmad-output/planning-artifacts/prds/prd-crank-2026-08-03/prd.md` — FR-2, NFR-S3, NFR-S4, FR-50 security evidence.
|
||
- `_bmad-output/planning-artifacts/prds/prd-crank-2026-08-03/addendum.md` — side-effect/idempotency and Community decisions.
|
||
- `_bmad-output/planning-artifacts/architecture/architecture-crank-2026-08-03/ARCHITECTURE-SPINE.md` — AD-9, AD-11, AD-21, AD-23, conventions.
|
||
- `_bmad-output/test-artifacts/test-design-progress.md` — E1-R-008, E1-20, E1-21.
|
||
- `_bmad-output/implementation-artifacts/1-8-rest-execution-boundary-errors.md` — unified execution handoff and review lessons.
|
||
- `_bmad-output/project-context.md` — outbound safety, testing, config, boundary and redaction rules.
|
||
|
||
## Dev Agent Record
|
||
|
||
### Agent Model Used
|
||
|
||
GPT-5 Codex
|
||
|
||
### Debug Log References
|
||
|
||
- 2026-08-15: Story 1.9 moved to in-progress; current implementation baseline is `7674284` plus uncommitted Story 1.7/1.8 worktree.
|
||
- 2026-08-15: Added RED adapter outbound-security tests, runtime retry/idempotency tests and typed config coverage for request body limit.
|
||
- 2026-08-15: Final verification passed: `just verify` exit code 0.
|
||
- 2026-08-15: Code review patches applied; final `just verify` passed after fixing resolved-IP deny, header provenance, idempotency trust, streaming request limit, redirect policy outcome, safe transport diagnostics and adapter-owned dispatch marker.
|
||
|
||
### Completion Notes List
|
||
|
||
- Story context created by `bmad-create-story`.
|
||
- Added missing `Tasks / Subtasks` section before implementation because the created story lacked executable task checkboxes required by `bmad-dev-story`.
|
||
- Hardened outbound REST policy: forbidden static credential/framing headers reject before dispatch; system correlation headers remain system-owned; resolved Auth Profile headers remain allowed after runtime resolution.
|
||
- Added fail-closed request body limit and typed `CRANK_OUTBOUND_MAX_REQUEST_BYTES` config, propagated consistently into Admin and MCP runtime construction.
|
||
- Added bounded retry semantics: read-safe transient failures can retry; mutating retries require verified idempotency and reuse the same scoped idempotency key.
|
||
- Added typed `upstream_request_too_large` outcome and updated the v5 execution-outcome CHECK/schema guard/migration sequence checksum so persisted history remains closed.
|
||
- Updated FR-2 Capability Inventory evidence and baseline checksum after tests passed.
|
||
- No dependency or toolchain changes were introduced by Story 1.9.
|
||
|
||
### File List
|
||
|
||
- `_bmad-output/implementation-artifacts/1-9-outbound-rest.md`
|
||
- `_bmad-output/implementation-artifacts/sprint-status.yaml`
|
||
- `.env.example`
|
||
- `docker-compose.yml`
|
||
- `deploy/community/.env.example`
|
||
- `deploy/community/.env.images.example`
|
||
- `deploy/community/docker-compose.yml`
|
||
- `deploy/community/docker-compose.images.yml`
|
||
- `apps/admin-api/src/main.rs`
|
||
- `apps/mcp-server/src/main.rs`
|
||
- `crates/crank-adapter-rest/src/client.rs`
|
||
- `crates/crank-adapter-rest/src/error.rs`
|
||
- `crates/crank-adapter-rest/src/lib.rs`
|
||
- `crates/crank-adapter-rest/src/model.rs`
|
||
- `crates/crank-adapter-rest/tests/integration.rs`
|
||
- `crates/crank-adapter-rest/tests/integration/client.rs`
|
||
- `crates/crank-adapter-rest/tests/integration/outbound_security.rs`
|
||
- `crates/crank-core/src/execution.rs`
|
||
- `crates/crank-core/src/ext/protocol.rs`
|
||
- `crates/crank-registry/src/migrations/execution_outcome_v5.rs`
|
||
- `crates/crank-registry/src/migrations/execution_outcome_v5.sql`
|
||
- `crates/crank-registry/src/migrations/schema_guard.rs`
|
||
- `crates/crank-runtime/src/auth.rs`
|
||
- `crates/crank-runtime/src/execution_failure.rs`
|
||
- `crates/crank-runtime/src/executor.rs`
|
||
- `crates/crank-runtime/src/idempotency.rs`
|
||
- `crates/crank-runtime/src/model.rs`
|
||
- `crates/crank-runtime/src/request_context.rs`
|
||
- `crates/crank-runtime/src/request_preparation.rs`
|
||
- `crates/crank-runtime/tests/product_metrics.rs`
|
||
- `crates/crank-runtime/tests/stages.rs`
|
||
- `docs/schemas/migration-sequence.json`
|
||
- `crates/crank-config/src/debug.rs`
|
||
- `crates/crank-config/src/process.rs`
|
||
- `crates/crank-config/src/schema.rs`
|
||
- `crates/crank-config/tests/contract.rs`
|
||
- `crates/crank-runtime/src/executor.rs`
|
||
- `crates/crank-runtime/tests/stages.rs`
|
||
- `docs/capability-baseline/manifest.json`
|
||
- `docs/capability-inventory.json`
|
||
- `docs/runtime-config.md`
|
||
- `docs/schemas/runtime-config.schema.json`
|
||
|
||
## Change Log
|
||
|
||
- 2026-08-15: Story 1.9 created as ready-for-dev with outbound REST security scope, current brownfield gaps, test matrix and guardrails.
|
||
- 2026-08-15: Story 1.9 moved to in-progress and missing executable task checklist added before implementation.
|
||
- 2026-08-15: Story 1.9 implemented and moved to review after targeted tests, guardrails, Compose config checks and `just verify` passed.
|