Added#
DELETE /api/accountcloses an account, which nothing could do. The accounts that arrived in 1.7.0 could be signed out of and never closed: there was nodeleteUserin the store interface, in either driver, or anywhere else. The only way out of this product was to stop using it.It takes the account row and, with it, every session, every prompt, every version of each, and every
/c/<token>link the account published. Postgres does that with the fouron delete cascadeclauses the schema already carried; the memory driver walks the same graph by hand.Immediate, with no grace period. A screen that says deleted should mean deleted, and a
deleted_atcolumn would have meant touching every read, a second reaper, and an account that both exists and does not.The confirmation is checked on the server. The browser asks for the login to be typed, and a browser is bypassed by anyone with a terminal, so the same string is compared against the session the request resolved. Whose account is never a parameter: the worst any caller can do is delete themselves, asserted against four spellings of a target plus a query string.
Published share links stop working, and that is the answer rather than an oversight. Keeping them would mean keeping the deleted person's prompt text and their denormalised
owner_loginintrazum_shares.One plant refused to fire twice, and both times the test was what was wrong. Removing
versions.delete(id)leaves version rows orphaned in a map no public call can reach, and all seven tests through the route stayed green, because every route reaches a version through its prompt and the prompt is gone. Adding a count did not fix it: the count summed what each iteration was about to delete, so it reported three removed with the delete taken out. It measures the map before and after now, and the plant fails withthe versions were left behind, unreachable and undeleted. The guard for it runs againstpromptTablesInMemoryrather than through theStore, because that is the level the bug lives at.An existing guard caught this before CI did.
every route the web app serves is named in the roadmapfailed on/api/account, soROADMAP.mdgains anUnreleasedsection on the same termsCHANGELOG.mdhas one.Left alone deliberately:
trazum_prompt_versions.author_idreferencestrazum_userswith neither cascade norset null. It cannot bite today, because prompts are private soauthor_idalways equals the owner and the cascade fromtrazum_promptsreaches those rows first. The day collaboration exists, deleting an account will fail on a foreign key. Migrating the schema for a feature that does not exist would be inventing a requirement.Expired sessions are swept, and nothing was sweeping them.
findSessiondeletes the row it was handed on its way out, which covers a session somebody comes back and presents. It does not cover the ones nobody ever comes back for, and those are the majority: a browser that cleared its cookies, a laptop that was replaced, anyone who signed in from somewhere once. Those rows sat intrazum_sessionsfor ever and nothing about the deployment looked wrong while they piled up.This is unbounded growth, not a way in, and the test says so.
findSessionexcludes anything pastexpires_at, so a dead row cannot authenticate anybody. The assertion is therefore about how many rows are left rather than about what a lookup answers, which is the honest shape for a fix whose whole subject is a table that only grows.On sign-in rather than on a timer, for the reason
rate-limit.tsalready gives for sweeping on use: this deploys to a platform with no long-lived process to hang an interval on, and a route that stops being called should stop doing work. Signing in is the event that grows this table, so it is the right event to shrink it by, and after the first sweep the delete matches nothing and costs an index probe. Awaited rather than fired and forgotten, and wrapped in acatch, because a floating promise on a serverless function is one the runtime may kill mid-delete and a failed sweep must never cost somebody their sign-in.No migration:
trazum_sessions_expires_at_idxwas added with the table indb/001_accounts.sqland is exactly the index this delete wants.Two plants, two failures: removing the sweep fails with
expired sessions survived a sign-in and were left to accumulate, and a sweep that ignoresexpires_atfails withthe sweep took a session that had not expired, which is the half that would turn this from a fix into an outage.POST /api/auth/signout?all=1ends every session the account has, and the account menu offers it.deleteSessionsForUserexisted in the store interface and in both drivers, with no caller anywhere. The only revocation available was for the session doing the asking, so somebody whose laptop was stolen could sign out on their phone and the stolen cookie stayed valid for the rest of its thirty days, with nothing they could do about it.Opt-in rather than the default. The common sign-out is one person leaving one shared machine, and taking their phone with them would be a surprise nobody asked for. The narrow sign-out is unchanged and stays first in the menu; the wide one sits below it and its label says what it ends, this device included.
The authorisation is an absence. There is no parameter naming whose sessions to end: the user is resolved from the caller's own cookie, so the worst any caller can do is sign themselves out. The response is the same 204 with the same empty body whether one session went or twenty and whether the caller held a live cookie at all, because a count answers a question nobody holding a valid cookie needs and every holder of a stolen one would like.
One of the three plants did not fire, and the test was the thing that was wrong. The isolation test signed in as two people and checked that revoking one left the other alone, which a route that grew a
?user=parameter passes just as happily as a route that never had one: planting it left every assertion green. It attempts the attack now, in four spellings a future handler could plausibly read plus a JSON body, and fails withone account revoked another account's sessions through ?all=1&user=….The other two: reverting to
deleteSessionalone fails the wide sign-out, and makingallunconditional failssigning out of one device signed the account out of all of them.A UI guard broke on the change and was rewritten rather than relaxed.
ui.test.mjsproved the sign-out uses POST by quoting the source text'/api/auth/signout', { method: 'POST' }, which stopped matching when the path became a template literal. Quoting a spelling is not proving a property: that guard would also have gone on passing if somebody had added a second sign-out call on GET beside the first. It now walks every occurrence of the path in the component and requires POST at each, and separately requires the wide sign-out to exist. Both halves were planted:GETfails witha sign-out call does not say POST, so an image tag could forge it, and dropping?all=1fails withthe account control cannot revoke every device.The ten-minute window on an OAuth state is checked here now, not asked of the browser.
OAUTH_STATE_TTL_SECONDSexisted and was applied in exactly one place: the state cookie'smaxAge. That is a request a browser is free to ignore and a non-browser never sees. Meanwhile the callback's own comment described "a real one that sat in a tab past the ten-minute window" as one of the two cases it handled, and nothing measured it. The state carries an issue time now, andstateMatchesreads it.What that binds, and what it does not. It binds a browser, which is the case the window was written for: a callback URL left in an open tab, in history, or in a proxy log stops working ten minutes after it was issued rather than whenever the browser gets round to dropping the cookie. It does not bind a client that writes its own cookie, and the timestamp is deliberately not signed to make it so, because there is nothing there to gain: anyone who can set this cookie can equally ask for a fresh one, so a forged issue time buys an attacker a state they could have had for free. Saying that is the point; an HMAC would have looked like it closed something.
Both ends of the window. Past the TTL is the case the ten minutes are about. Issued in the future is a clock that disagrees with ours, and a negative age is not a small one: read as a number it sits inside every window there is, for as long as the skew lasts. So it is refused rather than granted an unbounded one.
The old two-part value is refused, not accepted. A browser can be holding one across a deploy, and the cost of refusing is a 400 saying start again and one more click, inside a ten-minute window. Accepting it would give the guard a shape that switches itself off for anything resembling the format it replaced, which is the kind of guard that outlives its own reason.
One test that quoted the cookie's layout by hand now reads it through
unpackState, so it fails on the destination it is about rather than on a format change.Three plants, three failures: deleting the window check, keeping only its upper bound, and accepting the two-part format.
GET /api/auth/sessionis rate limited, and it was the only auth route that was not. Every call below the disabled branch is an indexed lookup by token hash, made for an unauthenticated caller, keyed on a cookie that caller chose.lib/auth/routes.tshas exported a limiter for the sign-in hops since they were written; this route imported the file for nothing else and never asked for one. The gap was an omission, not a decision.Its own budget, not the sign-in one, and that is the part worth a guard. The header asks this endpoint before it can draw anything, so a person clicking around calls it far more often than they sign in. One shared bucket means ordinary browsing spends what the sign-in hops need and refuses somebody at the moment they press the button. Reusing
authRateLimitedfails withreading the session locked this address out of signing in, which is the regression a future reader is most likely to make while tidying.Sixty a minute, the same as
/api/writeand for the same reason: the limiter keys on an address rather than a person, so the budget has to be an office's. That is a policy matched to an existing precedent in this repository, not a measurement, and the comment says so rather than dressing it up. What it does not bound is a distributed attacker, whichrate-limit.tsalready states in its own terms; guessing a token is not among the risks, since they are 256 bits.The refusal sits after the disabled branch, not before it. That branch exists so an operator whose sign-in never appeared can curl this endpoint and read why, and it touches no store; rationing it would ration the one answer somebody debugging a deployment needs. Moving the limiter above it fails on call 61 of a test with its own address, which is the only way that failure names the ordering rather than a budget two tests above already spent.
Three plants, three failures: deleting the limiter, sharing the sign-in bucket, and moving it above the disabled branch. The 429 carries
cache-control: private, no-storelike every other branch of this route.The English catalogues lost their em-dashes, and the guard covers them now. 341 in
packages/cli/src/i18n/en.ts(30 of them written as\u2014), 17 inpackages/core/src/i18n/en.ts, 1 inapps/web/lib/i18n/en.ts. Three of them were not punctuation at all but table cells, and they became words the way the Spanish sweep did:none,other,no verdict.This reverses a decision the guard itself argued for, and the comment now says why rather than being quietly deleted. The old argument was that the em-dash is ordinary English punctuation and the product's whole English voice rests on it, so sweeping one file and not the rest reads as two writers. That holds for prose somebody opens on purpose and does not hold for the line that appears in their terminal unasked. The README,
docs/and this file keep theirs, deliberately: the line is what a user reads on screen versus what a reader opens.What the mechanical pass got wrong, and how it was found. A comma was right 249 times and a colon 99, chosen by reading the clause after the dash, and then every changed line was read back. Three kinds of damage turned up that no rule would have avoided: a dash ending a wrapped help line became a comma at the start of the next one; the config help table used the dash as a column separator, so a comma read as part of the value (that table is a colon against the value now, the same shape the Spanish sweep gave it); and one regex reached inside a JSON literal in that table and moved a comma belonging to the data, which is why the block was restored and rewritten by hand.
An existing guard caught the sharpest one.
markdown.test.jsforbidsscore:,grade:,rating:in the report, because a report that looks like it scores you is a report that invented one. The sweep turned "There is no score — every column is a measurement" into "There is no score: every column…", and the guard failed on a copy change nobody would have connected to it. The sentence is two sentences now.Twenty-four test assertions quote this copy and were realigned to it, and 75 more were reverted after an over-eager pass touched assertions whose strings live in
packages/core/src/*.tsrather than in a catalogue and were never swept.Three plants, three failures: a literal em-dash in the CLI's English catalogue, an escaped one in core's, and the guard being narrowed back to Spanish, which fails on finding three catalogues where it expects six.
trazum from-claude-code --state <file>reads only what is new. A transcript is append-only and can be enormous, so anything converting it on a loop spends its time re-reading bytes that cannot have changed. On the largest real transcript on one machine, 212 MB, the conversion drops from 2.6s to 0.19s, and the records appended are byte for byte what a full read would have produced. The status line'sStophook uses it, so its per-turn cost on that session goes from 2.7s to 0.72s.The resume point is not the end of the file, and that is the whole design. One call is written as several lines and the last one stands, so a run that stopped at the end would record the call that was still streaming from its first line and never see the lines that finished it. The bill would be short by whatever that call grew by, on every pass, with nothing looking wrong. So the resume point is the first line of the last call, that call is re-derived every time, and the output is truncated back to the settled records before the new ones are appended.
Contiguity was measured rather than assumed: across 208 real transcripts and 36,468 lines carrying a
requestId, no request ever reappeared after another had begun. The design does not lean on that; it re-derives the final call whether or not it needed re-deriving, because a measurement on one machine is evidence and not a guarantee.Three refusals, each because the exact answer is not available otherwise: it needs
--out(nothing to truncate when the records go to stdout), it takes one transcript rather than a folder (several transcripts appending to one output have no single settled length), and it re-reads from the top when the bytes before the resume point do not match what it left, so a rotated or replaced transcript is never resumed into. A missing or corrupt state file is a cold start, not an error: it is a cache.Five plants, and three of them found holes in the tests rather than in the code. Deleting the digest passed, because the replacement transcript was shorter and the length check alone refused it. Deleting the output truncation passed, because every append in the suite made the tail longer. Deleting the partial-line cap passed, because the half-written line was planted after a real call, where the cap changes nothing. All three tests were rewritten until the deletion they name is the reason they fail.
A Claude Code status line that costs nothing.
plugin/statusline/trazum-statusline.shshows what the session has cost at the bottom of the terminal:Sonnet $0.7761 · 10 calls · cache 88% · saved $2.91None of it is tokens. Claude Code draws the status line's stdout in the terminal and writes a
Stophook's stdout to the debug log, so neither is context.SessionStartis the hook whose stdout the model does see, which is why the refresh is not wired to it and why a test refuses it by name in both the script and the README somebody copies from.The split between the two is the design. Claude Code runs the status line on every assistant message and cancels the script if another update arrives while it is still running, so a status line that reads the whole transcript does not show a stale number, it shows nothing. Measured on 208 real transcripts on one machine: median 0.50s, largest 6.5s on a 212 MB session. With the work in the hook, the status line returns in 0.08s on that same 212 MB session, and the hook pays the cost once per turn, after the turn.
Without the hook it still works, and shows the figure Claude Code computes itself labelled
(Claude Code)rather than passing somebody else's estimate off as Trazum's.Five plants, five failures: moving the computation back into the status line is caught by a
trazumthat writes a marker and fails, dropping the attribution is caught, writing the cache in place rather than renaming it into place is caught, and namingSessionStartin either the script or the README is caught both when it replacesStopand when it is added beside it.The MCP registry listing is published by the release workflow. A new
mcp-registryjob inrelease.ymlwaits for npm to serve the new@trazum/mcp, authenticates with GitHub OIDC, publishespackages/mcp/server.json, and then asks the registry what it serves and fails if it is not the version just sent. It was the last manual step in a release, and it failed on both of its two manual runs.scripts/mcp-registry-preflight.mjs. The registry verifies a listing by readingmcpNameoff the package on npm, and npm serves a new version minutes after the publish returns, so chaining the two publishes produces a 400 that reads like a manifest bug and is a propagation race. This asks npm for the exact version until it answers 200 and serves the rightmcpName, for up to five minutes. A fixed sleep would be too short on a slow day and too long on every other one.It also re-checks the
server.json/mcpNameagreement at the point of use, which is not redundant withpublish.test.js: that runs against the commit, this runs against the checkout a release job is about to publish from, and a hand-pushed tag can skip the first.Proved by planting all three failures: a version npm does not have times out with the 404 quoted, a name mismatch fails before any request, and the real version passes on the first ask.
The gateway forwards two paths that spend nothing, without judging them.
POST /v1/messages/count_tokensandGET /v1/modelson Anthropic. Until now the rule was one path per provider, and a coding agent pointed at this gateway got a 404 within its first second from a proxy that was otherwise working.Refusing them was never the stricter answer.
count_tokensis the call you make to find out whether you can afford the other one, so answering it with a 402 blinds a caller at the exact moment they are trying to behave. A budget refusal only means something when there is money on the line; on a free call it is theatre with a real cost.What it widens is stated in
docs/gateway.mdrather than glossed: the origin is still compiled in, so the credential still reaches one host, and what grows is the set of operations somebody who can reach the loopback port may perform with it, from one to three. So the list is literal strings rather than patterns, the method is part of the match, and the comparison is against the whole path.The free branch reaches no decision, records no usage and never substitutes a model, because there is no money to judge, no counts to keep and nothing to swap. Any of those would be a figure invented about a call that cost nothing.
Two security guards were strengthened rather than relaxed. Adding a destination for somebody's credential already meant editing an allowlist in
security.test.js; adding a path forwarded without a budget decision now means the same, method included. And the fetch-target guard pinned a single-element array, which is the wrong thing to hold: it fails on a second call site that is correct and passes on a first that is not. It asserts the set of distinct targets now.Eight refusals are planted and pass:
/v1/messages/batches(bills, and reads as administrative),/v1/models/../messages,/v1/models?limit=1,/v1/modelsX,/v1/model, both right paths on the wrong method, and a method nothing answers. Four design failures are planted too, and all four fail: the free branch moved after the budget decision, astartsWithcomparison, a billing path added to the free list, and the free branch recording usage.Proved live as well as in tests: against the real
api.anthropic.com, the spending path returns 402 whilecount_tokensand/v1/modelsreturn Anthropic's own 401 for a fake key, on the same gateway, configuredfail-closedwith no budget.
Fixed#
The web app never lends its own LLM key.
POST /api/optimizereadTRAZUM_LLM_API_KEY, thenANTHROPIC_API_KEY, and fell through toproviderFromEnv()when a request carried no key of its own. On a deployment with either variable set, any stranger who posted{"suggest": true}spent the operator's money: no account, no session, nothing to attribute it to, and a rate limiter in front of it keyed on a header the caller controls.It is not armed on the live deployment.
https://trazum.vercel.app/api/optimizeanswered"llmConfiguredOnServer": falsewhile this was being written, so no key was configured and nothing was ever spent. It was a trap set rather than a leak open, and it would have armed itself the day somebody set that variable.The bug is a function used outside the world it was written for.
providerFromEnv's own comment says it is "trusted because it came from the environment: the operator configuring their own machine, not a stranger naming a host for this server to fetch". That is exactly right for the CLI, where the operator and the caller are the same person. In a web app they are not, and reusing it there turned "my key on my machine" into "my key for anyone with the URL".The endpoint and the model may still come from the operator, and the key may not. Collapsing those two kinds of setting is what caused this:
TRAZUM_LLM_BASE_URLis the documented Ollama-on-localhost case and costs an operator nothing when a stranger uses it, because the stranger still brings the credential that pays.allowInsecureis scoped to the operator's own host for the same reason.GET /api/optimizestops answering whether there is a key worth attacking. It returnedllmConfiguredOnServer, unauthenticated and unlimited, which is an oracle. The field is gone rather than set tofalse, because the question no longer has meaning once the server never lends a key, and the placeholder in the key field says it without a round trip. The route also gains the rate limiter that was onPOSTonly: the one endpoint that answered without a body was the one nothing bounded.Two plants, both firing. Restoring the environment fallback fails with
a keyless request was servedanda keyless refining request was served. Closing onlysuggestand leavingllm.enabledopen fails with the second alone, which is how this kind of fix is usually half-made. The suite keepsTRAZUM_LLM_API_KEYset so the tests run against the configuration that used to be dangerous rather than a tidy one where the question cannot arise.Half of this file was a second copy of itself. 100 of its 116 version headings appeared twice, 11,336 lines of duplicate history, concatenated in #411 and unnoticed for sixty-nine releases. The two copies differed by exactly one entry, present in the first and missing from the second, so the first contained the second whole and the second was deleted after proving that line by line: every version heading still present, every entry still present, none duplicated.
A section marked
Unreleasedsat below## 1.80.0holding work that shipped in 1.80.0.packages/mcp/server.jsonexists at thev1.80.0tag andaction.ymlcarries the corrected description there, so the file was telling a reader "not released yet" about something they could already install. Both entries are folded into 1.80.0 where they belong. This is the one that mattered: the changelog is what somebody reads before depending on this, and it was wrong in the direction that undersells what they get.Two more
## Unreleasedheadings and two# Changelogtitles. Two pull requests each opened their own Unreleased instead of adding to the one there, and the duplicated title came in with the duplicated history. One of each now.A guard, so none of the four can come back.
publish.test.jsasserts one title, oneUnreleased,Unreleasedas the first section, and versions in descending order. Nothing was looking at this file's structure before, only at whether a given version had a heading somewhere in it, which all four defects satisfied. Four plants, four failures, and the ordering assertion is the one that found the duplicate history in the first place.
Security#
The publisher binary is pinned by version and checksum. The upstream guide installs it from
releases/latest/download, a movable ref, into a job holdingid-token: writefor a namespace-wide grant. It is pinned to a version and verified against the checksum published for that tag, the same rule every action in this repository already follows.The listing runs in its own job, outside
environment: release. That job downloads a third-party binary and runs it, so it must never share a process withsecrets.NPM_TOKENor withcontents: write. It runs after npm and the GitHub release are done, so the worst it can do is fail, and a failed listing is recoverable by hand while a bad publish is not.security.test.jsholds all of it: the job exists, it is gated on the same decision the uploads are, it waits before it publishes, the binary is pinned and verified, and it is not in the release environment. Seven plants, seven failures, and one of them found a hole in the guard itself: the ordering assertion usedindexOfalone, and-1is less than every real index, so it passed loudest exactly when the step it ordered had been deleted. Presence is asserted before order now.The npm URL is encoded, not patched.
scripts/mcp-registry-preflight.mjsfirst built it with.replace('/', '%2f'), which CodeQL flagged as incomplete escaping and was right to: a string pattern replaces the first occurrence only, so that line was correct for@scope/nameby luck of the shape rather than by construction.encodeURIComponentnow. Both spellings answer 200 from npm; only one of them is an encoder.
Changed#
docs/releasing.mddocuments the job, the three choices behind it, and keeps the manual route as the fallback, now with the 401 (an expired device-flow token) alongside the 400 and the 403.