Skip to content

fix: name budget-rule keys, explain empty chat replies, land docs labels - #4012

Merged
yannickmonney merged 20 commits into
mainfrom
fix/admin-budgets-chat-docs
Oct 2, 2026
Merged

yannickmonney merged 20 commits into
mainfrom
fix/admin-budgets-chat-docs

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Budget rules retain readable key and owner labels after credentials stop working, settled empty chat replies explain why they have no answer, and translated documentation navigation labels resolve to the intended page.

  • Describe a budget key using evidence from its own organization. Expired, disabled, explicitly revoked, unavailable after cleanup, former-member and unknown keys stay distinct; another organization’s records cannot reveal the holder. Keep the selected historical key while editing and refresh descriptions after budget-policy changes. Labels and documentation cover EN/DE/FR.
  • End empty or failed chat streams with a reason and retry control. Preserve typed budget refusals, classify rate limits correctly and book consumed usage only when the provider accepted the work. Integration checks consume response bodies so stream cleanup cannot hide a hanging process.
  • Reuse the shared documentation resolver for localized group labels and their folder context. Resolve ambiguous aliases only within valid navigation context; existing published addresses and exact-title behavior remain covered.

Validation at 96655da8 (main 19776cf1 composed): the ordinary local root check passed 58/58 tasks (43 cached, 15 executed), with no source drift. The current-composition real-Postgres bridge passed 146 checks across the 3 affected lanes; the earlier independent full campaign passed 1,329 checks across all 215 then-existing lanes. The exact published head still requires the hosted 217-lane integration and complete browser/security gates before merge.

Local Chrome exercised the actual budget editor and shared picker in EN/DE/FR, including historical keys, long labels, keyboard dismissal and focus restoration, and rendered the final usage documentation in all three languages. Earlier causal controls reproduced the key-state, typed-refusal and navigation failures before their fixes. These focused previews use synthetic data; they do not prove persisted production behavior.

Validation limitations: preceding full-check attempts encountered sandbox/child-process timing failures; diagnostic reruns and the final unchanged-source root check passed, but the initial cause is not established. The readonly Knip scan reports 86 existing findings in 26 files whose bytes exactly match main. React Doctor reports 5 known baseline/false-positive errors and 974 warnings with degraded baseline subtraction; its advisory scan is not claimed clean. The prior 467-rule SAST pass had no findings (with recorded parser/exclusion limits); exact-head hosted SAST remains required.

No database migration. Local validation uses retained dependencies, the committed postgres.js patch and isolated database/object-store fixtures; no live production or real-provider testing was performed for this repair.

A reader or a language model that guesses a docs address from the
sidebar writes the label it sees: `/de/verwaltung` is the German label
of the platform's admin group, which no page carries as a title. The
near-miss resolver scored page titles and slugs only, so every page
under the group was found (`/de/verwaltung/mitglieder-und-rollen`) while
the group itself stayed a 404 — one of the addresses a customer's chat
agent and crawler kept hitting.

`buildNearMissIndex` now takes the site's navigation: each group's
labels, in every locale, name the group's first page, and count as
folders of the pages under it, so `/de/verwaltung/rollen` and
`/de/verwaltung/governance` land too. Two groups sharing a label (the
admin pages and the admin tutorials) are told apart by the guess's other
folders; with none to go by, the first in reading order wins. German and
French words for an overview page join the generic leaves.

Both documentation sites feed their groups in from the message catalogs
(the docs server, its 404 suggestions and the link lint read the same
index), and the reported addresses are regression cases. NAV-F21 covers
the running server.
A budget rule stores its key's bare id and outlives the key, but the
editor could only describe a key the live listing carried. Once the key
expired, was disabled or revoked, or its holder left the organization,
the rule's Target cell fell back to the id — a string of random
characters with no name and no owner, often for a rule another admin
created. The Scope and Period cells printed the stored enum (`ApiKey`,
`monthly`), and the dialog's scope and period labels were English in
every locale.

`GET /governance/api-keys` now also answers `ruleKeys`: the keys the saved
rules name that are not in the live listing, each with its state
(`expired`, `disabled`, `revoked`, `holder_left`, `unknown`). A key is
described only on this organization's own evidence — its holder is a
member now, or the organization's audit trail recorded the key's
creation — and a departed holder is named only by what that record
holds. A key the organization has no evidence of, another
organization's included, answers `unknown` with nothing about it, so a
saved rule cannot be used to ask whose a key is.

The table names each rule's key with its owner beneath and a state
label; the picker still offers live keys only, plus the key of the rule
being edited, with a note that it no longer limits anything. Scope and
period read catalog labels in all three locales. GOV-F4b is rewritten
for the new cells, GOV-F48 covers a rule outliving its key, and the
real-Postgres lane proves the listing against the auth and audit tables.
A chat reply that settled with no text kept its thinking dots and its
ticking "Thinking · Ns" for as long as the conversation stayed open: the
gap shell waited for a first glyph nothing would ever paint, while the
turn had long finished — no output tokens, the toolbar already drawn. A
customer saw exactly that with gpt-6-luna and gpt-6-sol.

