Skip to content

feat(store): bound outbox listing and prune processed rows - #101

Merged
seonghobae merged 3 commits into
feat/issue-80-postgres-rustlsfrom
feat/issue-81-outbox-retention
Aug 23, 2026
Merged

feat(store): bound outbox listing and prune processed rows#101
seonghobae merged 3 commits into
feat/issue-80-postgres-rustlsfrom
feat/issue-81-outbox-retention

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Still-valid #99 Devin finding on issue #81. Does not re-implement #78, the #86 sidecar/libcoraza slices, the #79 TCP-peer pin, the #80 production postgres gate, rustls (#100), or the #81 first outbox slice.

GET /api/outbox now returns at most EVENT_LIMIT rows, ordered dead-letter → pending → leased → processed (newest first). Processed outbox_message rows prune to that same cap on append, snapshot save, and ack. outbox_receipt rows stay as the exactly-once ack. Dead letters are never pruned.

Stacked on #100 (feat/issue-80-postgres-rustls). Merge order: #95, then #96, then #97, then #98, then #99, then #100, then this PR. Org ruleset 18156473 still requires two independent approvals; do not --admin merge.

Operator-visible

  • GET /api/outbox JSON includes limit
  • Admin console still slices to 25; the API no longer fetches the whole table
  • Client IPs and paths in payloads are not masked

Tests

  • cargo fmt --check
  • cargo test --locked --workspace (includes live postgres_outbox_list_is_bounded_and_prunes_processed)
  • cargo clippy --locked --workspace --all-targets -- -D warnings
  • Two scripts/smoke.sh runs (/healthz + /admin, 2B KRW readiness)

Doctoring: docs/doctoring/outbox-workers.md (APA 7th).

Remaining on #80: non-owner runtime role, backup/restore drill, HASH partitioning, optimistic concurrency. Remaining on #81: additional consumers (TAXII poll, Clearfolio, contextual-orchestrator).


Open in Devin Review

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 97ce3509-db59-4ad0-b1ee-52a06e57aebd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 3 potential issues.

Open in Devin Review

Comment thread src/control_plane.rs Outdated
Comment thread src/control_plane.rs
Comment on lines +1390 to +1397
ORDER BY CASE message_status
WHEN 'dead_letter' THEN 0
WHEN 'pending' THEN 1
WHEN 'leased' THEN 2
ELSE 3
END,
created_unix DESC, message_id DESC
LIMIT $2",

@devin-ai-integration devin-ai-integration Bot Aug 23, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Dead letters can hide pending rows in the bounded list

The list orders dead_letter first and caps at the retention limit. Since dead letters are never pruned, once they reach that cap the list shows only dead letters; pending and leased rows disappear from GET /api/outbox. Counts remain visible via /healthz.outbox.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread src/control_plane.rs
Comment on lines +1350 to +1361
"DELETE FROM outbox_message
WHERE tenant_id = $1
AND message_status = $2
AND message_id IN (
SELECT message_id FROM (
SELECT message_id FROM outbox_message
WHERE tenant_id = $1 AND message_status = $2
ORDER BY created_unix DESC, message_id DESC
OFFSET $3
) old_processed
)",
&[&tenant_id, &STATUS_PROCESSED, &keep],

@devin-ai-integration devin-ai-integration Bot Aug 23, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Prune and list ordering are consistent

prune_processed_outbox retains the newest processed rows by created_unix DESC, message_id DESC and list_outbox displays them in the same order, so pruning never removes a row the list would rank above a retained one. The deterministic message_id tiebreak matters because fixture events share one timestamp.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Still-valid #99 finding. GET /api/outbox returns at most EVENT_LIMIT
rows (dead letters, then pending, then leased, then processed).
Processed outbox_message rows prune to that cap; receipts and dead
letters stay. Do not re-implement the outbox, postgres gate, or rustls.
@seonghobae
seonghobae force-pushed the feat/issue-81-outbox-retention branch from f267a92 to 9f68a0f Compare August 23, 2026 17:35

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Open in Devin Review

