Skip to content

docs(agent-identity): settle the broker's write order for every audit event - #2984

Merged
ChrisJBurns merged 6 commits into
mainfrom
docs/audit-write-order
Nov 26, 2026
Merged

ChrisJBurns merged 6 commits into
mainfrom
docs/audit-write-order

Conversation

@rdimitrov

@rdimitrov rdimitrov commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Settles the two design points #2541 asks for before its implementation starts. The implementation is #2985, which follows these rules.

1. What each broker event does when the audit sink does not accept its record. Until now, audit.md's "Write order and failure" covered only the ID-JAG, the call decision, and refusals. It is now a table covering every broker event:

Event Waits for its record? Without it
Session open, any kind Yes Nothing changes, and a refresh token the open got is discarded and revoked. An open that converted the request's token fails as for token_used (the client refreshes), or 503 when the same caller failed the same way within a minute; either way the token is spent. Any other fails UNAVAILABLE. A scheduled run's open retries once, then the run does not start.
Instance registration Yes UNAVAILABLE, not registered. A new helper's or team member's first registration is not retried: it does not run. The root's registration retries when the run starts, and re-registrations after a reopen on the next call.
Accepted delegation report Yes UNAVAILABLE, not stored. A new helper's first report is not sent again: it does not run. Re-reports after a reopen keep their retry.
Schedule setup or renewal Yes As a converted open: nothing stored, the grant AS-1 issued is revoked; a failed renewal keeps the current grant.
ID-JAG issuance; decision for a tool call or listing Yes (unchanged for calls) UNAVAILABLE, no token
Session close No The close takes effect. Deleting a host session also closes an open still in progress, and no new broker session is created for it for a bounded time.
Refusals No (unchanged) The refusal is returned; a refused open never leaves a session
Any other record No, unless its section says so The event takes effect

Most events that wait are the ones later records reference by AuditID: per-call events point to the session-open record, lineage to registration and delegation records, scheduled runs to the schedule. The ID-JAG and the decision wait so that nothing is redeemed or dispatched before its record exists. A close never waits, because holding it back would keep the session's refresh token usable; a refusal never waits, because holding it back would turn a denial into a retryable error.

A sink can store a record and still fail to confirm it. When the broker undoes an event after its record was not accepted, or after an accepted record because the session closed while it was recorded, it records a refusal whose mecatl.supersedes names the earlier record, so lineage checks and reconciliation see a rollback. The outcomes table gives that refusal error for record_not_accepted and denied when a close undid the event.

The broker reports these failures with the reason record_not_accepted. Step (3)'s failures and client mapping, step (4)'s and the delegation report's failure tables, the scheduled-run open, the failure matrix, and "Error reasons" each gain the case.

2. How the open record names a refresh token it replaced. By the AuditID of the open record that stored it and that open's source token jti, never by its value. ToolHive's refresh tokens are opaque, so the broker has no jti of its own to record. The broker grant record keeps that AuditID.

3. A fact #2985 records that the design did not name. user_client_id and user_client_iss in Subjects: the client the user's token was issued to, such as the TUI client, and its authorization server. client_id keeps its meaning in every component's records.

Left to other tickets

Asking for

Agreement on rules 1 and 2, or corrections; they are the two "settle in the design before starting" items on #2541.

Checks

  • task docs passes.

Refs #2541

🤖 Generated with Claude Code

… event

audit.md's write order covered only the ID-JAG, the call decision, and
refusals. #2541 asks for the rest to be settled before it starts: what a
session open, an instance registration, a delegation report, and a close
do when the sink does not accept their record, and how the open record
names a refresh token it replaced.

An open, a registration, and an accepted delegation report wait for
their record and fail as UNAVAILABLE without it, because later records
reference them by AuditID. A close and a refusal never wait. A replaced
refresh token is named by the AuditID of the open record that stored it
and that open's source token jti, since the broker cannot read a jti
from an opaque refresh token.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…in the records

The #2541 implementation records three facts the design did not name:
the stand-in parent of a team member created over the API, the stand-in
delegation from its RunTeam run, and the client a user's token was
issued to as client_id and client_iss. Registration and delegation
inputs now say that mecak8s reports the stand-in mark, and the
write-order table says a session a refused open created is not kept
when the refusal's record is not accepted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@ChrisJBurns ChrisJBurns left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review of the write-order rules against the rest of the agent identity design and the tickets that build on them. Each point is a question with the lines to check, so it can be verified or rejected point by point; I may be wrong on any of them. Line references are at c823930.

1. A refused open record: UNAVAILABLE, or "as for a refused token"?

The new table says a session open whose record is not accepted "fails as UNAVAILABLE", and that a converted access token "is spent, so the client refreshes it" (audit.md write-order table, row 1).

Step (3) already has a rule for an open that converted the token and then could not keep its session: "If the broker session closes after an open converted the request's token, the broker revokes the refresh token it got, the request fails as for a refused token, and the client refreshes it" (credentials-and-lifecycle.md:258). In "Error reasons", UNAVAILABLE is listed only as coming from AS-1 or AS-2, as "a retryable infrastructure error" (credentials-and-lifecycle.md:972).

  • Should a refused record after conversion fail as for a refused token, like the step (3) case, with UNAVAILABLE only for a tokenless open?
  • If UNAVAILABLE is intended, which "Error reasons" row and failure-matrix row cover a broker-sourced UNAVAILABLE? A client following the current table retries with the spent token and gets token_used.
  • "Changes nothing" leaves out the converted jti, which the broker must still remember. Is that intended?

2. Who retries a refused registration or delegation report?

The table says "mecak8s retries it as any failed registration" and "mecak8s reports it again as any failed report".

  • Which rows in step (4)'s failure table and the delegation report's failure table give that retry? As I read them, retries cover an expired workload credential, a lost response, and check 2 "after a new session opens", not a refused record.
  • In #2985, a failed registration stops the helper: "An error stops the helper before it runs" (internal/adapter/server/identity_broker_helpers.go:25). Nothing reports a delegation again. Is the intent to add a retry in mecak8s, or to change the table to say the helper or team member fails?

This matters for #2557 (team runs) and #2817 (end-to-end): once #2566's sink can refuse records, one sink hiccup ends a team member, and a delegation never reported again makes the run's later calls fail with PERMISSION_DENIED (step 6, check 4).

3. Does the lossless sentence decide #2848's open question?

The new last sentence of "Lossless delivery": "A close or a refusal still takes effect; its record waits for the sink instead of being dropped." The same paragraph says components "block or refuse the operation rather than buffer and drop records", and #2848 still asks whether lossless delivery belongs in phase 2 (#2566) or phase 3.

  • Since a close is never held back, its record has to be queued somewhere. Is that a durable outbox (which touches #2563's storage), or in memory (lost on a crash)?
  • Should this sentence wait for #2848 instead?

4. "Not accepted" versus "not written"

The table treats a record the sink did not accept as never written, and drops the session, instance, or delegation. An HTTP sink can time out after the collector has already stored the record, which #2566 and #2848's lossless mode both allow.

  • What does the trail show then? The success record exists for something that was rolled back.
  • #2985 has a Supersedes field on a follow-up refusal record for some paths (a close during the record). Should the design define that, and apply it to every rollback after a refused record, so #2844's lineage walk and #2848's reconciliation can tell these apart from forged records?

5. client_id means two things

The Subjects row now reads: "client_id and client_iss: the client the user's token was issued to" (audit.md:38). For AS-1's conversion, the user's token was issued to the TUI client, while the design says AS-1 records the conversion with client mecatl (credentials-and-lifecycle.md, step 3, "AS-1 records the conversion"), and V carries client_id=mecatl.

  • Should the user's token client have its own key (for example user_client_id and user_client_iss), so client_id means the same thing in every component's records?
  • The previous sentence "client_id by its authorization server" was the general qualification rule for every client_id. Was removing it intended?

6. The refusal row says both "never waited for" and "kept only if accepted"

"Refusal … Never waited for … A session a refused open created is not kept when the refusal's record is not accepted."

  • To know whether the refusal's record was accepted, the broker has to wait for it. Which is intended?
  • Step (3) doesn't say a refused open leaves a session. Could this be "a refused open never leaves a session, whatever happens to its record"?

7. Stand-in parents and delegations: audit or lineage design?

The stand-in mark for API-created team members changes registration and delegation semantics, not only records.

  • Registration check 7 compares host session, owner, definition, and parent, but not the mark, while the delegation report treats the mark as content for check 6. Can a re-registration flip it without being refused?
  • Nothing checks that a stand-in parent is the root instance, or that a stand-in delegating run belongs to it.
  • Does this need agreement on #2555/#2557 (teams without a source session) first, since it decides part of what those tickets parked?

8. Events the table doesn't cover

The table is introduced as covering every broker event. These seem to be missing:

  • schedule setup and a scheduled run's session open (#2569, #2843); if a scheduled open is "session open, of any kind", a sink refusal fails a run with nobody present, and the scheduled-run failure table has no row for it;
  • the decision that authorizes a tool listing (#2729), which brings an ID-JAG and a decision for each gateway listing;
  • credential renewal, which re-registers (#2562);
  • sign-out everywhere, SVID issuance, and definition load (#2848's producers).

Should there be a catch-all row ("any other record: not waited for unless its section says otherwise"), or explicit rows?

9. Smaller points

  • Rule 2 names a replaced refresh token by "the AuditID of the open record that stored it". implementation.md's broker grant record has no field for that AuditID. Should it be added, so #2563 makes it durable?
  • "Record first, then store state" settles part of #2563's open item on the persistence ordering of correlation records across a restart. Should #2984 leave crash ordering to #2563?
  • "Discarded, and revoked once revocation exists" is implementation status in final-state text; step (3) already requires revocation. Could this say "discarded and revoked", with the gap as a code shortcut naming #2568?

- An open whose record is not accepted fails as for a refused token
  when it converted the request's token, and as UNAVAILABLE otherwise;
  the broker still remembers the converted jti.
- A refused registration or delegation record is not retried: the
  helper or team member does not run. Both failure tables and the
  error reasons gain the row.
- A refused open never leaves a session; other records are not waited
  for unless their section says so.
- An undone event's record may still exist, so the broker records a
  refusal that supersedes it.
- The user's token client gets its own keys, user_client_id and
  user_client_iss, and the general client_id rule is restored.
- The broker grant record keeps the AuditID of the open that stored
  its refresh token.
- Lossless queuing of close records is left to #2848, crash ordering
  to #2563, and the stand-in marks to #2557.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rdimitrov

Copy link
Copy Markdown
Member Author

Thanks, all nine checked out. cf42713 addresses them; #2985 is being updated to match.

  1. Refused open record. Agreed. An open that converted the request's token now fails as for a refused token, the same as step (3)'s close-after-conversion case, so the client refreshes; only an open that converted nothing fails as UNAVAILABLE. The broker still remembers the converted jti. "Error reasons" gains a broker-sourced record_not_accepted row.
  2. Retry of a refused registration or report. No retry: the table now matches the code. The helper or team member does not run, and both failure tables gain a "record not accepted" row. Whether mecak8s should retry once Audit records and delivery #2566's sink can refuse records is a question for Audit records and delivery #2566.
  3. Lossless sentence. Removed; queuing close and refusal records under a lossless sink is left to [Phase 3] Authorization server and gateway audit records, and reconciliation #2848.
  4. Not accepted versus not written. Added: when the broker undoes an event after its record was not accepted, it records a refusal whose mecatl.supersedes names that record's AuditID, so lineage checks and reconciliation see a rollback, not a forgery.
  5. client_id. The user's token client now has its own keys, user_client_id and user_client_iss, and the general "client_id by its authorization server" rule is back.
  6. Refusal row. Now "a refused open never leaves a session, whatever happens to its record".
  7. Stand-in marks. Removed from this PR and from feat(identitybroker): record who acted, for whom, and what was decided #2985; they belong with Runs, delegations, and the run owner #2557's decision on teams created over the API.
  8. Other events. Added a catch-all row: any other broker record is not waited for unless the section that defines the event says otherwise. Scheduled opens, listing decisions, renewal and the others can then each say so when they are designed.
  9. Smaller points. The broker grant record gains the open record's AuditID; crash ordering is left to Durable broker state and recovery #2563; "revoked once revocation exists" is now "discarded and revoked", with the gap as a code shortcut naming Sign-out and revocation #2568.

@ChrisJBurns ChrisJBurns left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for working through the first round. Points 3, 6, 7, and 9 check out at cf42713. A few things remain, mostly where the new rows meet text elsewhere in the design. As before, each is a question with lines to check, and I may be wrong on any of them. Line references are at cf42713.

1. Is record_not_accepted retryable or not?

  • The "Error reasons" row (credentials-and-lifecycle.md:953) says: "Fail the open, registration, delegation report, or call as a retryable infrastructure error."
  • The new failure-table rows say "No. The instance does not run." (:393) and "No. The receiving helper or team member does not run." (:476), as does audit.md:128-129.
  • #2985's comment on the reason also says to retry it (internal/identitybroker/errors.go:68-72 on #2985).

Could the row be split by event: a converted open as for token_used (refresh, retry once); other opens and calls retryable UNAVAILABLE; registrations and delegation reports not retried? Separately, token_used's own outcome cell says "The same.", which by table order points at the row above; since record_not_accepted now refers to token_used, could that cell be spelled out?

2. "Not retried" versus the existing retry paths

Two passages still describe retries the new rows rule out:

  • credentials-and-lifecycle.md:258: "A registration that fails after the save is retried when the run starts."
  • credentials-and-lifecycle.md:341: after a session reopens, "A helper that cannot be registered again then is registered, and its delegations reported, on its next call."

In #2985 the holder also retries a move or renewal on the next lookup. Is "not retried; does not run" meant only for a first registration or report of a new helper or team member? If so, could the rows say that, and say what happens for the root's registration and for re-registration and re-reports after a reopen (a helper that is already running can't "not run")?

3. Client mapping and failure matrix

Step (3)'s client mapping (:325) lists subject_invalid and token_used for 401 bearer_rejected, but not record_not_accepted, which #2985 maps there. Neither the step (3) failure table nor the failure matrix has a "record not accepted" row. Should they? And which client code does a non-converted UNAVAILABLE open map to?

4. mecatl.supersedes in the profile

The rule is in prose at audit.md:136, but the profile table (audit.md:33-48) doesn't list the key, and the superseding refusal's Type and Outcome aren't given. The prose also covers only "undoes an event after its record was not accepted". #2985 also writes a superseding refusal when an accepted record's event is undone because the session closed while it was recorded (agents.go:172-174, authorize.go:351 on #2985). Should the Correlation row name the key, and the rule cover both cases?

5. Scheduled-run opens

A scheduled run's open is "Session open, of any kind" (audit.md:127), but the scheduled-run failure table (credentials-and-lifecycle.md:876-887) has no row for a refused record. That open is already designed (:851), so a sink refusal fails an unattended run with nobody to retry. Should that table gain a row, or should audit.md:127 point scheduled opens to their own section?

6. The catch-all row and referenced records

The catch-all (audit.md:134) defaults to "not waited for". The reference rule (audit.md:136) keeps an event only if later records can resolve its AuditID. Two events later records will point at fall under the catch-all: schedule setup (whose grant scheduled-run records reference, #2569/#2843; :845 also says its failures are "As session open's"), and the decision that authorizes a tool listing (#2729; its ID-JAG is waited for under the ID-JAG row, but the decision isn't). Should the catch-all exclude records that a later record references by AuditID?

7. Smaller points

  • implementation.md:9 still says the records "must also carry AS-1's own subject and the token's client_id", which is now user_client_id.
  • The lossless paragraph (audit.md:138) says components "block or refuse the operation rather than buffer and drop records", while closes, refusals, and catch-all events now go ahead without their record. Could a one-line known gap say delivery of records the broker doesn't wait for under a lossless sink is open in #2848?
  • The PR description still describes the earlier rules ("mecak8s retries", stand-in marks, client_id/client_iss, lossless queuing). Could it be updated so reviewers agree to the current text?
  • Stand-in marks moved to #2557, which closed on 2026-11-23 (via #2930) without mentioning them. Is there a new ticket to track them? See the matching question on #2985.

… the design

- record_not_accepted's outcome is split by event: a converted open
  as token_used, other opens and calls retryable, and a new helper's
  first registration or report not retried; token_used's own outcome
  is spelled out.
- "Not retried" covers only a new helper's or team member's first
  registration or report; the root's registration and re-registrations
  and re-reports keep their retries.
- Step (3)'s failures and client mapping, the scheduled-run open, and
  the failure matrix gain the record-not-accepted case.
- Schedule setup and the decision for a tool listing wait for their
  records; the catch-all covers only records nothing references.
- The profile names mecatl.supersedes, which also covers an accepted
  record undone by a close during its recording.
- Lossless delivery of records the broker does not wait for is a
  known gap for #2848, and the user's token client is user_client_id
  in the identity-mapping note.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rdimitrov

Copy link
Copy Markdown
Member Author

Thanks. ce51086 addresses these, and the PR description now describes the current rules.

  1. Is record_not_accepted retryable? The "Error reasons" row is now split by event: a converted open as token_used (refresh, retry once); any other open, an ID-JAG, or a call as a retryable infrastructure error; a new helper's or team member's first registration or delegation report not retried. token_used's own outcome is spelled out.
  2. "Not retried" versus the existing retries. "Not retried; does not run" now covers only a new helper's or team member's first registration or report. The root's registration is still retried when the run starts, and re-registrations and re-reports after a reopen, a move, or a renewal on the next call; the audit table and both failure tables say so.
  3. Client mapping and failure matrix. Step (3)'s client mapping answers a converted record_not_accepted open with 401 bearer_rejected, and any other UNAVAILABLE open with 503 identity_broker_unavailable. Step (3)'s failure table and the failure matrix gain the row.
  4. mecatl.supersedes. The Correlation row names it: on a refusal that undoes an earlier record of the same event, with the event's Type and the refusal's own Outcome, code, and reason. The rule now covers both cases, a record not accepted and an accepted record undone by a close during its recording.
  5. Scheduled-run opens. The scheduled-run open's failure table gains a row: retry once as for a lost response; if the record is still not accepted, the run does not start and its fire fails as a retryable infrastructure error.
  6. Catch-all and referenced records. Schedule setup and the decision for a tool listing now have rows that wait for their records. The catch-all says an event that later records reference by AuditID is listed or waits as its section says.
  7. Smaller points. implementation.md now says user_client_id; the lossless paragraph names delivery of records the broker does not wait for as open in [Phase 3] Authorization server and gateway audit records, and reconciliation #2848; the PR description is updated. On the stand-in marks: you're right that Runs, delegations, and the run owner #2557 is closed, so they now have their own ticket, Mark team members created over the API as having a stand-in parent #2986.

@ChrisJBurns ChrisJBurns left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, all seven round-2 questions check out at ce51086, and #2986 tracks the stand-in marks. Nothing here blocks; these are minor gaps the edits opened. Same format as before: questions with lines to check, and I may be wrong on any of them. Line references are at ce51086.

1. Which sections describe "a move" and "a renewal"?

audit.md:128 and credentials-and-lifecycle.md:394 and :956 retry "a re-registration after a reopen, a move, or a renewal on the instance's next call, as their sections say". Step (4) (:344-396) has no move or renewal re-registration, and the Lifetimes table (:992) renews the SVID "while the instance stays registered to the same session", without a registration. "Move" seems to come from #2985's holder, where it is part of a reopen. Should these say only "after a reopen", or should step (4) and Lifetimes gain those paths? #2985's errors.go:79-81 also applies "move, renewal" to delegation re-reports, which :477 and audit.md:129 limit to "after a reopen".

2. Outcomes for a superseding refusal

The Correlation row (audit.md:44) gives the refusal "the event's Type and its own Outcome". The outcomes table (audit.md:50-56) defines subsets only for decision, dispatch, and observed outcome, so a refusal typed as a session open, registration, delegation, or schedule setup has no allowed outcomes. #2985 also supersedes tool-call decisions with error, which the Decision row defines as "evaluation failed", while audit.md:132 doesn't describe a decision as undone. Could the table gain rows for those types, and say which Outcome a superseding refusal uses (error for record_not_accepted, denied for a close)? And should the :137 rule include or exclude decisions?

3. implementation.md:300

It still says "registration and delegation reports fail as UNAVAILABLE, and the helper does not run", with no exceptions. Should it cover the root's registration retried when the run starts, re-registrations and re-reports on the next call, schedule setup, the listing decision, the scheduled-run open, and a refusal superseding an accepted record after a close?

4. Catch-all sentence and the unknown follow-up

The catch-all (audit.md:135) says an event later records reference by AuditID "is listed above or waits as its section says". A result after an unknown outcome is "a new event that references the earlier one" (audit.md:44), but observed outcomes are neither in the table nor given a wait rule in their section (:97-101). Is that reference by AuditID, and if so, does it need a row? Also, :137 still says "Later records reference the first three", while scheduled runs now reference the schedule-setup record.

5. Schedule rows

  • The setup row (audit.md:131) says only "nothing is stored". The open row says the refresh token is "discarded and revoked". A schedule grant can last up to 30 days; should the setup row say the grant AS-1 issued is revoked?
  • Renewal "sets up a new schedule grant" (credentials-and-lifecycle.md:895). Does it count as setup, and is the old grant kept when the record isn't accepted?
  • :889 says the fire "fails as a retryable infrastructure error". Who retries an unattended fire? #2843 still lists retrying a failed run as undecided.
  • The failure matrix row (:914) covers neither setup nor the scheduled open.

6. A sink outage reads as a sign-in problem

A converted open answers 401 bearer_rejected (:326). The client refreshes and retries once, and the second open converts a fresh token and fails the same way (:905: "signs in again if that fails"). So while the sink is down, every interactive open looks like a token problem and never reaches 503. Should a second record_not_accepted in the same request fall back to 503 identity_broker_unavailable, or should the design say what the user sees?

7. identity_broker_unavailable gains a cause

The 503 code already exists (internal/adapter/server/errorcodes.go:132, sdk/typescript/src/errors.ts:43), and user docs describe it as "The identity broker is unreachable" (user-docs/reference/http-sse-api.md:33). An audit sink refusing a record is a new cause: a compatible widening, but worth saying in #2985's wire API statement and in those docs. Also, :326 says "which the client retries"; mecatui leaves the retry to the user. "Can retry"?

8. PR description

"Left to other tickets" still says stand-ins are "not part of this PR" rather than linking #2986. "The events that wait are the ones later records reference by AuditID" doesn't cover the ID-JAG and the decision, which wait so nothing is dispatched before its record (audit.md:130, :132).

- Re-registrations retry only after a reopen; no move or renewal path.
- The outcomes table covers session open, registration, delegation,
  schedule setup, and close, and a superseding refusal uses error for
  record_not_accepted and denied when a close undid the event,
  decisions included.
- A repeated record_not_accepted on a converted open answers 503
  identity_broker_unavailable, so a sink outage does not read as a
  token problem; a 503 open is one the client can retry.
- Schedule setup or renewal revokes the grant AS-1 issued and keeps
  the current one; an unattended fire that cannot start waits for the
  next fire, with sooner retries open in #2843; the failure matrix
  covers both.
- The audit profile check and the reference rule cover every event
  that waits, and a result after an unknown outcome joins by operation
  and attempt IDs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rdimitrov

Copy link
Copy Markdown
Member Author

Thanks. 6ec9bda closes these, and the PR description is updated.

  1. Move and renewal. Removed: re-registrations retry only after a reopen, in the audit table, step (4)'s failure table, and "Error reasons". feat(identitybroker): record who acted, for whom, and what was decided #2985's errors.go wording follows.
  2. Outcomes for a superseding refusal. The outcomes table gains rows for session open, registration, delegation report, schedule setup (success, denied, error) and session close (success). A superseding refusal uses error for record_not_accepted and denied when a close undid the event. The rule now includes a decision whose token the broker withholds after a close.
  3. implementation.md. The check now covers the root's registration retried when the run starts, re-registrations and re-reports after a reopen, schedule setup and renewal, the listing decision, the scheduled-run open, and a refusal superseding an accepted record after a close.
  4. Catch-all and unknown follow-ups. A result after an unknown outcome also names the earlier one by its operation and attempt IDs, so it does not depend on that record's AuditID and needs no row. "The first three" now reads "the events that wait", and names the schedule-setup record and why the ID-JAG and decision wait.
  5. Schedule rows. The row covers setup and renewal: the grant AS-1 issued is revoked, and a failed renewal keeps the current grant. An unattended fire that cannot start waits for the next fire; retrying it sooner is left to Audit records mark scheduled runs #2843. The failure matrix row covers setup, renewal, and the scheduled open.
  6. Sink outage reads as a sign-in problem. Agreed. A converted open that fails with record_not_accepted now answers 503 identity_broker_unavailable when the same caller's previous open of that host session failed the same way within the last minute, so an outage shows as unavailable and the client stops spending fresh tokens. feat(identitybroker): record who acted, for whom, and what was decided #2985 implements it.
  7. identity_broker_unavailable gains a cause. "Can retry" now. feat(identitybroker): record who acted, for whom, and what was decided #2985 adds the audit-sink cause to its wire API statement and to the user docs.
  8. PR description. It links Mark team members created over the API as having a stand-in parent #2986 and Audit records mark scheduled runs #2843, and says the ID-JAG and decision wait so nothing is redeemed or dispatched before its record exists.

@ChrisJBurns ChrisJBurns left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, round 3 mostly checks out at 6ec9bda: move and renewal are gone, the test bullet covers every row, the schedule rows say what happens to the grant, and the description links #2986 and #2843. The new 503 repeat rule raises two questions I'd want answered before approval (1 and 2); the rest is minor. Same format as before: questions with lines to check, and I may be wrong on any of them. Line references are at 6ec9bda.

1. Does the 503 repeat rule fire for creates, forks, and clears?

credentials-and-lifecycle.md:326 answers 503 "when the same caller's previous open of that host session failed the same way within the last minute". A create without an explicit ID gets a new host session on every attempt, and fork and clear also open a new host session, so each retry looks like a first failure and gets 401 again (#2985 keys on owner and host session: internal/adapter/server/identity_broker.go:647-697). Those are the most common interactive opens, so a sink outage there still ends at sign-in (:905). Should the rule key on the caller alone, or state that creates are excluded and say what the user sees?

2. What should the client do after the 503?

The repeated open still converted the fresh token, and the broker remembers its jti (:330). If the client retries with that token, as "retry later" invites, the broker answers token_used, which is 401 bearer_rejected. In #2985 that non-repeat outcome also clears the window, so the next refreshed attempt is a "first" failure again and gets 401. Should :326 and user-docs/reference/http-sse-api.md:33 say that in this case the token is spent and the client refreshes before retrying? And should a token_used for a token the window already counted leave the window in place?

3. Who is "the same caller", and where does the state live?

The broker's caller is elsewhere the workload; #2985 keys on the session owner, in each mecak8s replica's memory, so a retry reaching another replica (#2805) or following a restart gets 401. :956 drops "of that host session" and "within the last minute", and the step (3) failure row (:323) doesn't mention the rule. Schedule setup and renewal (audit.md:135, :846) fail "as a session open that converted the request's token" but have no host session to key on; does the rule apply to them? Could step (3) say the caller is the owner as mecak8s verified it, and that the memory is per replica and best effort?

4. Closing by host session

The design says "Deleting hostS42 closes A42" (:342) and that an unsaved create closes "by its broker session ID" (:258). #2985 now closes by root host session, including a new session an open is still recording; that open then fails, supersedes its record, and stores nothing. Should step (3)'s session end say so, and say whether a later open of a deleted host session may create a new broker session? (See question 1 on #2985.)

5. Outcomes table

  • There's no row for ID-JAG issuance, though its record waits (audit.md:134) and #2985 emits mecatl_id_jag with outcomes. With implementation.md:290 ("each event type rejects outcomes outside its fixed set"), would every ID-JAG record be rejected?
  • The write-order row says "schedule setup or renewal" while the outcomes row (:57) says only "schedule setup".
  • The Decision row (:54) still defines error only as "evaluation failed", but a decision superseded for record_not_accepted now uses error.

6. The unknown follow-up

audit.md:139 says a late result "also names the earlier one by its operation and attempt IDs". The decision, dispatch, and observed-outcome records of an attempt all share those IDs, so they name an attempt rather than a record, and implementation.md:289 makes the late result a distinct attempt with its own mecatl.attempt_id. Which field carries the earlier attempt's ID? Could :44 and implementation.md:289 use the same wording?

7. Scheduled-run open, described two ways

:889 says the run "fails as any fire that cannot start", which no section defines, while :956 still files every other open under "a retryable infrastructure error", which includes the scheduled-run open. Could :956 exclude it and point to :889, and :889 either define what a fire that cannot start does or defer that to #2843 explicitly? The comment on #2843 still says the fire "fails as a retryable infrastructure error".

- The 503 repeat rule keys on the caller alone, the owner mecak8s verified,
  so creates, forks, clears, and schedule setup and renewal count too. After
  the 503 the token is spent and the client refreshes before retrying; a
  token_used retry does not end the minute. The memory is per replica and
  best effort.
- Deleting a host session closes an open still in progress, and the broker
  refuses a new broker session for it for a bounded time.
- The outcomes table gains ID-JAG issuance and covers schedule renewal; a
  decision whose record was not accepted is an error.
- A late result after an unknown outcome is a new observed-outcome event in
  the same attempt, marked mecatl.late_result.
- A scheduled run's open is excluded from the retryable-infrastructure row,
  and what else a fire that cannot start does is left to #2843.

Refs #2541

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rdimitrov

Copy link
Copy Markdown
Member Author

Thanks. 00ae95c answers these, and the PR description is updated.

  1. The 503 rule for creates, forks, and clears. It now keys on the caller alone: a converted open that fails with record_not_accepted answers 503 when the same caller's previous converted open failed the same way within the last minute, whichever host session each opened. Schedule setup and renewal count the same way. feat(identitybroker): record who acted, for whom, and what was decided #2985 follows.
  2. After the 503. Step (3) and "Error reasons" now say the token is spent either way, so the client refreshes it before retrying. A retry with the spent token fails with token_used and 401, which does not end the minute; only a successful open does. feat(identitybroker): record who acted, for whom, and what was decided #2985 keeps the window on that token_used, and http-sse-api.md says to refresh before retrying.
  3. Who the caller is. The owner mecak8s verified for the request. Step (3) says mecak8s keeps this in each replica's memory, best effort, so a retry that reaches another replica, or follows a restart, gets 401 again. The step (3) failure row and "Error reasons" now point to the rule.
  4. Closing by host session. "Session end" now says deleting hostS42 closes A42 by the root host session, together with a new broker session an open is still creating. That open fails with session_closed, records a refusal that supersedes its record, and keeps no refresh token. After the delete, the broker refuses a new broker session for hostS42 for a bounded time that outlasts opens already under way. feat(identitybroker): record who acted, for whom, and what was decided #2985 adds that mark (its question 2).
  5. Outcomes table. It gains an ID-JAG issuance row (success, denied, error). The registration row says "schedule setup or renewal". The Decision row's error covers a decision whose record was not accepted.
  6. The unknown follow-up. A late result is a new observed-outcome event in the same attempt, with the same operation and attempt IDs and mecatl.late_result=true. The attempt's earlier observed outcome, the unknown one, is the record it follows. The correlation row, the catch-all, and implementation.md's check use the same wording; a retry is still a new attempt.
  7. Scheduled-run open. "Error reasons" sends a scheduled run's open to its own failures row and excludes it from the retryable-infrastructure case. That row says the run does not start and the next fire runs as usual, and leaves what else a fire that cannot start does, such as notifying Alice, to Audit records mark scheduled runs #2843. I've posted a correction on Audit records mark scheduled runs #2843.

@ChrisJBurns ChrisJBurns left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving. Round 4 checks out at 00ae95c. The points below are minor and fine as follow-ups; I may be wrong on any of them. Line references are at 00ae95c.

  • implementation.md:300 still keys the 503 rule on "previous open of that host session". :326, :956, and #2985 key on the verified owner across host sessions, with schedule setup and renewal counting too.
  • The deleted-host-session refusal (:342) isn't in step (3)'s broker checks, failure table, or HTTP mapping (#2985 answers 401 with a token, 404 without). The failure-matrix row at :926 ("A new session opens on Alice's next request") doesn't hold during the window. "A bounded time" isn't named, and unlike the 503 window the text doesn't say the mark is per replica and best effort. #2985 also sets the mark when a scheduled run ends, which :342 doesn't mention.
  • The mark is keyed on host session only. Creates with an explicit ID come only from the scheduler today, so a re-create within the window can't happen, but keying on host session plus the deleted incarnation would keep it from ever blocking a re-create.
  • :326 says what keeps the 503 window (token_used) and what ends it (a successful open), but not other failures, or whether a successful schedule setup or renewal ends it.
  • The write-order rows at audit.md:132 and :136 don't point to the 503 exception on a repeat.
  • The ID-JAG outcome row (audit.md:57) allows denied "when a broker check refused it", but broker checks run before AS-1 and are recorded as a denied decision, so no ID-JAG record exists for them. The Decision row's error reads as if the decision record carries it; per :61 it is the superseding refusal.
  • A client can't tell the spent-token 503 from any other 503 (same code, no cause in the body). "Always refresh the access token before retrying an open's 503" would be simpler to follow.

@ChrisJBurns
ChrisJBurns merged commit df1a521 into main Nov 26, 2026
37 checks passed
@ChrisJBurns
ChrisJBurns deleted the docs/audit-write-order branch November 26, 2026 12:27
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