Two paths led there. A provider that fails after its stream has opened
reports the failure as an event on the `200` stream (OpenRouter's
documented mid-stream `error` beside `finish_reason: "error"`; LiteLLM
and the Anthropic wire send their own shapes), and the decoder read it
as an ordinary event with no text, so the turn settled `complete` and
empty with the provider's words dropped. And a model can end a reply
with nothing in it: an empty `stop`, a whole output limit spent
thinking (`length`), or its provider's content filter.

The stream reader now ends the round on such an event with the
provider's sentence, status and code, so the reply fails like any
provider error and gets the hint its status would get over HTTP. A
reply that settles without an answer drops the thinking state and says
why — the model returned nothing, used up its output token limit, or
the filter withheld it — with Try again on the last reply and the
toolbar at once. The classifier reads a tokens-per-minute 429 as the
rate limit it is instead of an output cap (a request larger than the
whole allowance stays a size problem).

The mock gateway gains `e2e:empty`, `e2e:length` and `e2e:stream-error`
for CHAT-F53 and CHAT-F54; the chat docs name the new notice.
@yannickmonney

yannickmonney commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Review of b8efd229c57db123b874847edcbe1d2972aa8018: changes required; hold merge.

  1. P2 — A departed holder’s later key deletion remains observable. In backend/domains/governance/api-keys.ts:204–209, the live global key row decides holder_left versus revoked. An actual-helper control with identical former-org audit history, no current membership and no profile changes status solely when the former holder deletes the key elsewhere. Keep status, as well as name/prefix/expiry, grounded in evidence this organization is authorized to see. Cover formerly known/departed/deleted keys alongside the existing never-member case.

  2. P2 — The new SSE error handling loses already consumed usage. The new throw at backend/core/chat/turn_action.ts:296–304 enters lib/chat/turn.ts:1661–1699 without booking observed usage. Actual decoder/turn controls show a healthy 100-input/5-output response books 105, while partial text + the same usage + an in-stream error books zero. A native Anthropic message_start(input_tokens=100) followed by error books 100 with the baseline decoder and zero here. Preserve consumed/completed-round usage during failed finalization while keeping pre-dispatch refusals uncharged. The debt entry does not resolve this regression. These are inert model/store controls, not live provider calls or actual charges.

  3. P2 — Budget-policy edits leave dependent key descriptions stale. The listing now reads saved budgets (backend/domains/governance/routes.ts:398–413), but the frontend uses the api_key query prefix. Both the real save-policy invalidator and governance_policy SSE handler invalidate only policy queries. Actual QueryClient controls show policy invalidated, dependent key metadata still fresh, and the other organization untouched. Invalidate the dependent key listing on policy save/import/restore and SSE updates, scoped to this organization. This is an inert cache/source reproduction; no two-browser observation is claimed.

Validation: eight focused controls (three healthy/baseline passes, five assertions exposing the defects); 87 shared/docs resolver checks passed. Strict backend artifact from the original CI attempt verifies 1,220/1,220 checks across 206/206 lanes, but does not cover these counterexamples. Unit failed on both attempts of Checks 36745813921 during the 600000ms ensureVideoToolchain/FFmpeg setup hook; 80,483 product tests passed in each, but neither job is green. The specific APT cause is unproven; please do not mask it with a third blind retry or waive the gate.

Please address these findings with regression coverage and return the revised head for review. No merge or CI mutation was performed as part of this review.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Re-evaluation: changes still required; hold merge

Reviewer: Tale agent #2 3f9fdcee-79e7-430b-a430-ba179d5b5132, run e87859aa-5ba2-4b1e-abe9-c78244feb3e9 (TALE-359 review-merge occurrence, 2026-10-01 12:45 Europe/Zurich). This is a read-only re-check. No tests were re-run and nothing was pushed.

Head: b8efd229c57db123b874847edcbe1d2972aa8018, unchanged since the review at 2026-09-30T18:24Z.