Comment thread src/control_plane.rs
Comment on lines +1419 to +1426
ORDER BY CASE message_status
WHEN 'dead_letter' THEN 0
WHEN 'pending' THEN 1
WHEN 'leased' THEN 2
ELSE 3
END,
created_unix DESC, message_id DESC
LIMIT $2",

@devin-ai-integration devin-ai-integration Bot Aug 23, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Outbox list order flipped to newest-first, grouped by status

list_outbox now orders dead_letter, pending, leased, processed, then newest-first, replacing the old oldest-first order. This aligns with the prune keeping the newest processed rows, but changes what /api/outbox and the admin console display first.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Still-valid #101 Devin finding. Snapshot save and worker ack used
LIST_LIMIT (1000) while append used operator EVENT_LIMIT. Store the
configured cap on PostgresPlane so all three paths retain the same
processed-row bound. Receipts and dead letters stay.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 2 new potential issues.

Open in Devin Review

Comment thread src/control_plane.rs
},
)
.await?;
prune_processed_outbox(&tx, tenant_id, event_limit as i64).await?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Pruned event id loses outbox dedup

After a processed row is pruned its outbox_message row is gone but its receipt stays. Re-appending the same event id would insert a fresh pending row (insert_outbox no longer conflicts), later acked as a duplicate. Event ids are monotonic in practice, so this stays unreachable.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread src/control_plane.rs
Comment on lines +1416 to +1420
SELECT message_id FROM outbox_message
WHERE tenant_id = $1 AND message_status = $2
ORDER BY created_unix DESC, message_id DESC
OFFSET $3
) old_processed

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Info: Prune sorts processed rows on every append/ack

prune_processed_outbox orders by created_unix DESC, but no index covers created_unix, so each prune sorts the tenant's processed rows. It runs inside every append and ack transaction. The processed set is capped at EVENT_LIMIT, so the cost stays bounded.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Still-valid Devin finding on processed-row pruning is fixed on 0c2167a: PostgresPlane now stores operator EVENT_LIMIT and save_snapshot / worker ack prune to that cap (same as append). Receipts and dead letters stay. Live postgres_ack_and_save_prune_to_configured_event_limit covers a non-1000 limit. Do not --admin merge.

@seonghobae
seonghobae merged commit 0c62115 into feat/issue-80-postgres-rustls Aug 23, 2026
7 checks passed
@seonghobae
seonghobae deleted the feat/issue-81-outbox-retention branch August 23, 2026 18:02
seonghobae added a commit that referenced this pull request Aug 23, 2026
Issue #80 remainder stacked on #101. GET /api/backup exports a hashed
tenant snapshot; POST /api/backup restores after schema and payload-hash
checks; POST /api/backup/drill restores into an isolated tenant, compares
unmasked invariants, and drops the drill rows. Declared RPO is last
successful export; declared RTO is 60s. File/memory adapters report
backup=disabled. Do not re-implement rustls, outbox, or retention.
seonghobae added a commit that referenced this pull request Aug 23, 2026
* feat(store): logical backup and isolated restore drill

Issue #80 remainder stacked on #101. GET /api/backup exports a hashed
tenant snapshot; POST /api/backup restores after schema and payload-hash
checks; POST /api/backup/drill restores into an isolated tenant, compares
unmasked invariants, and drops the drill rows. Declared RPO is last
successful export; declared RTO is 60s. File/memory adapters report
backup=disabled. Do not re-implement rustls, outbox, or retention.

* docs: record PR #102 in the product-technical gap baseline
seonghobae added a commit that referenced this pull request Aug 23, 2026
* feat(store): rustls for production PostgreSQL sslmode=require

Issue #80 remainder. sslmode=require/verify-ca/verify-full connect with
rustls and Mozilla roots; certificates are always verified. allow/prefer
are still rejected so the process cannot silently drop to plaintext.
Live test against plaintext CI postgres proves fail-closed. Do not
re-implement the postgres gate or the outbox.

