Repository navigation
Disable deleted sub-account addresses; reinstate and pool them on create - #49
Merged
Merged
Conversation
Deleting a derived sub-account now stops its address accepting new messages in fmsgid (POST /fmsgid with accepting_new false), so fmsg hosts refuse new mail to it, before the grant is deleted. If fmsgid can't be updated the delete fails with 503 and keeps the grant, so it can be retried rather than leaving an address accepting mail with nothing to retry from. Delegated identities are left alone. Creating a derived sub-account registers its address with accepting_new true and quota_pool set to the owner, so it shares the owner's quota. Only the owner can derive the address, so one that already exists was theirs before: fmsgid reinstates it and the create response reports "reinstated": true (false for a new address). If the grant then can't be created the reinstated address is disabled again. The api-key create CLI does the same and prints reinstated=. An fmsgid without accepting_new answers POST /fmsgid with no body: creation then works as before with reinstated false, and deletion fails rather than claiming the address was disabled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Needs markmnl/fmsgid#7 (
accepting_new/quota_poolonPOST /fmsgid,{"created","reinstated"}response).DELETE /fmsg/sub-accounts/:agent: for aderived_sub_accountgrant, firstPOST /fmsgid {"address":…, "accepting_new":false}so fmsg hosts refuse new mail to the address (they answer "not accepting"), then delete the grant. Fail-closed: if fmsgid fails (or is too old to supportaccepting_new, detected by its empty response body) the request is503and the grant is kept so the owner can retry. Deleting first would leave the address accepting mail with no grant left to retry the disable from. Delegated identities are not touched.POST /fmsg/sub-accounts: registers the derived address withaccepting_new: trueandquota_pool: <owner>(shares the owner's quota). Only the owner can derive@<owner>_<agent>@<domain>, so an existing address is theirs from before: fmsgid reinstates it and the response gains"reinstated": true(falsefor a new address) so a UI can say the address was used before, is active again and its earlier messages are still there. If the grant can't be created afterwards (409, limit), a reinstated address is disabled again.api-key createCLI: same registration/reinstatement/undo; printsreinstated=true|false. (There is no CLI delete.)POST /fmsgid, so a disabled address is refused immediately.reinstated: false); deletion fails with 503 until fmsgid is upgraded.Test plan
go test -race ./...,go vet ./..., gofmt cleanFMSG_TEST_DATABASE_URL(throwaway Postgres 17): handler lifecycle (create → delete disables → re-create reinstates, quota_pool = owner; conflict leaves it accepting), delete keeps the grant on fmsgid failure / old fmsgid and succeeds on retry, delegated delete sends nothing, failed re-create (limit) re-disables, old fmsgid create; CLI reinstate and undo-on-conflictreinstatedparsing, empty/malformed/422/503 responses, cache invalidation🤖 Generated with Claude Code