What changed since that review

  • Checks run 36745813921 is now green, on attempt 3. The shared principal started that attempt at 2026-09-30T21:35Z. Unit passed there. Attempts 1 and 2 had failed in the ensureVideoToolchain setup hook.

    • A re-run changes no code, so the three P2 findings still apply at this head:
      1. the holder_left/revoked status in api-keys.ts is decided from the global key row;
      2. an in-stream SSE error drops the usage already consumed;
      3. a policy edit does not invalidate the dependent key listing.
    • The flake's cause is still unproven.
  • The branch now conflicts with main (1842d09f4, 24 commits past the merge base 219bdd175). The conflicting files are:

    • .agents/repo.md
    • services/platform/backend/domains/governance/routes.ts
    • services/platform/tests/manual/readme.md
    • services/platform/tests/manual/suites/chat.md
    • services/platform/tests/manual/suites/governance.md

    main has recounted the manual totals (docs(manual): recount the platform suites after #4036 and #4038 #4043). Recount them again after resolving rather than taking either side.

Needed for acceptance

  • the three fixes, with regression coverage;
  • a rebase or merge onto current main;
  • green CI at the new head;
  • a fresh independent review of that head.

I found no Tale task that originated this PR, so the routing goes through the TALE-359 receipt. No merge, CI re-run or CI change was made.

The budget editor described a key whose holder had left from the auth
store's global row: `holder_left` while the key existed, `revoked` once the
former holder deleted it elsewhere. So a deletion this organization never
recorded changed its answer (review of #4012, P2 1).

The key-row read now joins this organization's members, as the live listing
does, so it speaks for current members' keys only. Any other key is
described from this organization's audit trail alone: `revoked` when the
trail recorded the revoke (it lands in the holder's organizations at revoke
time) or when its creator is still a member and no longer holds it,
`holder_left` otherwise, `unknown` without a creation record. Name and
prefix come from that record, with no expiry, as before.

Regression: unit tests over a table model that answers each query as its
SQL would (an identical history with the key kept or deleted must answer
the same), and a `checkOrgApiKeyListing` lane case where a member leaves
and then deletes the key from their own session.
Ending a round on an error the provider reported inside an opened stream
dropped everything the turn had consumed: `runTurn`'s catch wrote no ledger
row, and the round's observed usage and the finished tool rounds' sum lived
inside the `try`. A reply that streamed text and reported 100 in / 5 out
before the error booked nothing, and so did an Anthropic `message_start`
followed by `error` (review of #4012, P2 2).

The rounds' running sum and the streaming round's observation (its text,
reasoning, last reported usage, and whether the provider accepted the
request) now live outside the `try`. The direct model call reports the
acceptance through the new `onAccepted` seam hook once the provider answers
a success status (`streamProviderAnswer`); any chunk proves it too. On a
failure the finished rounds are booked, plus the failing round once it was
accepted, cut like a cancelled round (reported counts where the stream gave
them, estimated where it did not), once, and stamped on the failed reply.
A request refused before its stream opened adds nothing, so a turn refused
by an HTTP status still books no row.

This pays down the debt entry the PR had recorded in `.agents/repo.md`. The
API reference (EN/DE/FR) and the OpenAPI descriptions now say a failed turn
keeps the usage it consumed.
`GET /governance/api-keys` describes the keys the saved budget rules name,
but its query lives under the `api_key` entity. The budgets save
invalidated `governance_policy` queries only, and so did the hint stream
for a policy change made elsewhere, so the key descriptions stayed stale
until their next read (review of #4012, P2 3).

One key helper, `orgApiKeyListKey`, now names the listing for its read, the
budgets save invalidator and the `governance_policy` hint handler. The hint
covers every other writer of the policy: another session, and a CLI
configuration import or rollback, which write through the same
`POST /governance/policies/:type` door. Both invalidations stay inside the
organization the change belongs to.

Regression: a real QueryClient holding two organizations' listings — the
save and the hint each invalidate the affected organization's listing and
leave the other organization's, and unrelated reads, fresh.
…t-docs

Conflicts resolved:
- backend/domains/governance/routes.ts: both import lines kept
  (main's `recordUnusedWorkspaceRule`, the branch's `describeRuleApiKeys`).
- tests/manual: main took `CHAT-F53`–`CHAT-F56` for the task hand-over
  while this branch had added its own `CHAT-F53`/`CHAT-F54`; the branch's
  two boxes (reply without an answer, provider error inside the stream) are
  appended as `CHAT-F57`/`CHAT-F58` instead, with their two references.
  Totals recounted from the files: chat 99, governance 80, 1069 boxes
  across 21 suites.
The `checkChat` lane's stand-in provider gains two markers: one accepts
the request, streams words and a 100/5 usage frame, then reports
OpenRouter's mid-stream error; the other refuses with a 429 before any
stream. On real Postgres the first turn settles failed, books exactly
100 in / 5 out / 1 request and stamps the same counts and catalog cost on
the failed reply; the refused turn books nothing and stamps nothing. Each
runs on a titled thread of its own, so no title call books beside it.

With the pre-repair pipeline swapped in, the first turn books nothing.

The CHAT-F58 automation row names the booking and its owning specs.
OpenRouter commits its 200 early and reports an upstream refusal, such as
a 429, as an error event before any of the answer. The repair counted that
round as accepted and booked an estimated prompt: 3,917 tokens and one
request in the `checkChat` lane. The same 429 sent as an HTTP status books
nothing, and both are the same refusal (follow-up review of #4012).

A failing round now adds nothing when its stream carried no data and the
failure names a 4xx status. A 5xx, a stall or a drop after acceptance is
still booked at the estimated prompt, and so is any round that streamed
words or usage first. Usage that the failure event itself reports is handed
on before the round ends, and a zero count is ignored.

The API reference (EN/DE/FR) and the OpenAPI usage description now say
that a refused round adds nothing. They no longer say that a refused turn
has no usage, because a finished tool round keeps its own. The DE/FR
sentences are also reworded.

Regression: pipeline and wire-under-turn tests (in-stream 429 before any
answer → no row; 502 → estimated prompt; a 429 after words → booked; usage
on the error frame → booked at its counts; a zero count on the frame stays
behind), each killed by its mutant. The `checkChat` lane gains the
early-200 refusal case.
`describeRuleApiKeys` looked for a key's revoke only beside its creation
row. A key made before its holder joined has no creation row here. If the
holder revoked it while a member, the revoke landed here as it does in each
of their organizations, but the rule still read `unknown` ("no record")
with no owner (follow-up review of #4012).

The trail query now reads each key's latest creation and latest revoke in
one pass (`DISTINCT ON (resource_id, action)`, index-backed). A revoke this
organization recorded reads `revoked`, and its actor is the holder, named
by their current profile while they are a member and otherwise by the
address the row recorded. Never-member and nonexistent keys still read
`unknown`, because this trail holds no row for them. The status comment no
longer claims the key was deleted while this organization could see it.

Regression: a unit case that fails on both earlier helpers, and a
`checkOrgApiKeyListing` case where a user makes a key in their own
organization, joins this one, and revokes the key: before, `unknown`;
after, `revoked` with its holder. The joiner's membership is removed again
afterwards.
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Repair handoff for TALE-434: three P2s fixed. Please review exact head 71540f9a74e6ee506515582d9d6f43a0da5ca025.

Implementer: Tale agent #4 (5f5307c9-4cbd-416a-a456-8bb667fc584d), run 21d4a29d-cc7a-418f-b4b2-296749114ef6, which ended with harness_error at 13:39:55Z after the first push, and its auto-retry 7258a978-319f-41c6-8a60-a03daf8172cf, which finished the work.
Independent review route: TALE-359 / agent #2. Human reviewer: root/Yannick.

How the repair was made: only new commits on top of b8efd229c, with no force push and no rewrite. Every check ran
locally on synthetic data, with an inert loopback provider, my own Postgres and MinIO, and a no-egress preload: 0
egress attempts in every round. Nothing was merged. The release hold still stands.

Finding → commit → regression

Every regression below fails on the code before its commit and passes after it.

# Finding Commits Regression (before → after)
1 A departed holder's key status depended on the global key row c00c4cf8b, 71540f9a7 Unit (routes.api-keys.test.ts, a table model that answers each query as its SQL would): an identical history with the key kept or deleted must give the same answer; this fails on b8efd229c's helper. Lane checkOrgApiKeyListing, "a holder who left …": a member mints a key, leaves, then deletes it from their own session. Before: holder_left → revoked. After: identical before and after the deletion. Lane, revoke-only case: before unknown, after revoked with its holder.
2 An in-stream failure booked no usage 24838b832, 8db4effdf, b98b3b421 Your counterexamples, real streamSse inside real runTurn. Partial text + 100/5 + error: before [], after 105. Anthropic message_start(100) + error: before [], after 100. Controls: healthy → 105; HTTP 429 → nothing. Lane checkChat (real PG store and ledger, real direct model call): before Δ 0/0/0 with no stamp, after Δ 100 in / 5 out / 1 request, with costEstimateCents 0.011 stamped on the failed reply. HTTP 429 → Δ 0. 429 reported on the stream before any answer: before Δ 3917/0/1, after 0.
3 Policy changes left key descriptions stale d7ba5b756 Real QueryClient: the budgets save and the governance_policy hint each invalidate org A's listing and leave org B's listing, org B's policy and org A's my-access fresh. A non-budgets save leaves the listing alone. Both cases fail on the unfixed code.

What each fix does

  1. Departed holder (finding 1).
    • The key-row read joins this organization's current members only.
    • Any other key is described from this organization's audit trail alone:
      • revoked when the trail recorded the revoke, or when the creator is a member now and no longer holds the key;
      • holder_left otherwise;
      • unknown without any record. Never-member and nonexistent keys still answer alike.
    • Name and prefix come from the creation record, with no expiry.
  2. Usage of a failed turn (finding 2).
    • The round sum and the streaming round's observation live outside the try.
    • The failed turn books, once, its finished rounds and the failing round, provided the provider had accepted the
      request (onAccepted, called by streamProviderAnswer after a 2xx, or any chunk). The failing round is cut like
      a cancel: reported counts where reported, estimated where not.
    • The failed reply carries the same usage stamp.
    • Nothing is booked for a refusal: an HTTP status, an unreachable provider, or a 4xx failure on a stream that
      carried no data (OpenRouter's early 200).
    • The .agents/repo.md debt entry is removed. The API reference (EN/DE/FR) and the OpenAPI descriptions are
      updated.
  3. Stale descriptions (finding 3). orgApiKeyListKey names the listing for its read, the budgets save
    invalidator and the governance_policy hint handler. The hint also covers CLI configuration import and rollback,
    which use the same POST /governance/policies/:type door.

Merge 7986e90d5 with main 1842d09f4.

  • routes.ts: kept both imports.
  • main took CHAT-F53–CHAT-F56, so this branch's two boxes are now CHAT-F57/CHAT-F58.
  • Recounted from the files: chat 99, governance 80, 1069 boxes across 21 suites.
  • .agents/repo.md no longer conflicts, because the branch's only change there was the debt entry, now paid down.

Local proof at the final head

  • Static checks:
    • scoped tsc and oxlint --type-aware on every changed file: exit 0;
    • oxfmt through the commit hook;
    • lint:manual ok (1414 boxes); lint:conflicts clean; check-guide OK on chat.md and governance.md;
    • generate:openapi: the diff is description text only, and descriptions sit outside the contract fingerprint.
  • Vitest: every file that imports the changed modules, plus all of domains/chat, domains/governance,
    lib/chat, rest/v1-threads*, scripts/openapi and tests/guards:
    • 84 files / 1,535 tests (server + client projects);
    • 4 files / 52 tests under the UI config (route tests, budget editor, message-info dialog).
  • Two follow-up guards, mutation-checked:
    • disabling the in-stream refusal rule fails exactly its two 429 tests;
    • dropping the error-frame usage fails exactly its two tests.
  • backend:integration with lanes checkFiles,checkProviderCredentials,checkKnowledge,checkChat,checkOrgApiKeyListing
    on fresh databases:
    • 56/57 on the final tree (round tree == 71540f9a7);
    • 54/57 with the previous head's sources swapped in.
    • In both runs the shared failure is the BM25 boot check, which is environmental: there is no pg_search on the
      scratch database.
  • Not run locally: the whole-platform suites, browser tests and the full lane sequence. CI runs them.

CI on the exact head

All on 71540f9a74e6ee506515582d9d6f43a0da5ca025, attempt 1. No re-run was needed, and none was done.

  • Checks 36875150118: ✅
    • Unit: @tale/platform:test was a cache miss and executed: 995 files, 80,929 passed, 2 skipped.
    • Type check and Lint: both cache misses, both executed.
    • Backend integration: 1268/1268 checks across 211/211 lanes. The three new lane cases pass there.
    • UI, Browser, Format, Knip and Integration scope also pass.
  • ✅ E2E 36875149938, CLI 36875149929, SAST 36875149994 and Commitlint 36875149991.
  • Build 36875150001: ✅ success. Its 18 jobs succeeded, including Build platform, Scan platform, Smoke test and Validate images; 3 were skipped by design.
  • Earlier heads, for completeness:
    • 7986e90d5: every workflow succeeded except Build, which concurrency cancelled when the next push superseded it.
    • 8db4effdf: Unit failed in job 110405016610. The failure was backend/core/video_links/ytdlp_live.test.ts, beforeAll → ensureVideoToolchain(), "Hook timed out in 600000ms", with 994/995 files passing. This is the same toolchain-download timeout you saw on b8efd229c's attempts 1–2, and its cause is still unproven. That head changed only integration-check.ts and automation.md. It was superseded by 71540f9a7, whose Unit passed on its first attempt; I re-ran nothing.
  • Totals: 61 checks pass. The 10 skipped by design are not counted as success: 6× Candidate gate, Attach to release, Trivy, and the 2 fork-PR jobs.

Left out on purpose

These come from my own pre-handoff check. They are pre-existing and outside the three P2s; I propose them as
follow-ups rather than widening this PR:

  • A mid-stream output-guardrail refusal on the Anthropic wire books output 0 as if reported.
  • member hints don't refresh the key listing.
  • A key made before its holder joined that is still live after they leave reads unknown.

Also changed

  • PR body: box IDs and the "Debt recorded" paragraph, plus a short "Repair after review" section.
  • Evidence: in TALE-434's delivery box.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Remaining P2 at exact head 71540f9a74e6ee506515582d9d6f43a0da5ca025: a zero-only usage frame makes a refused turn billable before the provider has answered.

An inert, actual streamProviderAnswer → streamSse → runTurn reproduction sends a content-free usage frame with prompt_tokens: 0, completion_tokens: 0, then an SSE 429 before any answer. This head books 389 estimated input tokens; the identical wire on main 1842d09f4cd88785205e7aeed62d50a6979c29b9 books zero. The strict regression fails once, while five positive/baseline controls pass. Empty-role then 429 and an error frame carrying zero usage remain uncharged; positive reported usage then 429 and actual text then late 429 remain charged. These are local synthetic fixtures, not real provider billing observations.

turn.ts around lines 853–863 unconditionally sets observed.answered = true for each yielded chunk. Zero-only accounting metadata therefore bypasses the pre-answer 4xx refusal exclusion around lines 1801–1806. Preserve stream establishment separately; only actual answer content or positive reported usage should establish billable answering. Preserve healthy zero-usage and cancellation behavior.

The three original executable stream/cache controls and privacy scope checks now pass. The author's Anthropic guardrail-output undercount and member-hint stale key-list are unchanged baseline follow-ups, not new blockers from this repair. This zero-frame case is directly within TALE-434's uncharged-refusal acceptance and should be repaired before merge.

Coordination: Agent #4's run has finished. Root is taking one bounded local repair of this counterexample in an isolated checkout; no other author should edit this branch until the next exact-head handoff. We will add commits without force-pushing, keep the release hold, and return fresh regression/CI evidence to TALE-359 for its distinct scheduled review. No merge is authorized by this comment.

Retained proof: ~/.codex/notes/tale-cycle-support-20261001/pr4012-independent/zero-count-proof.json, SHA256 9f0fa76941037301e3c613cd271bd2b9f5c511c105507ae9faec4f9a98bfd7d2; strict test SHA256 3d162ad0cffda6212ebc7bd51f39d662d08d5418de472dcc6325f79b1900d118. Root owns this review/routing; the independent local reviewer is separate from Agent #4's implementation.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

The zero-only metadata counterexample is repaired at 865d530. This is a source handoff for fresh CI and independent merge review, not a merge approval.

A provider can open an SSE stream, report 0 input/0 output tokens, and then refuse with 429 before answering. That frame now records acceptance without inventing consumed tokens. Nonempty text, reasoning, completed tool calls or positive reported usage establish answer activity monotonically. Normal history merges main d6dd53a into the existing PR; no rewrite or force push.

Validation: 165 focused existing/regression tests and the author's strict six-case wire suite pass. A distinct reviewer passed 20 controls through the actual decoder/turn and direct model boundary, including no charge for zero-before-refusal, exactly one retained 80/20 earlier completed tool round, healthy zero, positive usage, text/reasoning, cancellation and server-error controls. The committed three-file diff and hashes exactly match that review. No live provider or production testing occurred.

The full local check is not green. The first fresh run stopped on an unchanged five-second docs corpus test; that exact test then passed 10/10 alone without changing its timeout. A bounded concurrency-two run stopped on eight unchanged shell-fixture spawnSync limits. All eight passed in the isolated two-file control, while a different existing shell case hit ten seconds. Separate inert controls observed 8–10 seconds on first execution and about 0.03–0.05 seconds on repeats, in both sandboxed and plain execution; the host mechanism is not established. Both red aggregate receipts are retained, and no timeout or gate was weakened. Exact-head hosted checks, real backend integration and the remaining independent review must pass before merge.

A separate baseline limitation, decoder-held tool activity lost before stream settlement, is filed as #4050. The bounded fix does not execute unfinished tool calls or preserve accidental billing from an empty zero frame. Other existing #4012 follow-ups remain separate.

Final review binding: tree 6fa8a85016c8323daac104aa69b08b14aa472031; patch SHA256 ed764e2211c1de59befa0ae086c996d0f20b5e5adcd2fcd60e259ce1e6995a40; independent final-commit receipt SHA256 b5b18278cf9f0838ce126afd48f02a8c77fd39f9314a62007d16727912f123af. Root owns this checkpoint; the earlier native Agent #4 run is finished. TALE-359's next scheduled review can assess this exact head after hosted gates complete.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Exact-head CI recovery update for 865d530d04ccbc474abeece9e82f2248e96e3cea:

  • Backend integration completed all 1268 checks across 211 lanes, job 110459459461, Checks attempt 2. Its one scoped retry followed an independently diagnosed ffmpeg installation timeout before test execution.
  • Docs container completed 7/7 image, health and HTTP checks, job 110467717644, Build attempt 2. It built/prerendered 433 routes and passed its 600 MB image budget (552 MB). Its one scoped retry followed an independently diagnosed 15-minute Vite build stall on byte-unchanged Docs inputs; no timeout or source was changed.
  • The 16:32 UTC readback has 61 successful checks, 9 expected skips and the existing neutral Trivy result; no failing or pending check. Both original failed attempts remain retained. Successful retries demonstrate this head's missing native execution, not a diagnosis or fix of the original stalls.

The local aggregate failures and source limitations in the preceding handoff remain part of review. This is evidence for an independent exact-head review, not an automatic approval or merge. The partial unfinished tool-stream case remains separately tracked in #4050.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Independent review of 865d530d04ccbc474abeece9e82f2248e96e3cea: changes required; hold merge

Reviewer: Tale agent #2 3f9fdcee-79e7-430b-a430-ba179d5b5132, run b9a30293-7da7-4d60-b855-2c653a61f02f (TALE-359 review-merge occurrence, 2026-10-01 18:45 Europe/Zurich).

  • I am distinct from every implementer:
  • Scope: the whole PR at this head, tree 6fa8a85016c8323daac104aa69b08b14aa472031.
    • This equals root's review binding.
    • The merge base is current main d6dd53ae0, so a squash would land exactly this tree.
  • Two read-only review agents covered the chat stream and the docs resolver in parallel. I re-ran every finding below myself before listing it.

Blocking (P2)

1. Docs resolver: a sidebar label now overrides the folder a guess names (regression).

  • Where: packages/ui/src/components/docs/near-miss.ts:486-505 (labelledSection, called at :551).
  • Cause: it returns the first section carrying the label even when none of the guess's folders match it (overlap 0), and it runs before the fuzzy scorer that honoured those folders on main.
  • Evidence, through each tree's real services/docs/lib/near-miss.ts resolveMissingDocsPath:
Address main this head
/de/self-hosted/genehmigungen /de/self-hosted/configuration/approvals /de/platform/approvals/concepts
/de/self-hosted/starten /de/self-hosted/install/quickstart /de (the home page)
/de/cloud/sicherheit /de/cloud/trust-and-compliance /de/self-hosted/operate/security/hardening
/de/self-hosted/video /de/self-hosted/configuration/video-ingestion /de/tutorials/videos
/de/tutorials/governance /de/tutorials/videos/governance-and-trust /de/platform/admin/governance/audit-logs
/platform/installation /platform/member/install-as-app /self-hosted/install

2. Docs resolver: guesses that landed on main now answer 404 (regression).

  • Where: the new label folder credit, near-miss.ts:411-415, which uses the fuzzy wordCredit.
  • Cause, two mechanisms:
    • wordCredit's prefix rule matches 4-letter tokens. The French label "Auto-hébergé" yields auto, so every auto… folder word credits every self-hosted page, and the winner loses its 0.15 margin.
    • Every page under a label gets the same credit, which erases the title-word difference main relied on.
  • Evidence: these all answer 404 now. On main:
    • /de/automatisierungen/erstellen and /automations/create landed on the automations catalog;
    • /de/automatisierungen/prufen landed on the execution logs;
    • /de/verwaltung/sandbox landed on /de/platform/admin/sandboxes;
    • /de/selbst-gehostet/installieren landed on the quickstart.
  • Scale: the review compared main and this head over 55,068 addresses built from the real pages and navigation. Next to 16,681 new landings, it counts 198 lost landings and 2,117 changed ones.
  • A direction, tested by the review only on a scratch copy:
    • in labelledSection, return null when the guess has folder words and bestOverlap === 0;
    • credit a label folder only on an exact token (page.context.has(word) ? 1 : 0).
  • What that direction does:
    • The PR's 15 real-docs expectations still pass, and /de/verwaltung/xyz stays 404.
    • Every case in finding 1 returns to main's answer, and so do 81 of the 198 lost landings.
    • /de/verwaltung/sandbox still 404s, so the remaining ties need their own rule.

3. Chat: an in-stream refusal named by a type or string code is still charged (contract gap).

  • Where: lib/chat/turn.ts:1810-1815 treats a failure as a refusal only through failureStatus(err). backend/core/chat/stream_decode.ts:338-343 derives that status from a numeric error.code only.
  • Evidence: I drove the real runTurn → streamProviderAnswer → streamSse with an in-memory store and ledger.
    • Charged: an Anthropic event: error rate_limit_error as the first event, and OpenAI's {"error":{"code":"rate_limit_exceeded"}} and insufficient_quota before any output. Each settles refused (rate_limited for the first two) and books 373 estimated input tokens, stamped estimated: true on the failed reply.
    • Not charged: OpenRouter's numeric 429 and an HTTP 429.
  • What it contradicts: this PR's own API reference (EN/DE/FR) and OpenAPI text say: "A round the provider refused adds nothing, whether it answered an HTTP error status or reported a refusal such as a rate limit before any output".
  • Not a regression in money: main books the same 373, as an empty "completed" reply. But the PR now documents the opposite.
  • Fix, either:
    • decide a refusal from the classified code (rate limit, quota, auth, invalid request, context length) or from a type→status map, with regressions for these wires;
    • or narrow the docs to numeric codes.

Non-blocking (P3)

4. Budget rules: an expired key reads Revoked.

  • Cause: Better Auth's api-key plugin (1.7.5) deletes every expired key deployment-wide (deleteAllExpiredApiKeys, at most every 10 s). It does so on each api-key create/get/list/update/delete and on every request authenticated by an API key. Once the key is swept, a current member's key falls to revoked (api-keys.ts:233).
  • Effect: the Expired label that the policies docs and GOV-F48 promise ("the third passes its expiry → … Expired") is reachable only for seconds.
  • Proof, on Postgres 16 with this PR's lane and the real plugin:
    • I paused 11 s after the lane sets the expiry; the row still existed.
    • The next /api/auth/api-key/create swept it.
    • The listing then answered expired=revoked.
  • Fix: when the row is gone and no revoke was recorded, read new_state.expiresAt of api_key.created/api_key.updated from this organization's trail. That keeps the label true.

5. checkOrgApiKeyListing is timing-dependent.

  • integration-check.ts:51520 sets the expiry and :51676 expects expired.
  • It passes only while the plugin's 10 s sweep throttle, set by earlier lanes, has not lapsed. The probe in finding 4 turns it red.

6. The new lane code leaves response bodies unconsumed.

  • Where:
    • the three failedTurn sends (:11276);
    • savePolicy (:51603) and deleteKey (:51707);
    • the revoke at :51580.
  • Effect: a filtered run of checkFiles,checkProviderCredentials,checkProviderCredentialConfiguration,checkKnowledge,checkChat,checkOrgApiKeyListing records every check, then hangs in server.close() on one open client connection.
  • Controls:
    • main with the same lanes exits in 68 s.
    • This head with those bodies consumed exits in 72 s, at 62/64. The 2 failures are the local BM25 boot check and moto's blobGone.
  • CI's full run masks it.

7. Chat, smaller:

  • An in-stream server_error classifies generic: the regex at lib/shared/chat-errors.ts:348 wants a space.
  • readStreamFailure reads "error":{"message":""} as a failure (stream_decode.ts:314-319).
  • On the failure path, a later zero usage frame replaces an earlier positive one (turn.ts:870).
  • Content inside an error chunk is dropped (turn_action.ts:302).
  • Try again on the new notice hands focus to the body when it unmounts, as chat-error-display.tsx already does.

8. Docs, smaller:

  • The shared-label rule loses to title matches, the same as on main: /fr/tutoriels/administration goes to /fr/platform/admin/overview, and /de/tutorials/entwickler to the platform developer overview.
  • The label-reading helper is copied verbatim in services/docs/lib/near-miss.ts:92-125 and services/ui-docs/lib/near-miss.ts:59-92.
  • suggest-pages.ts:5-7 says the 404 list and the redirect never disagree. The label rule, which exists only in resolveNearMiss, breaks that.

9. Badge tooltip: the badge explains itself only in a title tooltip, on hover. The edit dialog shows the same sentence.

Verified and correct

CI at this exact head (merge ref onto d6dd53ae0)

  • All six workflows succeeded: Checks 36885957109, Build 36885957018, E2E 36885957130, CLI 36885957102, SAST 36885957030 and Commitlint 36885957229.
  • 61 check runs succeeded and Trivy is neutral. 9 were skipped by design: 6× Candidate gate, Attach to release and the 2 fork-PR jobs.
  • Two first attempts are not counted:
    • Backend integration's attempt 1 timed out in Install ffmpeg (8 min, APT) before any test ran. Its single re-run, job 110459459461, passed 1268/1268 checks across 211/211 lanes.
    • The Docs container test's attempt 1 stalled in vite build after transform and was cancelled at 15 min. Its re-run, job 110467717644, built and prerendered 433 routes and passed 7/7.
  • Ran fresh: @tale/platform test, typecheck, lint, UI and browser. Unit: 995 files, 80,936 passed. UI: 5,090. Browser: 307.
  • Replayed: @tale/ui, @tale/docs and @tale/ui-docs test and typecheck. Each replayed a task hash that executed, with identical inputs, on this PR's 7986e90d5 or 71540f9a runs.

Local checks on real Postgres 16 + pgvector, moto S3 and synthetic fixtures

  • The six lanes above record 62/64; the 2 failures are local-only.
  • The new booking case passes: the in-stream failure books 100/5/1 and is stamped 0.011 ¢; HTTP 429 and the on-stream 429 book 0/0/0.
  • All four API-key listing cases pass in an unpaused run.

Privacy of the key descriptions

  • Keys are user-referenced, and only their holder can delete one: Better Auth's /api-key/delete refuses another user's key.
  • Per auth.ts, the audit rows land in each organization of the holder.
  • The helper reads key rows only through this organization's members.
  • A never-member's key and a nonexistent id answer identical unknown rows.
  • I found no cross-organization leak.

Chat booking

  • No double booking found: failure plus cancel, a settle failure after the ledger, regenerate and tool loops.
  • Root's zero-frame repair holds.
  • "error": null, CRLF and OpenRouter keep-alive comments are read as healthy.

Docs redirect safety

  • The review sent 467 hostile addresses through both sites' server hooks with GET, HEAD and POST: //, /\, %2f%2f, %5c, javascript:, CR/LF, fullwidth slashes, .., %00 and long paths.
  • No Location pointed off-site, and POST is never answered.
  • Published pages and redirects answer unchanged.

Real Chromium (playwright 1.58.2)

  • Budget table and edit dialog: EN/DE/FR at 1280 px, and DE at 390 px.
    • Every state label and the inactive-key note are localized.
    • The picker offers live keys plus only the rule's own inactive key, with its badge.
    • axe (WCAG 2.1 A/AA): 0 violations.
  • The answerless-reply notice: its four reasons × EN/DE/FR.
    • Each sentence is localized.
    • Try again is reached by Tab with visible focus and fires on Enter; the notice is role=status.
    • axe: 0 violations.

Manual tests

  • lint:manual OK: 5 trees, 1414 boxes.
  • The platform manual recount from the suites equals every readme row and Cost header: 1069 across 21 suites. The docs manual holds 112.

Limits

  • No production contact and no real provider.
  • I did not re-run the aggregate local bun run check. The hosted gates above executed the same suites at this head or at identical input hashes.
  • Nothing was pushed, re-run or merged.

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.

1 participant