Skip to content

feat(mitigations): extend FlowSpec lifetime with an audit trail - #326

Merged
lance0 merged 26 commits into
mainfrom
feature/flowspec-lifetime-extension
Oct 24, 2026
Merged

lance0 merged 26 commits into
mainfrom
feature/flowspec-lifetime-extension

Conversation

@lance0

@lance0 lance0 commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Add an authenticated Operator action to extend the saved lifetime of a live ordinary enforced FlowSpec rule. Preserve the exact match, action, rule identity and creation history; refuse expired, withdrawn, blackhole, simulation, foreign-POP or unsafe intent. Fresh ownership, safelist, policy, binding and fence checks precede an atomic expiry/audit update. No speaker mutation or new quota slot is used.

The modal shows current/proposed expiry, the full rule and exact police bps, and requires a reason. An open modal retains precise refusals and uncertain-update warnings after eligibility changes; it blocks further submission until the operator closes it. Read-only preparation uses one five-second budget, server-side statement deadlines and discarded read connections; atomic mutation and COMMIT remain outside cancellation.

Validation on d56b8c4: all 575 library tests, 7 lifetime and 2 admission database tests, all 64 PostgreSQL lifecycle cases, both strict Clippy configurations and the Rust 1.89 all-target check pass. One-connection blocked-read tests recover before blocker release; the old preparation fails the negative control. Mutation SQL and UI preservation were verified. Pinned frontend lint/types, 574 tests and production build pass; both eligibility-loss races fail under the old dialog guard. Desktop/mobile browser checks pass in both themes with reduced motion. All 18 hosted checks pass on this exact head; the PR is clean and ready for review.

This PR targets #325 and contains only lifetime extension. Merge order: #323 → #327 → #322 → #324 → #325 → #326. Use merge commits; after the predecessor lands, retarget the next PR to main before merging.

Copilot AI 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.

🔵 Needs a closer look

Unresolved lifetime monotonicity and lifecycle-lock risks require fixes and final human routing-safety review.

2 open issues
What changed in this PR

Adds an operator workflow to extend an existing FlowSpec rule’s saved lifetime without changing its match/action or sending speaker mutations.

Changes:

  • Adds an authenticated extension endpoint with eligibility checks and atomic expiry/audit updates.
  • Adds a confirmation dialog showing the complete rule, exact police rate and expiry estimate.
  • Adds backend, PostgreSQL and frontend coverage, plus operator documentation.
File Description
tests/​integration_lifetime.rs Tests transactional updates, rollback and lock-wait safety.
src/​guardrails/​mod.rs Separates reusable rule checks from creation quotas.
src/​domain/​mod.rs Exports lifetime-extension types and logic.
src/​domain/​lifetime.rs Implements extension eligibility, safety checks and domain tests.
src/​db/​traits.rs Defines the atomic extension repository contract.
src/​db/​repository.rs Implements PostgreSQL expiry and audit transactions.
src/​db/​mock.rs Implements mock extension behavior and audit-failure simulation.
src/​api/​routes.rs Registers the extension endpoint.
src/​api/​openapi.rs Registers endpoint documentation and schemas.
src/​api/​handlers/​lifetime.rs Handles authentication, requests and extension responses.
src/​api/​handlers.rs Exports the lifetime handler and schemas.
frontend/​lib/​api.ts Adds the extension client and error-status helper.
frontend/​components/​dashboard/​extend-lifetime-dialog.tsx Adds preview, validation and confirmation controls.
frontend/​app/​(dashboard)/​mitigations/​[id]/​page.tsx Integrates extension into mitigation details.
frontend/​__tests__/​extend-lifetime.test.tsx Tests confirmation, eligibility, no-op and error states.
docs/​reference/​api.md Documents the extension API contract.
docs/​README.md Links the extension workflow.
docs/​how-to/​extending-mitigations.md Explains operator steps and safety boundaries.
docs/​cookbook/​manual-mitigation.md Links extension guidance and corrects documented port limits.
CHANGELOG.md Records the lifetime-extension feature.

Review effort: Balanced

Comment thread src/db/repository.rs Outdated
Comment thread src/domain/lifetime.rs Outdated

Copilot AI 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.

🔵 Needs a closer look

The concurrency-sensitive expiry, audit, and controller-fencing boundaries warrant human safety review, and hosted qualification remains pending.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@lance0
lance0 force-pushed the feature/flowspec-lifetime-extension branch from 803f413 to 064e146 Compare October 24, 2026 03:24
@lance0
lance0 changed the base branch from feature/flowspec-destination-cidrs to feature/flowspec-admission-preview October 24, 2026 03:25

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@lance0
lance0 force-pushed the feature/flowspec-lifetime-extension branch from 064e146 to e80c203 Compare October 24, 2026 03:37
@lance0
lance0 requested a balanced review from Copilot October 24, 2026 03:37
@lance0
lance0 force-pushed the feature/flowspec-lifetime-extension branch from e80c203 to 37011af Compare October 24, 2026 03:39

Copilot AI 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.

🟡 Changes recommended

Eligibility changes can remove an open confirmation dialog and hide refusal or ambiguous-outcome warnings.

1 open issue

Review effort: Balanced

Comment thread frontend/components/dashboard/extend-lifetime-dialog.tsx Outdated
@lance0
lance0 force-pushed the feature/flowspec-lifetime-extension branch from 37011af to d56b8c4 Compare October 24, 2026 04:24
@lance0
lance0 marked this pull request as ready for review October 24, 2026 04:47
… violations

A safelist entry committed while the Postgres extension transaction waited
returned 409 Conflict, while preparation and the mock repository return the
documented 422 safelist refusal. Split the in-transaction checks so a pending
withdrawal or expiry remains 409 and a safelist match maps to the same
guardrail error as preparation.

Keep a cleared lifetime field empty instead of showing 0.
@lance0
lance0 changed the base branch from feature/flowspec-admission-preview to main October 24, 2026 16:09
…time-extension

# Conflicts:
#	CHANGELOG.md
#	docs/how-to/upgrading.md
#	docs/project/scrubber-diversion-contract.md
#	docs/reference/api.md
#	src/api/handlers.rs
#	src/api/handlers/manual_flowspec.rs
#	src/api/openapi.rs
#	src/config/inventory.rs
#	src/db/repository.rs
#	src/db/traits.rs
#	src/scheduler/reconcile.rs
#	tests/integration.rs
#	tests/integration_admission.rs
@lance0
lance0 merged commit 85f8006 into main Oct 24, 2026
16 checks passed
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.

2 participants