Skip to content

feat: publish and stream principal invalidations from the client - #14

Draft
pyropy wants to merge 1 commit into
srdjan/feat/iam-invalidate-routefrom
srdjan/feat/iam-client-invalidate
Draft

feat: publish and stream principal invalidations from the client#14
pyropy wants to merge 1 commit into
srdjan/feat/iam-invalidate-routefrom
srdjan/feat/iam-client-invalidate

Conversation

@pyropy

@pyropy pyropy commented Sep 10, 2026

Copy link
Copy Markdown

Description

The client publishes and streams principal revocations. Invalidate submits a self-signed /principal/invalidate the way Publish submits a revocation; StreamEvents yields both firehose kinds and Stream stays as a deprecated filter. The reconnect logic no longer moves its resume point backwards, and asks from one settle window back so late records are not lost. Part of the Forge S3 tenant IAM work (RFC).

Change log

  • Client.Invalidate, Client.StreamEvents; Stream deprecated
  • streamConn handles principal and skips unknown event names
  • Monotonic resume, reconnect from one settle window back, settle-window dedup set
  • swarf stream prints <kind> <json>; README updated
  • itest: a stranger is refused, an allowlisted invalidation is observed

🤖 Generated with Claude Code

Client.Invalidate self-signs a /principal/invalidate invocation the way
Publish signs a revocation, so a Hilt deployment on Swarf's publisher
list can record that a principal's cached proofs are void.
Client.StreamEvents carries both event kinds; Stream stays as a
deprecated filter that yields only revocations, and an event name the
client does not know is skipped rather than treated as corrupt. The CLI
prints the event kind before each record.

Streaming also resumes correctly after a late record. A record committed
inside the service's ten second settle window arrives behind newer ones,
and the resume timestamp moved back to it, so the next connection
re-delivered every record already sent from the newer timestamp. The
resume timestamp now only moves forward and the delivered causes stay in
the dedup set for as long as a reconnect could repeat them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@pyropy
pyropy added this pull request to stack #12 September 10, 2026 21:22
@pyropy
pyropy force-pushed the srdjan/feat/iam-client-invalidate branch from ebb92dc to 7dbede3 Compare September 11, 2026 12:40
@pyropy
pyropy requested a lite review from Copilot September 11, 2026 12:42

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

Incremental pruning is needed to avoid quadratic work in pkg/client/client.go.

Pull request overview

Adds principal invalidation publishing and unified event streaming, with reconnect handling, CLI support, documentation, and tests.

Changes:

  • Adds Client.Invalidate and Client.StreamEvents.
  • Supports principal and delegation events with reconnect deduplication.
  • Updates CLI output, documentation, and integration coverage.
File summaries
File Summary
README.md Documents principal invalidations and event streaming.
pkg/fx/app_test.go Tests invalidation authorization and uniqueness.
pkg/client/client.go Implements publishing and unified streaming; pruning currently performs potentially quadratic work.
pkg/client/client_test.go Tests invalidation, event handling, and reconnect behavior.
itest/happy_path_test.go Adds end-to-end authorization and streaming coverage.
cmd/swarf/stream.go Prints both firehose event kinds.
cmd/swarf/stream_test.go Tests mixed event output.
Review details

Suppressed comments (1)

pkg/client/client.go:266

  • This scans every entry in seen whenever a newer timestamp arrives. With a busy firehose, the map contains roughly one settle window of events, so a burst of n records performs O(n²) pruning work and can make the client fall behind. Keep the timestamps in an ordered queue/min-heap (retaining the map for CID lookup), or otherwise prune incrementally.
					horizon := resume.Add(-streamSettleWindow)
					for link, at := range seen {
						if at.Before(horizon) {
							delete(seen, link)
						}
  • Files reviewed: 7/7 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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