* docs: record PR #100 in the product-technical gap baseline

* fix(store): rewrite verify-full sslmode for tokio-postgres 0.7

Still-valid #100 Devin finding. tokio-postgres 0.7 only parses
disable/prefer/require. Map verify-ca/verify-full to require before
connect; rustls still verifies certificates. Password query-lookalikes
are left untouched.

* feat(store): bound outbox listing and prune processed rows (#101)

* feat(store): bound outbox listing and prune processed rows

Still-valid #99 finding. GET /api/outbox returns at most EVENT_LIMIT
rows (dead letters, then pending, then leased, then processed).
Processed outbox_message rows prune to that cap; receipts and dead
letters stay. Do not re-implement the outbox, postgres gate, or rustls.

* docs: record PR #101 in the product-technical gap baseline

* fix(store): prune processed outbox to EVENT_LIMIT on save and ack

Still-valid #101 Devin finding. Snapshot save and worker ack used
LIST_LIMIT (1000) while append used operator EVENT_LIMIT. Store the
configured cap on PostgresPlane so all three paths retain the same
processed-row bound. Receipts and dead letters stay.

* feat(store): logical backup and isolated restore drill (#102)

* feat(store): logical backup and isolated restore drill

Issue #80 remainder stacked on #101. GET /api/backup exports a hashed
tenant snapshot; POST /api/backup restores after schema and payload-hash
checks; POST /api/backup/drill restores into an isolated tenant, compares
unmasked invariants, and drops the drill rows. Declared RPO is last
successful export; declared RTO is 60s. File/memory adapters report
backup=disabled. Do not re-implement rustls, outbox, or retention.

* docs: record PR #102 in the product-technical gap baseline

* feat(store): non-owner PostgreSQL runtime role after migrate (#103)

* feat(store): non-owner PostgreSQL runtime role after migrate

Still-valid #98 finding. CI connects as a superuser, which bypasses
FORCE RLS. Migrations stay on the login role, then SET ROLE
wardnet_runtime (NOSUPERUSER, NOBYPASSRLS, not table owner). Missing
tenant GUC yields no rows; DROP TABLE and DISABLE RLS are denied.
Do not re-implement rustls, outbox, retention, or backup/restore.

* docs: record PR #103 in the product-technical gap baseline

* fix(store): restore logical backups across role-only schema versions

v3 only provisions wardnet_runtime and does not change table shape.
verify() accepts schema 2 through the current migration version so a
role-only upgrade cannot void the last pre-upgrade logical backup.

* feat(store): HASH-partition security_event by tenant (#104)

* feat(store): HASH-partition security_event by tenant

Convert unpartitioned security_event to PARTITION BY HASH (tenant_id)
with eight children under pg_advisory_lock. Rows keep unmasked client
IPs and paths. /healthz.event_partitions reports the child count.
Logical restore still accepts schema 2 through the current version.

* docs: record PR #104 in the product-technical gap baseline
seonghobae added a commit that referenced this pull request Aug 26, 2026
* feat(store): require PostgreSQL as the production control plane

Non-loopback binds fail closed without CONTROL_PLANE_DATABASE_URL.
Migrations create 3NF two-word tables with default-deny RLS. Snapshot
persist commits policy rows and audit records in one transaction.
Loopback still uses the JSON file or memory adapter.

* feat(store): transactional outbox and leased workers

Issue #81 first slice on the PostgreSQL control plane. Security events
append with an outbox row in one transaction instead of rewriting the
snapshot. Workers claim with SKIP LOCKED, retry, dead-letter, and
record unique receipts. Stdout SIEM is at-least-once; the receipt is
the exactly-once ack. Also deterministic ORDER BY on postgres loads
(still-valid #98 finding). Do not re-implement the postgres gate.

* feat(store): rustls for production PostgreSQL sslmode=require (#100)

* feat(store): rustls for production PostgreSQL sslmode=require

Issue #80 remainder. sslmode=require/verify-ca/verify-full connect with
rustls and Mozilla roots; certificates are always verified. allow/prefer
are still rejected so the process cannot silently drop to plaintext.
Live test against plaintext CI postgres proves fail-closed. Do not
re-implement the postgres gate or the outbox.

* docs: record PR #100 in the product-technical gap baseline

* fix(store): rewrite verify-full sslmode for tokio-postgres 0.7

Still-valid #100 Devin finding. tokio-postgres 0.7 only parses
disable/prefer/require. Map verify-ca/verify-full to require before
connect; rustls still verifies certificates. Password query-lookalikes
are left untouched.

* feat(store): bound outbox listing and prune processed rows (#101)

* feat(store): bound outbox listing and prune processed rows

Still-valid #99 finding. GET /api/outbox returns at most EVENT_LIMIT
rows (dead letters, then pending, then leased, then processed).
Processed outbox_message rows prune to that cap; receipts and dead
letters stay. Do not re-implement the outbox, postgres gate, or rustls.

* docs: record PR #101 in the product-technical gap baseline

* fix(store): prune processed outbox to EVENT_LIMIT on save and ack

Still-valid #101 Devin finding. Snapshot save and worker ack used
LIST_LIMIT (1000) while append used operator EVENT_LIMIT. Store the
configured cap on PostgresPlane so all three paths retain the same
processed-row bound. Receipts and dead letters stay.

* feat(store): logical backup and isolated restore drill (#102)

* feat(store): logical backup and isolated restore drill

Issue #80 remainder stacked on #101. GET /api/backup exports a hashed
tenant snapshot; POST /api/backup restores after schema and payload-hash
checks; POST /api/backup/drill restores into an isolated tenant, compares
unmasked invariants, and drops the drill rows. Declared RPO is last
successful export; declared RTO is 60s. File/memory adapters report
backup=disabled. Do not re-implement rustls, outbox, or retention.

* docs: record PR #102 in the product-technical gap baseline

* feat(store): non-owner PostgreSQL runtime role after migrate (#103)

* feat(store): non-owner PostgreSQL runtime role after migrate

Still-valid #98 finding. CI connects as a superuser, which bypasses
FORCE RLS. Migrations stay on the login role, then SET ROLE
wardnet_runtime (NOSUPERUSER, NOBYPASSRLS, not table owner). Missing
tenant GUC yields no rows; DROP TABLE and DISABLE RLS are denied.
Do not re-implement rustls, outbox, retention, or backup/restore.

* docs: record PR #103 in the product-technical gap baseline

* fix(store): restore logical backups across role-only schema versions

v3 only provisions wardnet_runtime and does not change table shape.
verify() accepts schema 2 through the current migration version so a
role-only upgrade cannot void the last pre-upgrade logical backup.

* feat(store): HASH-partition security_event by tenant (#104)

* feat(store): HASH-partition security_event by tenant

Convert unpartitioned security_event to PARTITION BY HASH (tenant_id)
with eight children under pg_advisory_lock. Rows keep unmasked client
IPs and paths. /healthz.event_partitions reports the child count.
Logical restore still accepts schema 2 through the current version.

* docs: record PR #104 in the product-technical gap baseline
seonghobae added a commit that referenced this pull request Aug 26, 2026
* feat(security): fail-closed destination policy for outbound HTTP

One DestinationPolicy mediates gateway upstreams, threat-intel fetches,
Clearfolio, SOC LLM, and the Coraza sidecar URL. Private, loopback,
link-local, CGNAT, and metadata classes are denied unless
DESTINATION_ALLOWLIST (or loopback development) permits them;
DESTINATION_DENYLIST wins. Clients ignore ambient HTTP proxies and do
not follow redirects.

Refs #79.

* docs: record PR #96 in the product-technical gap baseline

* feat(security): harden destination policy per-IP CIDR and readiness order

CIDR allowlist matches apply per resolved address, authorize non-default
ports, and reject prefixes outside the address-family width. IPv6
site-local is a denied class. Hostnames that merely contain 0x are not
hex IP literals. AppState constructors default to production policy;
seeded fixtures opt into development. Blocking DNS runs on spawn_blocking
with a timeout. Persistence and destination-list validation complete
before the readiness line.

* feat(security): pin outbound HTTP to evaluated destination addresses

After destination policy allows a host, the reqwest client resolves
only those IPs so a rebinding answer cannot reach loopback, private,
or metadata classes. Host and SNI stay on the original name.
Unpinned hostnames fail closed instead of falling back to OS DNS.

* feat(waf): evaluate live gateway transactions with in-process libcoraza

Issue #86 remainder: dlopen operator-supplied libcoraza and drive the C ABI
on each /gateway request. Missing library or empty ruleset fail closed before
bind. CI stays hermetic with a fixture cdylib that exports the same symbols.

* docs: record PR #97 in the product-technical gap baseline

* feat(waf): forward bounded client headers into in-process libcoraza

In-process transactions now receive the same forwarded-header allowlist as
the sidecar path (host, user-agent, accept, content-type, referer, origin,
x-requested-with, x-forwarded-for, x-real-ip, cookie — never Authorization;
32 headers / 8 KiB caps enforced by proven_engine::engine_forwarded_headers).
Each header crosses the C ABI via coraza_add_request_header before
process_request_headers, so CRS rules that inspect headers evaluate real
client input instead of a synthetic Host only.

Brings in the PR #95 sidecar hardening via merge so both engines share one
allowlist implementation and one status/bound contract.

Behavioral header-battery evidence lands with the issue-11 battery fixture
(PR #110); this slice ships the plumbing and keeps the stub contract
unchanged.

* feat(store): require PostgreSQL as the production control plane (#98)

* feat(store): require PostgreSQL as the production control plane

Non-loopback binds fail closed without CONTROL_PLANE_DATABASE_URL.
Migrations create 3NF two-word tables with default-deny RLS. Snapshot
persist commits policy rows and audit records in one transaction.
Loopback still uses the JSON file or memory adapter.

* feat(store): transactional outbox and leased workers

Issue #81 first slice on the PostgreSQL control plane. Security events
append with an outbox row in one transaction instead of rewriting the
snapshot. Workers claim with SKIP LOCKED, retry, dead-letter, and
record unique receipts. Stdout SIEM is at-least-once; the receipt is
the exactly-once ack. Also deterministic ORDER BY on postgres loads
(still-valid #98 finding). Do not re-implement the postgres gate.

* feat(store): rustls for production PostgreSQL sslmode=require (#100)

* feat(store): rustls for production PostgreSQL sslmode=require

Issue #80 remainder. sslmode=require/verify-ca/verify-full connect with
rustls and Mozilla roots; certificates are always verified. allow/prefer
are still rejected so the process cannot silently drop to plaintext.
Live test against plaintext CI postgres proves fail-closed. Do not
re-implement the postgres gate or the outbox.

* docs: record PR #100 in the product-technical gap baseline

* fix(store): rewrite verify-full sslmode for tokio-postgres 0.7

Still-valid #100 Devin finding. tokio-postgres 0.7 only parses
disable/prefer/require. Map verify-ca/verify-full to require before
connect; rustls still verifies certificates. Password query-lookalikes
are left untouched.

* feat(store): bound outbox listing and prune processed rows (#101)

* feat(store): bound outbox listing and prune processed rows

Still-valid #99 finding. GET /api/outbox returns at most EVENT_LIMIT
rows (dead letters, then pending, then leased, then processed).
Processed outbox_message rows prune to that cap; receipts and dead
letters stay. Do not re-implement the outbox, postgres gate, or rustls.

* docs: record PR #101 in the product-technical gap baseline

* fix(store): prune processed outbox to EVENT_LIMIT on save and ack

Still-valid #101 Devin finding. Snapshot save and worker ack used
LIST_LIMIT (1000) while append used operator EVENT_LIMIT. Store the
configured cap on PostgresPlane so all three paths retain the same
processed-row bound. Receipts and dead letters stay.

* feat(store): logical backup and isolated restore drill (#102)

* feat(store): logical backup and isolated restore drill

Issue #80 remainder stacked on #101. GET /api/backup exports a hashed
tenant snapshot; POST /api/backup restores after schema and payload-hash
checks; POST /api/backup/drill restores into an isolated tenant, compares
unmasked invariants, and drops the drill rows. Declared RPO is last
successful export; declared RTO is 60s. File/memory adapters report
backup=disabled. Do not re-implement rustls, outbox, or retention.

* docs: record PR #102 in the product-technical gap baseline

* feat(store): non-owner PostgreSQL runtime role after migrate (#103)

* feat(store): non-owner PostgreSQL runtime role after migrate

Still-valid #98 finding. CI connects as a superuser, which bypasses
FORCE RLS. Migrations stay on the login role, then SET ROLE
wardnet_runtime (NOSUPERUSER, NOBYPASSRLS, not table owner). Missing
tenant GUC yields no rows; DROP TABLE and DISABLE RLS are denied.
Do not re-implement rustls, outbox, retention, or backup/restore.

* docs: record PR #103 in the product-technical gap baseline

* fix(store): restore logical backups across role-only schema versions

v3 only provisions wardnet_runtime and does not change table shape.
verify() accepts schema 2 through the current migration version so a
role-only upgrade cannot void the last pre-upgrade logical backup.

* feat(store): HASH-partition security_event by tenant (#104)

* feat(store): HASH-partition security_event by tenant

Convert unpartitioned security_event to PARTITION BY HASH (tenant_id)
with eight children under pg_advisory_lock. Rows keep unmasked client
IPs and paths. /healthz.event_partitions reports the child count.
Logical restore still accepts schema 2 through the current version.

* docs: record PR #104 in the product-technical gap baseline

* feat(security): add bounded outbound fetch API (#113)

* feat(security): add bounded outbound fetch API

* fix(security): isolate fetch DNS pins per request

* feat(security): route browser DNS and HTTPS through Wardnet (#116)

* feat(security): add bounded outbound fetch API

* feat(security): route browser DNS and HTTPS through Wardnet

* fix(security): isolate fetch DNS pins per request

* fix(dns): bound concurrent UDP query handling

* fix(security): close destination policy review gaps

* fix(runtime): make worker shutdown durable
seonghobae added a commit that referenced this pull request Aug 26, 2026
* feat(security): fail-closed destination policy for outbound HTTP

One DestinationPolicy mediates gateway upstreams, threat-intel fetches,
Clearfolio, SOC LLM, and the Coraza sidecar URL. Private, loopback,
link-local, CGNAT, and metadata classes are denied unless
DESTINATION_ALLOWLIST (or loopback development) permits them;
DESTINATION_DENYLIST wins. Clients ignore ambient HTTP proxies and do
not follow redirects.

Refs #79.

* docs: record PR #96 in the product-technical gap baseline

* feat(security): harden destination policy per-IP CIDR and readiness order

CIDR allowlist matches apply per resolved address, authorize non-default
ports, and reject prefixes outside the address-family width. IPv6
site-local is a denied class. Hostnames that merely contain 0x are not
hex IP literals. AppState constructors default to production policy;
seeded fixtures opt into development. Blocking DNS runs on spawn_blocking
with a timeout. Persistence and destination-list validation complete
before the readiness line.

* feat(security): pin outbound HTTP to evaluated destination addresses

After destination policy allows a host, the reqwest client resolves
only those IPs so a rebinding answer cannot reach loopback, private,
or metadata classes. Host and SNI stay on the original name.
Unpinned hostnames fail closed instead of falling back to OS DNS.

* feat(waf): evaluate live gateway transactions with in-process libcoraza

Issue #86 remainder: dlopen operator-supplied libcoraza and drive the C ABI
on each /gateway request. Missing library or empty ruleset fail closed before
bind. CI stays hermetic with a fixture cdylib that exports the same symbols.

* docs: record PR #97 in the product-technical gap baseline

* feat(store): require PostgreSQL as the production control plane

Non-loopback binds fail closed without CONTROL_PLANE_DATABASE_URL.
Migrations create 3NF two-word tables with default-deny RLS. Snapshot
persist commits policy rows and audit records in one transaction.
Loopback still uses the JSON file or memory adapter.

* feat(store): transactional outbox and leased workers

Issue #81 first slice on the PostgreSQL control plane. Security events
append with an outbox row in one transaction instead of rewriting the
snapshot. Workers claim with SKIP LOCKED, retry, dead-letter, and
record unique receipts. Stdout SIEM is at-least-once; the receipt is
the exactly-once ack. Also deterministic ORDER BY on postgres loads
(still-valid #98 finding). Do not re-implement the postgres gate.

* feat(store): rustls for production PostgreSQL sslmode=require (#100)

* feat(store): rustls for production PostgreSQL sslmode=require

Issue #80 remainder. sslmode=require/verify-ca/verify-full connect with
rustls and Mozilla roots; certificates are always verified. allow/prefer
are still rejected so the process cannot silently drop to plaintext.
Live test against plaintext CI postgres proves fail-closed. Do not
re-implement the postgres gate or the outbox.

* docs: record PR #100 in the product-technical gap baseline

* fix(store): rewrite verify-full sslmode for tokio-postgres 0.7

Still-valid #100 Devin finding. tokio-postgres 0.7 only parses
disable/prefer/require. Map verify-ca/verify-full to require before
connect; rustls still verifies certificates. Password query-lookalikes
are left untouched.

* feat(store): bound outbox listing and prune processed rows (#101)

* feat(store): bound outbox listing and prune processed rows

Still-valid #99 finding. GET /api/outbox returns at most EVENT_LIMIT
rows (dead letters, then pending, then leased, then processed).
Processed outbox_message rows prune to that cap; receipts and dead
letters stay. Do not re-implement the outbox, postgres gate, or rustls.

* docs: record PR #101 in the product-technical gap baseline

* fix(store): prune processed outbox to EVENT_LIMIT on save and ack

Still-valid #101 Devin finding. Snapshot save and worker ack used
LIST_LIMIT (1000) while append used operator EVENT_LIMIT. Store the
configured cap on PostgresPlane so all three paths retain the same
processed-row bound. Receipts and dead letters stay.

* feat(store): logical backup and isolated restore drill (#102)

* feat(store): logical backup and isolated restore drill

Issue #80 remainder stacked on #101. GET /api/backup exports a hashed
tenant snapshot; POST /api/backup restores after schema and payload-hash
checks; POST /api/backup/drill restores into an isolated tenant, compares
unmasked invariants, and drops the drill rows. Declared RPO is last
successful export; declared RTO is 60s. File/memory adapters report
backup=disabled. Do not re-implement rustls, outbox, or retention.

* docs: record PR #102 in the product-technical gap baseline

* feat(store): non-owner PostgreSQL runtime role after migrate (#103)

* feat(store): non-owner PostgreSQL runtime role after migrate

Still-valid #98 finding. CI connects as a superuser, which bypasses
FORCE RLS. Migrations stay on the login role, then SET ROLE
wardnet_runtime (NOSUPERUSER, NOBYPASSRLS, not table owner). Missing
tenant GUC yields no rows; DROP TABLE and DISABLE RLS are denied.
Do not re-implement rustls, outbox, retention, or backup/restore.

* docs: record PR #103 in the product-technical gap baseline

* fix(store): restore logical backups across role-only schema versions

v3 only provisions wardnet_runtime and does not change table shape.
verify() accepts schema 2 through the current migration version so a
role-only upgrade cannot void the last pre-upgrade logical backup.

* feat(store): HASH-partition security_event by tenant (#104)

* feat(store): HASH-partition security_event by tenant

Convert unpartitioned security_event to PARTITION BY HASH (tenant_id)
with eight children under pg_advisory_lock. Rows keep unmasked client
IPs and paths. /healthz.event_partitions reports the child count.
Logical restore still accepts schema 2 through the current version.

* docs: record PR #104 in the product-technical gap baseline

* feat(store): optimistic concurrency on postgres snapshots

Issue #80 last remainder. tenant_account.snapshot_version must match
the loaded token or persist fails closed (HTTP 409). Restores overwrite.
File/memory stay single-writer. Do not re-implement rustls, outbox,
runtime role, HASH, or backup/restore.

* docs: record PR #105 in the product-technical gap baseline

* fix(store): keep postgres snapshot_version aligned after startup save

load_postgres was saving with OCC and leaving the in-memory token one
behind the database, so every later management write returned HTTP 409.
Advance the loaded snapshot_version to the value save() wrote.

* feat(store): outbox consumers for TAXII, Clearfolio, and orchestrator

Enqueue operator-triggered TAXII polls, Clearfolio submits, and
contextual-orchestrator SOC analysis on the PostgreSQL leased outbox.
Request path returns 202; GET /api/outbox/{id} exposes receipt evidence.
Secrets stay in the credential registry. Startup postgres save advances
snapshot_version so the first management write cannot false-conflict.

* docs: record PR #106 in the product-technical gap baseline

* feat(release): tagged GitHub Release with SHA-256 and immutable GHCR (#107)

* feat(release): tagged GitHub Release with SHA-256 and immutable GHCR

Issue #84 first slice. A vX.Y.Z tag builds a locked binary, checksums,
a GitHub Release, and ghcr.io/contextualwisdomlab/waf-ids-ai-soc:vX.Y.Z
with no moving latest tag. Promotion and rollback are tag-for-tag.
Do not re-implement store slices or OCC.

* docs: record PR #107 in the product-technical gap baseline

* fix(release): basename checksums and serialize postgres GRANTs

SHA256SUMS recorded dist/ prefixes so sha256sum -c failed next to the
downloaded binary. Emit basenames. Parallel PostgresPlane connects raced
HASH convert GRANT with SET ROLE GRANT (tuple concurrently updated);
hold the advisory lock across both. Do not re-implement HASH layout.

* feat(release): keyless cosign, SPDX SBOM, and SLSA on the same tag

Issue #84 remainder. GitHub OIDC signs the binary, checksums, SBOMs, and
the GHCR image by digest. Release is created only after signatures.
Syft SPDX fails closed without syft or non-SPDX JSON. NIST SP 800-218
is attached. Do not re-implement checksums or store slices.

* feat(release): refuse lightweight tags and pin k8s by digest

Issue #84 remainder. Annotated vX.Y.Z tags only; lightweight tags fail
closed before the release job builds. Kubernetes pin is the GHCR
content digest; tag aliases are refused. Do not re-implement checksums
or cosign/SBOM.

* docs: record PR #109 in the product-technical gap baseline

* feat(waf): detect OWASP CRS attack battery on the live binary

Issue #11 first slice. The build-script libcoraza ABI stub gains a
deterministic battery covering SQLi (942100), XSS (941100), path traversal
(930100), Unix RCE (932100, with first-match ordering so '; cat /etc/passwd'
attributes to RCE over traversal), and Log4j JNDI (944120) in raw and
percent-encoded forms across URI and POST-body phases.

tests/binary.rs now starts the real gateway with the stub engine, creates a
block route through the admin API, fires nine cases over HTTP, and asserts
each is 403-blocked citing the expected CRS rule id while a benign request
still forwards; /api/events must record one event per attempt with the
forwarded client IP kept unmasked.

Doctoring: docs/doctoring/ci-attack-evidence-battery.md grounds the split
between detection-path evidence (CI) and detection efficacy (operator-supplied
libcoraza + Core Rule Set), APA 7th.

* fix(control-plane): close OCC and credential race gaps

* fix(release): capture pushed image digest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant