Repository navigation
chore: sync dev with release v1.0.5 - #4619
Merged
Merged
Conversation
* feat(subscriptions): an agent's share of a subscription, enforced at every door (#4180) * feat(subscriptions): admission policy seam for a per-agent usage share (A) One edition-agnostic point where a registered policy may stop an agent's turn before it is admitted, on every door. With no policy registered nothing changes. The first intended policy is an agent's share of its subscription's usage, registered through this seam by an optional module. - services/admission_policy.py: register / enforce / notice. A policy refuses with chat_signals.AdmissionRefused (code, plain-words message, frees_at); any other policy error is logged and the turn is admitted. - /chat (admit_chat_request) and /task (dispatch_parallel_task) call it after the skill gate, before the idempotency claim: a refused request claims, uploads, writes and acquires nothing. - execute_task step 1c covers every other door: the row closes SKIPPED with the message (not FAILED: no schedule failure count, no breaker), error_code usage_share, and the refusal on the result. - routers/chat.py maps it to 429 + X-Trinity-Error-Code + Retry-After; a sync /task refused inside execute_task releases its claim and gets the same answer; the Workspace shows the message as category `limit`, not retryable. - ExecutionContext.usage_notice renders the policy's notice as a `- **Usage**:` line via compose_system_prompt's auto-fill. Tests: tests/unit/test_ent1059_admission_policy_seam.py (18). Each seam call, the SKIPPED write, the router mapping, the Workspace branch, the notice fill and the fail-open re-raise were removed one at a time and a named test went red each time. test_2638's pre-dispatch allowlist gains `policy_denied` with its reason. Refs abilityai/trinity-enterprise#1059 Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(subscriptions): usage-share refusal survives the task backlog drain (B) A share that ran out while a sync /task waited in the backlog: the drain closes the row SKIPPED, and a long-poll that reads the terminal back from the row (another worker drained it, or the wait timed out) rebuilt a success-shaped result from a SKIPPED row. It now answers the seam's own refusal. - execute_task's policy gate stores the row error as `[usage_share] text` (the #3114 pull-sink shape), so a reconstruct can tell a share stop from any other SKIPPED; the in-memory result keeps the plain message. - _dispatch_sync_backlog's reconstruct branch rebuilds AdmissionRefused from a SKIPPED row carrying that code; _map_task_failure then releases the claim and the router answers 429 usage_share (no Retry-After: the row has no frees_at, the message says when). Tests: test_ent1059_admission_policy_seam.py +2 (20). The reconstruct removed -> the drain test red; the prefix removed -> the SKIPPED-row test red; each restored from a copy. Refs abilityai/trinity-enterprise#1059 Co-Authored-By: Claude Fable 5.1 <[email protected]> * feat(subscriptions): usage share card and breakdown column (C) An agent's share of its subscription's usage, as its owner reads and changes it. Both surfaces render only when the instance is entitled to `usage_share`; an unentitled build calls nothing. - Settings > Guardrails gains a "Usage share" section (UsageShareCard): the rolling 7-day and 5-hour windows as used / budget with a meter, the warning line drawn at warn_pct, Warning / Stopped badges in words, when a stopped window frees, whether a stop ask is pending, the line the agent reads on its next turn, and where each number comes from. The owner changes it inline through the PUT; an empty field is the platform default and all three empty clears the override. Bounds are named client-side before a request; a refused PUT keeps the form open with an InlineError. Applies from the next turn, no restart. - Settings > Subscriptions per-agent breakdown gains "Share used (7d · 5h)": each agent's own percent, warning/danger tone from the share's own threshold; a share the reader cannot see renders a dash, never 0%. - stores/agents.js: getUsageShare / setUsageShare (single API client). stores/subscriptions.js: fetchAgentShares, per-agent isolated. Tests: src/frontend/tests/unit/usageShareCard.spec.js (22, mounted under jsdom). Mutations each turned it red and were restored from a copy: breakdown ungated (1 red), at_budget ignored (2), client validation bypassed (5), Guardrails section ungated (1). Raw-colour ratchet: no existing file grew; the new card carries 0 raw non-gray. Refs abilityai/trinity-enterprise#1059 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(execution): every door answers an admission-policy refusal; a refused loop iteration is skipped, not failed (abilityai/trinity-enterprise#1059 fix) Review C2, H1, the test_3274 sweep red and I5 on the pre-admission policy seam. C2: a turn an admission policy stopped inside `execute_task` is a SKIPPED row `[usage_share] <sentence>`, and `_admission_policy_gate` returned it as a result rather than raising — so every `dispatch_and_await_terminal` caller that branched on failed/cancelled only answered success-shaped with an empty reply. On the paid door that attached the execution to the claim, logged verify-ok and SETTLED a charge for a turn that never ran. - `chat_signals.admission_refusal_of(result, agent_name)` is the one rule: the in-memory attribute when the gate ran in this process, else a rebuild from the row's `skipped` + code shape. `result_from_execution_row` attaches it, so a turn refused on another worker (the backlog drain, a long-poll reading the row back) carries the same refusal; the separate rebuild in `_dispatch_sync_backlog` is that call now. - One branch per door, before failed/cancelled: paid releases the claim and neither attaches nor settles (no charge; `payment.reason` is the sentence); MCP inline chat answers 429 with the sentence and `X-Trinity-Error-Code`; a channel sends the sentence and returns before step 12 so no empty assistant turn is persisted; the public link answers 429 (sync) or stores the sentence as the reply (async); `portal_chat` reads status + code as well as the attribute; a room posts the policy's sentence and keeps its resume handle and cursor; A2A maps `skipped` to `rejected` with the message on the inline path as `_ROW_STATE` already did for the row; a refused validation turn is an ERROR verdict. The scheduler (`internal.py`), fan-out and operator-resume doors already record the skipped row with its message and need no branch; voice and the brain orb call `execute_task` directly and close SKIPPED. H1: `loop_service._close_run` counted a policy-refused SKIPPED as a failed run (only a gate-held SKIPPED was exempt), so `failed_runs` rose, `on_failure` applied, and an at-budget loop kept ticking to `max_runs`. It now reads the refusal off the row (`_split_error_code` + the predicate), closes the run `skipped`, counts nothing, and stops the loop with the code as `stop_reason`. Sweep: `usage_notice` joins the platform-controlled list in `test_3274_gate_context` — the line is composed by a policy from platform numbers and never reads requester text. I5: `fetchAgentShares` runs at most six reads in flight. Docs: `requirements/security.md` §20.5d and `architecture/execution.md` state the result-not-worker rule and each door's branch. Red before the fix, with the door code reverted and the predicate kept: all ten door tests in `test_ent1059_refusal_doors.py` (the paid one read `settled`, the Workspace one DID NOT RAISE, A2A read `failed`) and both loop variants beside the ent#751 hold test (`('failed', 'error')`); restored byte-identical. Co-Authored-By: Claude Fable 5.1 <[email protected]> * fix(completion-report): a refused turn's report shows the policy's sentence, not its [usage_share] code (abilityai/trinity-enterprise#1059 re-review N1) An admission-policy refusal closes the row SKIPPED with `[usage_share] <sentence>`, and the completion report (Workspace, Slack, Telegram) posted that text as-is. The report now strips a known `[code]` prefix from a non-success terminal before sanitising; an unknown `[...]` and any success text stay as the agent wrote them. `_split_error_code` moves to the cycle-free `execution_envelope` leaf as `split_error_code` so the report uses the same parser; the old names stay importable from `task_execution_service`. Also adds an executing spec for `fetchAgentShares`' six-lane cap (re-review N3): a deferred `getUsageShare` over 15 names, high-water mark 6, every name written, a failed read as `{ error: true }`. Mutation-checked: with the cap at 100 it fails (expected 15 to be 6). Red before the fix: test_the_workspace_report_shows_the_sentence_without_the_code, test_the_channel_report_shows_the_sentence_without_the_code. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Trinity Agent (trinity) <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> * feat(workspace): a credential handed in the chat — ask by name, masked field, stored in the agent's .env (trinity-enterprise#1066) (#4186) * feat(asks): a credential ask kind the agent raises by name and only the secret field answers (trinity-enterprise#1066) An agent that needs a secret asks for it BY NAME: `type: credential` with `context.credential_name`. The ask sink validates the name through a new policy leaf (`services/credential_ask_policy.py`: the agent reader's variable charset, at most 64 characters, never a name the agent runtime refuses from `.env` or one the platform writes — mirrored from the agent image's `execution_env` and held in parity by test), refuses `options` (`invalid_options`), and refuses the kind unless exactly one person is resolved (`no_person`). The value never travels through an ask: `answer()` takes `via_credential_sink`, and a credential row answered any other way raises `CredentialAnswerRefused` → 422 `credential_answer_via_field` on both doors (operator respond, Workspace answer). Dismiss is unchanged. The Workspace projection carries `credential_name` only; the wake prompt names the variable and says to read it from the environment, never a value. Mutations recorded: removing the `via_credential_sink` check turns TestAnswerRefusal (2) and TestOperatorDoor (1) red; disabling the `no_person` check turns the three no-person cases red; both restored byte-identical. Co-Authored-By: Claude Fable 5.1 <[email protected]> * feat(workspace): the secret field's sink stores the credential on the agent and answers the ask by name only (trinity-enterprise#1066) A `credential` ask is answered through ONE new Workspace door, `POST /api/enterprise/client-portal/asks/{id}/credential` (a person only — `get_portal_principal` fences agent keys out before the row is read, a system or ops key is 403 `person_required`; the same uniform 404 as the answer route, which here also covers an ask of another kind). The service runs the answer route's door checks (own ask, pending, not expired, not diverged) BEFORE the value is handled, then hands it to the one secret-handling leaf, `services/credential_sink.py`: * the NAME re-checked against the ask policy (a file-channel row validates nothing) and the value checked by shape only (`invalid_value`: empty, below the scrub's floor, over 32 KiB, a line break or NUL); * STAGED into the runtime identity scrub FIRST, fail-closed — 503 `scrub_unavailable` when the store is down, so nothing is delivered that the scrub cannot see; * the agent must be running (409 `agent_not_running`, naming the state); * one sink write per agent at a time through a short Redis lease (409 `env_busy`; a lease the store cannot grant is the same fail-closed 503); * `.env` read through the agent's own `GET /api/credentials/read`, one line set in place through `agent_env_patch.set_keys` (the #2023 quoting the agent's reader reverses; duplicates collapsed; every other byte kept — round-tripped in test against the agent image's `parse_env_file`), refused over 256 KiB (`env_too_large`), written back through `POST /api/credentials/inject` (503 `agent_unreachable` on either leg); * audit `credentials` / `chat_provide` with the name, the ask id and the file — never the value — and the requirements report cache dropped. Only then does the ask sink end the row `provided` with `via_credential_sink`; a compare-and-set lost after the write is 409 `already_resolved` with `credential_written: true` and nothing is rolled back. The value appears in no log line, no audit field, no refusal message, no response body and no wake prompt — asserted in test on every path, and pinned by an AST guard over the module: `value` may be measured, staged, patched into the file or passed on, never formatted, logged, concatenated or raised. Verified from the code, not the plan: the inject path is a whole-file read-modify-write, so the lease is what keeps two sink writes from dropping each other's key across workers. The owner's Credentials-tab inject and the Nevermined bind (ent#966, "no agent-side lock, D8") do not take it and keep their last-writer-wins contract — a documented residual of this change, not closed by it. Mutations recorded, each restored byte-identical: dropping `stage_secret` (4 red), the running check (2), the lease (2), the file cap (1), the line-break/NUL check (3), the kind check in the service (1), the person check on the route (2), `via_credential_sink` (6), and a `logger.info` that formats the value (the AST guard and the leak test, 2). Co-Authored-By: Claude Fable 5.1 <[email protected]> * feat(workspace): a secret pasted as a plain chat message is refused before admission (trinity-enterprise#1066) Both Workspace chat routes (`POST …/agents/{name}/chat` and `/chat/stream`) refuse a message that LOOKS like a credential with 422 `secret_in_message` after the roster and rate-limit gates and before anything else: no reply context, no title decision, no session row, no execution row, and on the streaming route no Idempotency-Key consumed (the ent#403 rule for a refused model). The refusal names the SHAPE that matched and points at the secret field a `credential` ask opens; it never carries the text. The detector, `utils/credential_sanitizer.secret_shape`, runs over `SECRET_VALUE_PATTERNS` — the one list the execution-log redaction already uses — which gains two service-token shapes (`ops_…`, `dop_v1_…`) in BOTH the backend and the agent-image copy, so logs learn them in the same change. Two deliberate differences from redaction: `Bearer` / `Basic` are excluded (in a chat message they are prose about an API, and a false refusal teaches people to route around the guard), and a sensitive `KEY=value` pair counts only with a value of 8+ characters (the identity scrub's own floor) under the #3311 harmless-word blanking (`author=…` is not a credential). Every pattern in the list is either named or excluded, and the test pins that partition complete so a new shape cannot silently escape the guard. Mutations recorded, each restored byte-identical: dropping the guard call on the sync route (11 red), on the stream route (11), the `ops_` shape from the redaction list (the both-copies redaction test), the `ops` entry from the guard's names (3), the `KEY=value` branch (6), the value floor (3 prose cases), and `Bearer` from the excluded set (the partition pin). Co-Authored-By: Claude Fable 5.1 <[email protected]> * feat(mcp): ask_for_credential — an agent asks the person in the chat for a secret by name (trinity-enterprise#1066) A one-purpose MCP tool over the credential ask kind: `ask_for_credential(name, why, request_id?, expires_at?)` raises `type: credential`, titled "Needs NAME", with `context.credential_name`, addressed to primary and carrying the turn id so it reaches the person of the conversation. The body is built from the declared fields only — a value, an agent name or options passed alongside never travel. Left out, request_id is derived from the name and the turn, so a retry in the same turn replays instead of asking twice. Refusals come back named (no_person, invalid_credential_name). The description (1.6k characters, under the 2,048 cap) says to ask only in a conversation with the person, never to ask for a secret in a plain message, and to read the value from the environment without repeating it. Registered in TOOL_ACCESS_POLICY as self-acting; the documented tool count moves to 176. Red first: the new describe block in operator_queue.test.ts failed on the missing tool (TypeError reading execute/description) before the tool existed. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(workspace): a masked secret field in the thread for a credential ask (trinity-enterprise#1066) `PortalCredentialField.vue` is what a `credential` ask renders as in PortalAsks, wherever the card is mounted (thread, Inbox, rail, agent page): the variable's name, a masked input (`type=password`, autocomplete/spellcheck off, password-manager hints off) with Show/Hide, and Send. Send posts once through the new store action `provideCredential` → `POST /asks/{id}/credential` with the value in the body only, and the field is emptied BEFORE the request goes out, so no component state holds the value whatever the server answers; unmounting empties the element too. Nothing touches the drafts or storage, nothing is logged, and each refusal the sink names (agent_not_running, scrub_unavailable, asks_unavailable, already_resolved with or without credential_written, the server's own invalid_value words) is said in an InlineError. Discuss is hidden on the kind: a discussion chat is a composer. The shared kind rule gains `credential` (`queueResponseKind`, label "Needs a credential"), so the Operating Room card, the detail panel and /m show no respond box or acknowledge for it — one line saying it is answered in the person's Workspace. The thread's history row reads "NAME provided" and the card "You provided NAME", never the stored response. The composer, on a 422 `secret_in_message` from either chat route, drops the failed bubble (a Retry would only re-send it), never hands the text back to the composer, clears any draft still holding it, and shows the server's pointer above the composer until the next send. Design system: primitives only (BaseInput, BaseButton, InlineError), the card's own ink, no raw colour — the new file starts at zero. Red first: the three new mount specs failed on the missing component, the `acknowledge` kind, the quoted "provided" answer and the visible respond box, and on the secret staying in the thread. Mutations recorded: removing the `secret` branch of settleDelivery turns 2 composer cases red; removing the field's pre-request clear turns 6 field cases red; both restored. Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(workspace): build the credential-field fixtures at run time (trinity-enterprise#1066) The two new specs carried token-shaped literals; the backend guard's tests build theirs by concatenation so no token-shaped string sits in the tree. Same here. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(credentials): a credential handed in the chat — requirements, architecture, flow, user docs (trinity-enterprise#1066) - requirements/credentials.md §3.10: the capability — ask by name, masked Workspace field, one `.env` line, "NAME provided", only the field answers, named refusals, what is out of scope. - requirements/security.md §20.11: the one door, the one leaf (scrub first, fail closed; lease; one line; audit by name), the answer refusal, the name policy, the paste guard and the composer keeping no copy, and the stated residuals (channel adapters, non-sink `.env` writers last-writer-wins, live stream). - architecture/backend.md: `credential_sink.py` and `credential_ask_policy.py` in the services catalog; the credential kind on the `ask_service` entry. - architecture/mcp-server.md: `ask_for_credential` on the operator_queue.ts row. - feature-flows/credential-in-chat.md (new) + index rows. - user docs: how a person answers a credential ask and what happens when a secret is pasted into the chat (credential-management.md), the card and the tool in approvals.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(credentials): the secret sink never treats an unread .env as empty (trinity-enterprise#1066) The sink rewrites the agent's whole `.env`. The agent's read endpoint omitted the file from `files` in three cases that are not "no file": it held a non-UTF-8 byte (returned in `files_b64`, which the sink never read), the read raised (swallowed into a warning), or the path was not a regular file. The sink mapped all of them to "" and the inject then replaced the file with one line, deleting every other credential with a success response. The agent read endpoint now lists a path in `missing` only when lstat raises FileNotFoundError, and reads from `_HOME` rather than a hard-coded home. The sink treats `.env` as empty only when it is in `missing`; under `files_b64` it is 409 `env_unreadable` (reason `not_utf8`), and absent from all three maps (a read error, or an agent image older than the list) it is 409 `env_unreadable` (reason `unconfirmed`). Nothing is written in either case. Red first: with the sink unfixed, a .env with other keys plus a Latin-1 byte and a .env mode 000 were both overwritten through the agent image's real read/inject router over a tmp home (DID NOT RAISE), and so was an omitted file from an older image. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(credentials): the ops_ shape matches the service-account token, not snake_case (trinity-enterprise#1066) `ops_[A-Za-z0-9_-]{20,}` matched any identifier of 20+ characters after `ops_` — this platform's own `ops_context_critical_threshold` setting, lease keys, function names. Because the shape sits in SECRET_VALUE_PATTERNS, such an identifier was both refused as a pasted secret in the Workspace chat and redacted from every persisted log, in the backend and the agent image. The token's real form is `ops_` + a base64url JSON document, which always begins `eyJ`. Both copies now use `ops_eyJ[A-Za-z0-9_-]{40,}` (the guard's name map with them; the partition test pins the three together). Red first: three ops_ identifiers were refused by `secret_shape` and redacted by `sanitize_text` in both copies (6 red); they now pass through both, are admitted on both chat routes, and a realistic token is still refused and redacted in both copies. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(asks): a credential ask is addressed to primary only, on every door (trinity-enterprise#1066) The MCP tool sent `to: primary`, but `_validated_ask` never looked at `to` for the kind, so `POST /api/agents/{self}/operator-queue` accepted `type: credential` addressed to `viewer`, `approver` or `role:<id>` as long as one person filled it — handing a viewer a field that writes into the agent's environment. - `_validated_ask` refuses any role but primary for the kind with 422 `invalid_to` (the REST door, which the MCP tool calls). `to: operator` is now refused there too, before addressing. - The file channel never reaches `_validated_ask`: its clamp resolves the addressee from the entry's `addressed_to_email`. For the kind, an addressee who is not the agent's single primary person is dropped, so the item is ingested unaddressed (an operator item no Workspace field opens for). Fails closed on a resolution error, never raises (#1632). Red first: `to` viewer / approver / role:finance were created or refused with the wrong code (6 red), and the file-channel clamp kept a viewer as the addressee (1 red). Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(credentials): a refused credential write takes its value back out of the scrub (trinity-enterprise#1066) The sink stages the value into the runtime identity scrub before it checks the agent, takes the lease or touches the file. A refusal after that (agent not running, env busy, lock store down, read unreachable, env unreadable, file too large) left the value staged in Redis for 24 h while the person was told "nothing was stored". - `runtime_secret_scrub.stage_secret` now returns whether THIS call added the value; `unstage_secret` removes one (best-effort, never raises). - The sink runs steps 3-5 in `_deliver` and, on a `CredentialSinkError` that left the agent's file untouched, unstages what it staged. A value staged earlier by something else keeps its protection. - The inject leg is the exception: the agent may have written before failing, so the value stays staged and the message now says it may or may not be stored, instead of implying nothing was. - Every pre-inject refusal message says nothing was stored, and now that is true of the scrub too. Red first: the seven pre-inject refusal arms left the value staged and/or did not say nothing was stored (7 red); the inject arms and the already-staged case are pinned alongside. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(workspace): a credential card names the asking agent and quotes its reason (trinity-enterprise#1066) A credential ask can be raised from any turn — a schedule's ask reaches the owner's Inbox — and the card showed the agent's name only on surfaces that pass `showAgent`, with the agent's `why` drawn as the card's own body. A person could not always tell who was asking, or that the reason was the agent's claim. For the kind, the card now always says "<agent> is asking you for NAME" (the agent's display label, else its name) and quotes the reason in a blockquote under "In <agent>'s words:", or says it gave no reason. The reason is drawn once, attributed, not also as the generic question. No colour of its own (the raw-colour ratchet is unchanged). Red first: the mount spec over the real PortalAsks and store found no asker line and no attributed quote (2 red). Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(workspace): pin the drafts-clearing loop in dropSecretMessage (trinity-enterprise#1066) The review found no spec reached the loop: the composer watch already clears THIS thread's draft when the send empties the field. The loop is not redundant — it clears the same text left as a draft in ANOTHER conversation (pasted there first, then sent here), which sits in local storage. That case is now seeded and asserted, with an unrelated draft kept. Mutation: with the loop deleted from PortalConversation.vue the new case goes red (1 failed); restored byte-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(credentials): the review fixes in the flow and the backend catalog (trinity-enterprise#1066) Primary-only addressing (REST door and file channel), `env_unreadable` and the agent read endpoint's `missing` list, unstaging on a refusal before the inject, the attributed card, the tightened `ops_` shape, and the owner-reach residual. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Trinity Agent (trinity) <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]> * chore(enterprise): bump the submodule pointer to main (bacec40 -> 448cdbc) (#4190) Three enterprise commits, all on enterprise main: ent#982 (steward proposes members and task owners), ent#1061 (a task reaches its owner from the project record), ent#1070 (the per-agent usage share policy, the private half of #4180). Co-authored-by: trinity-ability <[email protected]> Co-authored-by: Claude Fable 5.1 <[email protected]> * feat(agents): a tag in github:owner/repo@ref pins the clone; purge_agent_now removes an agent at once, audit first (#4183) * feat(subscriptions): admission policy seam for a per-agent usage share (A) One edition-agnostic point where a registered policy may stop an agent's turn before it is admitted, on every door. With no policy registered nothing changes. The first intended policy is an agent's share of its subscription's usage, registered through this seam by an optional module. - services/admission_policy.py: register / enforce / notice. A policy refuses with chat_signals.AdmissionRefused (code, plain-words message, frees_at); any other policy error is logged and the turn is admitted. - /chat (admit_chat_request) and /task (dispatch_parallel_task) call it after the skill gate, before the idempotency claim: a refused request claims, uploads, writes and acquires nothing. - execute_task step 1c covers every other door: the row closes SKIPPED with the message (not FAILED: no schedule failure count, no breaker), error_code usage_share, and the refusal on the result. - routers/chat.py maps it to 429 + X-Trinity-Error-Code + Retry-After; a sync /task refused inside execute_task releases its claim and gets the same answer; the Workspace shows the message as category `limit`, not retryable. - ExecutionContext.usage_notice renders the policy's notice as a `- **Usage**:` line via compose_system_prompt's auto-fill. Tests: tests/unit/test_ent1059_admission_policy_seam.py (18). Each seam call, the SKIPPED write, the router mapping, the Workspace branch, the notice fill and the fail-open re-raise were removed one at a time and a named test went red each time. test_2638's pre-dispatch allowlist gains `policy_denied` with its reason. Refs abilityai/trinity-enterprise#1059 Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(subscriptions): usage-share refusal survives the task backlog drain (B) A share that ran out while a sync /task waited in the backlog: the drain closes the row SKIPPED, and a long-poll that reads the terminal back from the row (another worker drained it, or the wait timed out) rebuilt a success-shaped result from a SKIPPED row. It now answers the seam's own refusal. - execute_task's policy gate stores the row error as `[usage_share] text` (the #3114 pull-sink shape), so a reconstruct can tell a share stop from any other SKIPPED; the in-memory result keeps the plain message. - _dispatch_sync_backlog's reconstruct branch rebuilds AdmissionRefused from a SKIPPED row carrying that code; _map_task_failure then releases the claim and the router answers 429 usage_share (no Retry-After: the row has no frees_at, the message says when). Tests: test_ent1059_admission_policy_seam.py +2 (20). The reconstruct removed -> the drain test red; the prefix removed -> the SKIPPED-row test red; each restored from a copy. Refs abilityai/trinity-enterprise#1059 Co-Authored-By: Claude Fable 5.1 <[email protected]> * feat(subscriptions): usage share card and breakdown column (C) An agent's share of its subscription's usage, as its owner reads and changes it. Both surfaces render only when the instance is entitled to `usage_share`; an unentitled build calls nothing. - Settings > Guardrails gains a "Usage share" section (UsageShareCard): the rolling 7-day and 5-hour windows as used / budget with a meter, the warning line drawn at warn_pct, Warning / Stopped badges in words, when a stopped window frees, whether a stop ask is pending, the line the agent reads on its next turn, and where each number comes from. The owner changes it inline through the PUT; an empty field is the platform default and all three empty clears the override. Bounds are named client-side before a request; a refused PUT keeps the form open with an InlineError. Applies from the next turn, no restart. - Settings > Subscriptions per-agent breakdown gains "Share used (7d · 5h)": each agent's own percent, warning/danger tone from the share's own threshold; a share the reader cannot see renders a dash, never 0%. - stores/agents.js: getUsageShare / setUsageShare (single API client). stores/subscriptions.js: fetchAgentShares, per-agent isolated. Tests: src/frontend/tests/unit/usageShareCard.spec.js (22, mounted under jsdom). Mutations each turned it red and were restored from a copy: breakdown ungated (1 red), at_budget ignored (2), client validation bypassed (5), Guardrails section ungated (1). Raw-colour ratchet: no existing file grew; the new card carries 0 raw non-gray. Refs abilityai/trinity-enterprise#1059 Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(execution): every door answers an admission-policy refusal; a refused loop iteration is skipped, not failed (abilityai/trinity-enterprise#1059 fix) Review C2, H1, the test_3274 sweep red and I5 on the pre-admission policy seam. C2: a turn an admission policy stopped inside `execute_task` is a SKIPPED row `[usage_share] <sentence>`, and `_admission_policy_gate` returned it as a result rather than raising — so every `dispatch_and_await_terminal` caller that branched on failed/cancelled only answered success-shaped with an empty reply. On the paid door that attached the execution to the claim, logged verify-ok and SETTLED a charge for a turn that never ran. - `chat_signals.admission_refusal_of(result, agent_name)` is the one rule: the in-memory attribute when the gate ran in this process, else a rebuild from the row's `skipped` + code shape. `result_from_execution_row` attaches it, so a turn refused on another worker (the backlog drain, a long-poll reading the row back) carries the same refusal; the separate rebuild in `_dispatch_sync_backlog` is that call now. - One branch per door, before failed/cancelled: paid releases the claim and neither attaches nor settles (no charge; `payment.reason` is the sentence); MCP inline chat answers 429 with the sentence and `X-Trinity-Error-Code`; a channel sends the sentence and returns before step 12 so no empty assistant turn is persisted; the public link answers 429 (sync) or stores the sentence as the reply (async); `portal_chat` reads status + code as well as the attribute; a room posts the policy's sentence and keeps its resume handle and cursor; A2A maps `skipped` to `rejected` with the message on the inline path as `_ROW_STATE` already did for the row; a refused validation turn is an ERROR verdict. The scheduler (`internal.py`), fan-out and operator-resume doors already record the skipped row with its message and need no branch; voice and the brain orb call `execute_task` directly and close SKIPPED. H1: `loop_service._close_run` counted a policy-refused SKIPPED as a failed run (only a gate-held SKIPPED was exempt), so `failed_runs` rose, `on_failure` applied, and an at-budget loop kept ticking to `max_runs`. It now reads the refusal off the row (`_split_error_code` + the predicate), closes the run `skipped`, counts nothing, and stops the loop with the code as `stop_reason`. Sweep: `usage_notice` joins the platform-controlled list in `test_3274_gate_context` — the line is composed by a policy from platform numbers and never reads requester text. I5: `fetchAgentShares` runs at most six reads in flight. Docs: `requirements/security.md` §20.5d and `architecture/execution.md` state the result-not-worker rule and each door's branch. Red before the fix, with the door code reverted and the predicate kept: all ten door tests in `test_ent1059_refusal_doors.py` (the paid one read `settled`, the Workspace one DID NOT RAISE, A2A read `failed`) and both loop variants beside the ent#751 hold test (`('failed', 'error')`); restored byte-identical. Co-Authored-By: Claude Fable 5.1 <[email protected]> * fix(completion-report): a refused turn's report shows the policy's sentence, not its [usage_share] code (abilityai/trinity-enterprise#1059 re-review N1) An admission-policy refusal closes the row SKIPPED with `[usage_share] <sentence>`, and the completion report (Workspace, Slack, Telegram) posted that text as-is. The report now strips a known `[code]` prefix from a non-success terminal before sanitising; an unknown `[...]` and any success text stay as the agent wrote them. `_split_error_code` moves to the cycle-free `execution_envelope` leaf as `split_error_code` so the report uses the same parser; the old names stay importable from `task_execution_service`. Also adds an executing spec for `fetchAgentShares`' six-lane cap (re-review N3): a deferred `getUsageShare` over 15 names, high-water mark 6, every name written, a failed read as `{ error: true }`. Mutation-checked: with the cap at 100 it fails (expected 15 to be 6). Red before the fix: test_the_workspace_report_shows_the_sentence_without_the_code, test_the_channel_report_shows_the_sentence_without_the_code. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(agents): a dotted tag in github:owner/repo@ref pins the clone The ref after `@` was checked against [A-Za-z0-9_-/] only, so a release tag such as v1.2.0 failed the check and was dropped without a word: the agent was created on main while the caller believed it pinned. The ref is now taken whole when it is a valid branch or tag name (dots allowed, minus the git ref-format shapes '..', a leading-dot component, a trailing '.' or '.lock'), and an unusable ref is a named 400 instead of a silent fall-back to main. The charset stays a shell-safety barrier for startup.sh's eval-built clone. Red first: tests/unit/test_4165_github_ref_tag.py — the five dotted refs returned url_branch=None and the ten unusable refs did not raise. Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(agents): purge_agent_now removes an agent at once, audit first (abilityai/trinity-enterprise#1055) Agent delete is a soft delete (#834): rows, volumes and the MCP key stay for the retention window. Removing an invited member's agent, or rolling back a half-created one, must leave nothing but the audit trail, so the retention sweep's hard purge becomes an immediate, edition-agnostic primitive with no route of its own: - the agent_lifecycle:purge audit row is written while the agent still exists and outlives it; if it cannot be written nothing is destroyed (503) - a person caller must pass assert_admin (an agent key carrying an admin owner's role is refused); actor=None is the platform itself - container, queued and in-flight work, Redis state, the #816 cascade (sharing, permissions both ways, MCP key) and the data volumes under both identities of a renamed agent (#1664) go; a base another agent claims stays; a Docker fault never stops the row purge - system agents (403) and ephemeral agents (409) are refused; no row is a no-op Red first: tests/unit/test_ent1055_purge_agent_now.py (module absent). Each of five mutations turns it red: admin gate removed (2), fail-closed removed (1), soft-delete-before-purge removed (7), base-claim guard removed (1), audit moved after the container removal (2). Docs: requirements/core-agent.md §1.4.1 and §4.2 ref pinning (trinity#4165); architecture/agent-lifecycle.md pointer. Registry: both new test files. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(agents): a tag in github:owner/repo@ref survives the three ref-existence checks (trinity#4165, abilityai/trinity-enterprise#1055 review C1) The parser accepted a dotted tag and stored it in `source_branch`, but every check that consumed that value before the clone asked for a BRANCH of that name: `provisioning.check_remote_branch_exists` ran `ls-remote --heads refs/heads/<ref>`, `ref_probes._ref_arg` prefixed `refs/heads/`, and the PAT path asked `GET /repos/{repo}/branches/{ref}`. So a tag passed the parser and was refused with "Branch 'v1.2.0' not found" on every path; the public doc claimed it pinned the clone. Now all three accept a branch or a tag, the ref still a value after the URL and never an option: the anonymous check asks for `refs/heads/<ref> refs/tags/<ref>` with no `--heads`; the probes ask for both and take the branch first (as `git clone -b` does), peeling an annotated tag to its commit; the REST path answers a 404 on `/branches/{ref}` with `/git/ref/tags/{ref}` before calling the ref missing. The refusal names both: "Branch or tag '…' not found". Red first: `tests/unit/test_4165_ref_existence_checks.py` drives the real `check_remote_branch_exists`, `probe_anonymous_ref`, `probe_tokened_repo_access` and `_validate_github_access` on all three paths against a fake `ls-remote` that filters like git (so a check that asks for heads only cannot see the tag) — 9 of 15 red before the change, all green after. Three pins on the old branch-only contract moved with it (`test_3725_*`: the argv now carries both refs and a same-named tag answers when no branch does; `test_ent123_tokenless_clone`: the wording). Docs: `requirements/core-agent.md` §4.2 names the three checks and the precedence; the two flow rows that quoted `--heads` / the old wording follow. Registry entry added. Co-Authored-By: Claude Fable 5.1 <[email protected]> * fix(agents): a ref in github:owner/repo@ref may not begin with '-' (trinity#4165, abilityai/trinity-enterprise#1055 review I5) `_GITHUB_REF_RE` admitted `-foo`. Safe today — every live site passes the ref as a value (`git clone -b <ref>` takes the next token whatever it starts with; the probes prefix `refs/…`) — but `startup.sh` also runs `git checkout "${SOURCE_BRANCH}"`, where a leading `-` IS parsed as an option, benign only because the clone already checked the ref out. One shell edit away from not. The regex gains `(?!-)`; the 400 names it. Red first: `TestRefRefused[-foo]` — DID NOT RAISE. Upgrade-safe: the parser has one caller (creation); no stored `source_branch` is re-parsed on boot, pull or reset, so existing agents are untouched. Co-Authored-By: Claude Fable 5.1 <[email protected]> * fix(agents): an annotated tag in @ref resolves to its commit, not the tag object (trinity#4165) `ref_probes` asked `ls-remote` for `refs/heads/<r>` and `refs/tags/<r>` and took a peeled `refs/tags/<r>^{}` line when one was listed. git never listed one: it shows a ref only when a pattern names it, and the peeled line's name ends in `^{}`. So an annotated tag resolved to the TAG OBJECT, and the raw template read was pinned to an id that is not the commit the clone checks out. The probe now also asks for `refs/tags/<r>^{}` by name. The unit fake listed `^{}` lines for a bare tag pattern, which is why the old test passed. It now lists a ref only when a pattern names it, and a new file runs the probes against a real bare repository over file:// (a lightweight tag, an annotated tag, a branch and an annotated tag sharing a name). Red first: test_4165_ref_probes_real_git.py — the annotated-tag and tokened cases returned the tag object id; 4 others passed. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(agent-server): a tag-pinned agent's pull cycle is a named skip, not a failure every tick (trinity#4165) `github:owner/repo@<tag>` clones with `git clone -b <tag>` in source mode, which leaves the agent on a detached HEAD: pinned to that release, by design. Pull sync is on for every `github:` agent, and `_run_pull_once` recorded `failed: detached HEAD: nothing to pull onto` on every cycle, a failure streak for an agent doing what it was asked to. A detached HEAD now records `skipped` with the reason named. A detached HEAD left by a rebase stopped part-way (its rebase-merge/rebase-apply directory exists) stays `failed`, so a stuck tree still shows. The push cycle is unchanged: it is off by default for a source-mode agent, and an owner who turns it on for a pinned agent gets an honest failure. Red first: test_4165_pull_cycle_pinned_tag.py::test_every_cycle_is_a_named_skip_not_a_failure — 'failed' == 'skipped'. Real repos, the agent cloned -b v1.0.0 (annotated). Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Trinity Agent (trinity) <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: trinity-ability <[email protected]> * fix(credentials): keep the credential read inside the agent home and make the paste guard linear (#4191) * fix(agent-server): the credential read stays inside the agent home (trinity-enterprise#1066) CodeQL flagged the `os.lstat` this branch added to `GET /api/credentials/read` (path depends on a user-provided value). The finding is real at the guard, not at any current caller: - the guard (`lstrip("/").lstrip(".")`, a `".." in` test on the stripped string, `str(resolved).startswith(str(home))`) let a single leading `../` through, and its prefix compare had no separator, so `../home2/.env` READ a file in a sibling directory whose name extends the home's; - the new `lstat` ran before any containment check, so `../<anything>` came back in `missing` — an existence probe one level above the home. Not reachable before this fix through the platform: the route sits behind the agent's per-agent auth middleware (#1159) and every backend caller sends fixed relative paths (`.env`, `.mcp.json`, `.credentials.enc`) or the agent's own `/list` output. Fixed at the root with one helper, `_contained_read_target`: refuse absolute paths and any `..` component, then require both the normalised lexical path and the link-resolved path to sit under the home with a trailing separator. `lstat` runs on the contained lexical path (the absence proof); the read goes through the contained resolved path, so a link is followed only to a target that is itself inside. Red first: tests/unit/test_ent1066_credential_read_containment.py — 5 of 13 red at the previous guard (sibling read, `../` oracle, absolute path, link to a sibling file, linked parent directory), all green with the fix; the fix reverted from a scratch copy turns the same 5 red. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(sanitizer): the paste guard's KEY=value walk is linear by construction (trinity-enterprise#1066) CodeQL flagged the two regex calls in `secret_shape` (py/polynomial-redos, "may run slow on many repetitions of '!'"). Origin: the patterns pre-exist on dev — `_KV_LINE_RE` / `_KV_PAIR_RE` are the redaction's #1661/#3311 walk — but these two alerts are introduced by this branch, which feeds them a Workspace chat message (user-provided text) through the new guard. Measured before the change, CPython was already linear on every shape tried (`!`*n, `=`+`!`*n, `!`*n+`=`, `!=`*n, `k=!`*n, an unclosed quote, sensitive keys with short values): 1M characters took 0.04-1.1 s, scaling ~10x per 10x. The lookbehind pins each key to the start of its run — the engine detail CodeQL's model does not see (#1661 says the same). The route caps a message at 100k characters. The guard no longer rests on that detail. It finds each `=` with `str.find`, walks back to the key start (never past the previous `=`, so no character is visited twice), and checks the value with one fixed-width match — an optional opening quote and eight non-space, non-quote characters. No length cap, so nothing at the end of a long message is dropped. One deliberate widening: the closing quote is no longer required, because a truncated paste is still the secret. The redaction path is unchanged. Red first: tests/unit/test_ent1066_secret_guard_linear.py — red before the change on the no-unbounded-regex pin and the unclosed-quote case (2 of 43); the timing bound (1M < 3 s, 10x input < 30x time) and both-way detection were green before and after. The change reverted from a scratch copy turns the same 2 red. The 1661/2208/2398/3840 sanitizer suites and the paste-guard suite stay green (608 passed). Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Trinity Agent (trinity) <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> * chore(enterprise): bump the submodule pointer to main (448cdbc -> f347a02) (#4193) Picks up abilityai/trinity-enterprise#1072 (member_agents module, ent#1055), which composes the purge_agent_now primitive from #4183. Co-authored-by: trinity-ability <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> * revert: an agent's share of a subscription (#4180) (#4199) * Revert "feat(subscriptions): an agent's share of a subscription, enforced at every door (#4180)" This reverts commit 9eedbbb6e0be8d5b73ccb5e8f0217a33a987b089. * chore(enterprise): bump the gitlink to the ent#1070 revert (trinity-enterprise#1076) Lands with the #4180 revert so dev never carries the usage_share module without the admission_policy seam it imports. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: trinity-ability <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> * fix(sub-003): the agent's auth answer outranks a prompt-length mention, and the turn-limit anchor is pinned (#4123) (#4197) * fix(workspace): keep a room's content inside the Inbox reading pane (#4160) (#4169) Every agent bubble renders PortalMarkdown's sr-only live region, which is position:absolute. The reading pane's scroll box was not positioned, so those regions resolved against the page, escaped the overflow box, and a long room stretched the document: the wheel scrolled the whole Workspace. Make the scroll box `relative`, as the list column's already is. Adds a mount spec pinning the containment structure for a long room, a room with many messages, and a thread. Fixes #4160 Co-authored-by: Claude Opus 5.5 <[email protected]> * refactor(operator-queue): the listing engine moves to listing.py, and the poller core into PollerCoreMixin (#3785, PR 2 of 4) (#4037) * fix(operator-queue): the #1677 helper delegates to the platform-alert seam create_bounded_alert(_outcome) keep their signatures and outcome contract and become a thin delegate of platform_alerts.observe, which already composes the per-(agent, type) budget inside its one locked create. The registered type names its kind; the key is read back from the item's id and context by derive_legacy_subject and must resolve to that same kind, else ALERT_FAILED_CREATE. The two kinds whose ids carry no subject (gitignore, problem report) are keyed by the request id minus the kind's prefix. observe's "updated" and "snoozed" pass through; "failed" maps to ALERT_FAILED_CREATE; every refused or failed arm logs [#1677 budget]. ALERT_FAILED_COUNT stays importable and is no longer returned. The budget episode reports through observe as kind alert_budget keyed by the budgeted type: one alert_budget:<type> row per agent, re-read by a later refusal outside the cooldown, ended by its 14-day lifetime. The bucketed id and its own operator_queue_new broadcast are gone; observe sends the thin operator_queue_sync trigger. Ratchet: create_bounded_alert_outcome and _maybe_emit_alert_budget_episode leave EMITTERS_NOT_YET_ON_SEAM; alert_budget gets a NO_CLEAR_SITE reason. Census: both leave _ALLOWED_CALLERS (no direct create left in either). #3254 re-pins (asserted outcomes unchanged): - test_1677_operator_alert_budget: write-observation point. The harness stands in for the seam's create with the same budget arithmetic and runs what observe spawns. Id shape in test_deterministic_bucketed_id_with_reserved_prefix, test_cooldown_knob_zero_never_raises (the subject replaces the bucket) and test_under_cap_creates_item_and_notification (the seam's id). The episode raise now stays in its spawned task, so test_episode_helper_raise_swallowed_refusal_stands reads the delegate's WARNING marker; test_ws_broadcast_failure_swallowed checks the thin operator_queue_sync payload. - test_3130_flood_guard, test_1632_operator_queue_caps: write-observation point. The flood alert still rides the delegate, so its writes, the typed budget read and the I1 fault injection move to the seam's create. - test_3243_atomic_asks::test_a_cap_hold_never_fires_the_flood_alert: write-observation point. Watched at observe, since the oqs.db assertion alone would now pass whether or not the alert fired. Known until the problem report moves in its own commit: nine test_3521_problem_report_comment cases are red here. The delegate files an event-kind row under the seam's id, which the old _attach_comment (keyed on the pre-seam request id) cannot find. New: tests/unit/test_3254_budgeted_alerts.py (registry parity, reach-back imports, the delegate's outcome table over all five budgeted types, the episode's seam properties, R1 for alert_budget). Part of #3254 * fix(operator-queue): the flood alarm reports through the seam and ends with its episode OperatorQueueSyncService._maybe_emit_flood_alert reports through platform_alerts.observe as kind queue_flood keyed by the reason: one pending row per (agent, reason), rewritten in place, budgeted by the seam. #3130's outcome rule is kept on observe's strings: a failed write releases the episode and is retried after the cooldown (I1); created, updated, snoozed and refused consume it. While an episode lasts it is re-read at most every 6 hours, so the kind's 14-day lifetime ends only a row nobody re-read, never a condition that still holds. The refresh time per (agent, reason) is a dict the method creates on the instance for itself; __init__ is unchanged. The flood's own operator_queue_new broadcast (which carried the title) is gone; observe sends the thin operator_queue_sync trigger. The two _sync_agent statements where an episode ends (_flood_episodes.discard for oversize_file and ingestion_cap) become calls to the new _end_flood_episode, which ends the episode and, only when one was running, ends its alert as the platform through platform_alerts.clear. A cycle with no episode costs no read. Ratchet: _maybe_emit_flood_alert leaves EMITTERS_NOT_YET_ON_SEAM; queue_flood's clear site is _end_flood_episode. No re-pin in this commit: the #3130 and #1632 harnesses were moved to the seam's create in the previous commit and keep their results. Tests: the flood through the real _sync_agent poll for 30 simulated days with the real expiry sweep (one row, re-read every 6 hours, ended as the platform when nothing is held), no read without an episode, two reasons two subjects, I1 on the real seam, a person's ending standing through the re-read and the clear, the thin trigger, R1 for queue_flood. Part of #3254 * fix(execution): the effect guard and missing-skill alarms report through the seam _on_unguarded_effect reports a refused effect through platform_alerts.observe as kind effect_unguarded keyed "<effect_type>:<reason>": one row per agent, effect and reason, rewritten by each further refusal, ended by its lifetime (nothing observes an agent starting to send ids). The send is refused whatever the alarm's outcome. _alert_skill_not_found reports through observe as kind skill_not_found keyed by the truncated command: one row per agent and command, re-read by each scheduled run. The paired notification is sent only on "created": a repeat of a pending command is an "updated" reading and already had one; refused, failed and snoozed wrote no new row. The pre-create dedup read stays and now matches only a pending pre-#3246 row (no subject), which keeps standing for its command until the upgrade sweep stamps it; a seam row is re-read through observe, where a repeat is never refused at the cap. task_execution_service.py: only _alert_skill_not_found changes. Its module-level utc_now_iso import is now unused and is left in place. Ratchet: _on_unguarded_effect and _alert_skill_not_found leave EMITTERS_NOT_YET_ON_SEAM; skill_not_found gets a NO_CLEAR_SITE reason (only the dispatch path could see a command resolve, and there the detector cannot tell "resolved" from "not a slash command"). #3254 re-pins (asserted outcomes unchanged): - test_1677_operator_alert_emitters:: test_skill_not_found_emitter_is_routed_not_allowlisted: the module must call platform_alerts.observe naming "skill_not_found" (AST), the seam that composes the budget, instead of mentioning create_bounded_alert. - test_2392_effect_guard_fail_closed: write-observation point and id shape. The alarm is recorded at platform_alerts.observe instead of a sys.modules stub of operator_queue_service, which lacks the names the seam reaches back for. The id prefix is asserted on the kind; the at-budget case returns the seam's refused_at_budget. - test_ent879_aauth_resource_route (the refused-call case): the dead create_bounded_alert patch moves to platform_alerts.observe. Tests: the effect refusal's seam properties and lifetime; the missing skill's one row per command, no notification on a repeat, a pre-seam row still standing, no notification at the cap; R1 for both kinds; the other shape, the clock 30 days ahead: a full skill_not_found budget frees itself through the real expiry sweep and a new command files. Part of #3254 * fix(git-sync): the gitignore sweep's alert is one row per change set _emit_gitignore_untracked_alert reports through platform_alerts.observe as kind gitignore_untracked, which stops being an event kind (platform_alerts.py: event=True dropped). It is a must-act kind: no lifetime, never ended by the platform. It is keyed by the change itself: a 32-hex digest of the canonical, direction-tagged set of paths the Push untracked and newly un-ignored (sorted removed paths, the exact removed count, sorted un-ignored paths). A repeat of the same set collapses onto one row; a different set, a different total behind a capped list, or the same path in the other direction is a different row. Keying per agent would let a later Push overwrite an earlier Push's path list on a pending must-act alert, which #2529 calls the surface that outlives the session. The legacy prefix keeps its _no_subject parser, so pre-existing rows stay pending until a person acts. Ratchet: _emit_gitignore_untracked_alert leaves EMITTERS_NOT_YET_ON_SEAM. #3254 re-pins (asserted outcomes unchanged): - test_2529_gitignore_precedence: write-observation point and id shape. The alert is watched at platform_alerts.observe (the two create.await_count == 0 checks would otherwise have gone vacuous); the per-agent id prefix is asserted on the kind, with the 32-hex key. - test_3246_platform_alerts_leaf::test_event_kind_has_no_subject: gitignore_untracked is a condition now, so it is asserted keyed and the problem report stays the event example. Tests: a repeated set is one row that never expires; distinct sets and a capped list with another total stay distinct; the direction tag holds; a person's ending stands; the 30-day case now also shows the gitignore row still pending. Part of #3254 * fix(workspace): the problem report is one seam row per person, target and day raise_problem_report reports through platform_alerts.observe as kind workspace_problem_report, which stops being an event kind (event=True dropped). It is keyed by the 32-hex digest _problem_report_id already computes: one row per person per target per UTC day, the "never duplicates" rule its docstring states. A person must act on it, so it never expires and the platform never ends it. The workspace-problem- id prefix is kept, so ent#866's owner-only rule and the machine-key "about a person" exclusion still hold. It returns True when the row was created or updated, False when snoozed, refused or failed. #3521's words-only rule moves under the seam's lock. observe gains keep_text (passed through database.create_platform_operator_queue_item to create_platform_item and _touch): with keep_text and a pending row, the reading only counts (last_seen_at, seen_count, expires_at) and the title, question, priority and context stand. The bare click passes keep_text, a reading with words does not. The click and the comment are two background requests that meet on one row inside the per-agent lock, so either order ends with the words. With no pending row the reading files as usual. update_pending_problem_report (database.py, db/operator_queue.py) and the nested _attach_comment are removed: one write path. Ratchet: raise_problem_report leaves EMITTERS_NOT_YET_ON_SEAM, which fixes the nine test_3521 cases the delegate commit left red. #3254 re-pins (asserted outcomes unchanged): - test_3521_problem_report_comment: the acknowledgement fixture goes through ask_service.answer (fixture shape; a raw status UPDATE carries no person ending for the snooze to read); the accessor test asserts the same type guard at the seam (a foreign row under the report's old id is never written); the lost-race test injects the bare click's whole reading, in its own thread, before the comment's locked create. - test_ent499_problem_report: write-observation point. The fake moves from create_bounded_alert to platform_alerts.observe; the routing AST test asserts the call to observe. - test_ent715_queue_person_fields: update_pending_problem_report leaves _NON_ROW_ACCESSORS (the accessor census forbids a stale entry). - test_3246_platform_alerts_leaf::test_event_kind_has_no_subject: no built-in kind is an event any more, so the property is pinned on a kind registered for the test, and both former events are asserted keyed. test_ent866_problem_report_owner_only is unchanged. Tests: keep_text at the sink, both interleavings keeping the words, one must-act row per person, target and day, the owner-only prefix, the delegate and the emitter landing on one subject, a person's ending not rewritten or reopened; the 30-day case now also shows the report still pending; the five-type admission test asserts every kind keyed. Part of #3254 * fix(operator-queue): decide a platform alert's snooze under the create's lock observe checks the snooze before the create's lock. Two moments let a person's ending slip past that check: an acknowledgement after observe read the pending row but before the locked create (the locked find then misses), and one between the locked find and _touch's compare-and-set (the lock covers creates, not respond_to_item, so the CAS loses). Either way the create fell through to an insert, and the alert a person had just ended was back at once. Before this batch most of the moved writers had a deterministic id that could not re-file after an ending, so the moves would otherwise ship that regression. create_platform_item gains snooze_since and a snoozed predicate. On the insert path, after a missed find or a lost CAS and inside the same locked transaction, it reads the newest person-ended row for the subject through the transaction's own connection (the public lookup opens another one) and returns {"outcome": "snoozed"} without inserting when the predicate says so. observe passes the standard 7-day window, computed on its own rather than from the pre-lock check's conditionally assigned cutoff, and lambda ended: _snoozed_by(kind, ended, priority, context). The pre-lock check stays as the fast path. A caller that passes neither keeps the old behaviour. The statement behind the public find_person_ended_by_subject becomes _find_person_ended_by_subject(conn, ...), shared by both reads. Tests: a person's acknowledgement through ask_service.answer, landed (a) between observe's read and the locked create and (b) between the locked find and the CAS, yields "snoozed" and no new row, for the problem report, an inbox collision as registered on dev, and the flood alarm's 6-hourly re-read. All six cases were red before this commit (a fresh row was created) and pass with it. On SQLite, BEGIN IMMEDIATE holds every other writer, so moment (b) lands the ending first and hands both finds the row as it stood just before it; two real workers are not exercised. Review fixes carried here (the earlier commits are left as they are): - OperatorQueueSyncService._maybe_emit_flood_alert: the cooldown is stamped before every reading, the 6-hourly re-read included. A failed re-read released the episode with the cooldown stamp still 6 hours old, so it was retried on the next 5-second cycle. New test: a failed re-read is retried no sooner than the cooldown (red before the fix). - test_3521_problem_report_comment (the lost-race re-pin): asserts the bare click's own request returned True and left a pending, comment-free row before the comment's locked create ran, so the test cannot pass without the interleaving it claims. - gitignore_sweep: states that past the probe's 2,000-line cap the key is the capped list plus the exact total (a full-set digest needs the in-container probe, outside this change). - test_1677_operator_alert_emitters: the census's guidance for an agent-influenceable emitter now points at platform_alerts.observe, not the delegate the #3246 ratchet counts as off the seam. - test_3254_budgeted_alerts: the frozen clock also covers db.operator_queue's ent#815 commit-lag check, which logged spurious errors against the real clock. Part of #3254 * fix(operator-queue): a failed flood re-read keeps the episode, so its end still clears the alert Fresh review of the #3254 budgeted slice (two findings): - A failed 6-hourly re-read of a persisting flood released the episode. If the condition then cleared before the retry, `_end_flood_episode` found no episode and the pending alert waited out its 14-day lifetime, although the code had …
Co-Authored-By: Claude Fable 5.2 <[email protected]>
vybe
approved these changes
Nov 17, 2026
trinity-ability
enabled auto-merge
November 17, 2026 13:48
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.
Merges the v1.0.5 release squash on
mainback intodevso the two share history. No content change: the trees are identical. Merge with a merge commit, never squash.🤖 Generated with Claude Code