Repository navigation
inkstone 0.1.5: the window closes within about half a minute, refused keys are removed instead of dead-ending, and an unchanged body goes out byte-for-byte - #847
Conversation
|
Thanks, this is a real improvement to the sign-in, and the wiring tests on step ④ are good. I ran the inkstone tests (106/106), Blocking:
Non-blocking:
The 0.1.4 bump is right; dist has up to 0.1.3. I'd land #841's stricter test first and rebase this on it. |
…le probe backoff (#841) The fake GET /api/tokenplan/v1/keys in keys.test.mjs's serveKeys() now behaves like the live platform: no `uaa-token` cookie gives -10002, and any query parameter gives -15100. A new test covers the third listKeys call site, the 401 cleanup in ensureKey: the probe refuses the new key, and the test checks that the refused key is deleted by name (#839). probeWithRetry takes its delays as an optional third argument, and ensureKey passes `probeDelays` through to the probe of a key it just created. The default delays are unchanged, so nothing outside tests behaves differently. The new test passes [0] and doesn't wait through the ~15s backoff. Because lib/ changed, inkstone goes to 0.1.4. Run at the reviewed head c4ab471, merged onto main 7e01fa8, on mote (Bun 1.4.2) with a temp HOME: - packages/inkstone `bun test`: 102 pass / 0 fail - `bun scripts/check.mjs inkstone`: ok - repo-root `bun test` and the full `bun scripts/check.mjs`: CI run 42476974057 at this head, green. The mote run waited 23 minutes behind 10 queued suites on the machine's suite lock and was dequeued without running. Broken by hand, each red: - query back at keyCount's listKeys: 3 fail (blank-prompt create, ten-key limit, the new cleanup test) - query back at pruneKeys' listKeys: 2 fail (both pruning tests) - query back at the 401 cleanup listKeys: 1 fail (the new test; main's tests stayed green there) - listKeys on the bearer instead of the cookie: 7 fail - probeDelays not passed through: 1 fail (the new test runs past bun's 5s limit at 15.0s) #847 (also inkstone 0.1.4) merges cleanly on top, but it has to move to 0.1.5.
|
#841 landed first as e7af785 (inkstone 0.1.4). It changes This branch still merges cleanly on top ( |
…-community#840 - the wiring test's key-list step is driven through ensureKey with a fake that refuses a paginated /keys (B05: the query going back now turns it red), chatFetch parses the body once and carries no dead key or empty catch, the fake browser builds under a pid-suffixed temp name and sweeps its sibling hashes, the magpie-community#825 test covers the reuse method, the host-shape copy drops the status the host does not take, the soft-refusal retry checks the key list before it builds a second key, and off Windows the sign-in watches the profile's cookie store for the session so the window closes itself (magpie-community#840)
…with the real wiring and the sign-in progress tested
… keeps an unchanged body byte-for-byte and re-attaches a Request body (blocking 3, nits)
…wser tests are scoped to this tree, and the cookie-probe claim is asserted (blocking 5, nits)
…ake too, so every listKeys caller is covered (blocking 2)
a9f500f to
07e82ba
Compare
|
Rebased on main ( Blocking
Nits: Verification: 116/116 tests in four timezones, One environment note: the root |
There was a problem hiding this comment.
Thanks, this round closes most of it. I checked each earlier point against the diff at 07e82ba and ran it on macOS (mote, Bun 1.4.2), each run in a fresh HOME:
cd packages/inkstone && bun test: 116 pass, 0 fail.bun scripts/check.mjs inkstone: exit 0.- repo-root
bun test: 6685 pass, 22 fail. main f379bf9 gives 6700 pass, 21 fail; the extra red is inkstone's (blocking 1 below). The other 21 (Devin and unnamed) are the same on main. - Hand breaks: dropping the launch baseline (
[]forbaselineatlib/browser.mjs:650) turns "an old cookie in the kept profile" red.match = nullindeleteKeyByNameturns 4 key tests red. Putting{ query: { page: 1, page_size: 50 } }back on itslistKeysturns "the orphan-deleting listKeys" red. Each is held by a test now.
Done: blocking 1 (baseline, expiry, host_key), 2, 3 and 5, and every nit. I checked the 226 drop against magpie's shapeRefused (400 and 422 only). The probe copy is in the profile, and the sweep is scoped to this tree.
Blocking:
- The new Request test is red in the repo-root
bun test. The failing test is "the fetch wiring is the request path", atpackages/inkstone/api.test.mjs:331(loader.fetch(req)):TypeError: fetch() request with GET/HEAD method cannot have body. It passes alone.bun test packages/catpaw packages/inkstone/api.test.mjsshows the cause:packages/catpaw/index.test.mjs:37leaves a global fetch wrapper that callsrealFetch(url, init), which drops the Request's method. That leak is catpaw's (filed as #877, with a kiro leak that breaks the same test on main). ButchatFetchis what depends on it. Atindex.mjs:96it hands back{ ...init, body: text }with no method, and at:98it callsupstream(input, init)with a Request whose body has been read. Any fetch in between that readsinput.urlsends a GET. When you re-attach the body, passmethodandheadersfrom the Request too, for exampleupstream(input.url, { method: input.method, headers: input.headers, signal: input.signal, ...init, body: text }). Do the same when a rewritten body is attached to a Request. The test then passes after catpaw too. - Blocking 4 is only half covered. At
lib/browser.mjs:649I replacedloginWait?.cookieProbe ?? ((probeProfile) => profileHasNewCookie(...))withloginWait?.cookieProbe. That way macOS and Linux get no probe at all. All 116 tests stay green: the positive test atfake-browser.test.mjs:252injects its owncookieProbe, and the negative one only checks that "console" is not reached. The fake browser already writes a newuaa-tokenrow 300ms in. Drop the injected probe from the positive test (keepplatform: "linux",pollMs), so it ends on "console" through the real sqlite probe and the launch baseline.
Non-blocking:
lib/keys.mjs:233: when the last no-plaintext retry gets -15108 or the soft refusal, the loopcontinues and ends without deleting that attempt's key. The message at:241still says "the orphan keys were removed".deleteKeyByNamealso logs and returns when the list fails. Delete after the last attempt too, and only say "removed" when the delete ran.- -15108 from inside the -15109 retry loop (
:174) still goes out raw, with no orphan cleanup.
… its body, drive the production cookie probe with no injection, delete the last orphan and report removal truthfully, and clean up a -15108 inside the -15109 retry (third-round review)
|
Fixed both blocking points and the two non-blocking ones at Blocking 1. Blocking 2. The positive production-wiring test no longer injects a probe: it runs Non-blocking 1. Non-blocking 2. A -15108 arriving inside the -15109 retry now deletes the orphan and reports the clear Verification: 119/119 tests in four timezones, |
yetone
left a comment
There was a problem hiding this comment.
Thanks, both blocking points hold now. I checked every changed line since 07e82ba against the last review, on 1925a25 merged onto main bc5b833 (no conflicts, main hasn't touched inkstone, catpaw or scripts since your base), on macOS (mote, Bun 1.4.2), each run in a fresh HOME:
cd packages/inkstone && bun test: 119 pass, 0 fail.bun scripts/check.mjs inkstone: exit 0.bun test packages/catpaw packages/inkstone/api.test.mjs: 79 pass, 0 fail.- Hand breaks, each red on exactly the test named for it and green again when restored:
- dropping the
method/headers/signalforwarding and going back toupstream(input, init): "the fetch wiring is the request path" is red in the catpaw combination (78/1). cookieProbe: loginWait?.cookieProbewith no production probe: "off Windows the production wiring closes the window on a new cookie" is red.- removing the post-loop delete at
lib/keys.mjs:259: "deletes the LAST orphan too" is red. deleteKeyByNamereturning true when the list fails: "does not claim it was removed" is red.- removing the
plaintextLostbranch in the -15109 loop: "-15108 inside the -15109 retry" is red.
- dropping the
Blocking 1 and 2 are done, and so is the -15108-inside--15109 nit.
One thing still needs fixing. It's the "only say removed when the delete ran" point, which this commit says is fixed:
removedgoes stale, and the last orphan is kept while the message says it was removed.lib/keys.mjs:187setsremovedonce for the whole function.:204,:230and:251set it only on aplaintextLostattempt. Then:259skips the final delete whenever an earlier attempt left ittrue. Here is a sequence that does that: the first POST succeeds with no plaintext. In the loop, attempt 0 deletes it, and the next POST gets -15108, so:251deletes that one too and setsremoved = true. Attempt 1's POST succeeds with no plaintext again. The loop ends withcreated === "",:259seesremovedand doesn't delete, and the user gets "the orphan key was removed". I ran exactly that against the fake on mote: 3 POSTs, keyk3is still on the account, and the error says "the orphan key was removed". The same thing happens whenremovedwas set in the -15109 or soft-retry branch and a later create succeeds without a plaintext. Fix: at:259, delete the currentnameevery time unless the last attempt was theplaintextLostone that already deleted it. For example, resetremoved = falseright after each successfulcreateKeyin the loop (and set it per attempt, not once per function). Then add the test above: -15108 in the middle, no-plaintext success last, and expect 0 keys left.
Non-blocking:
- Swapping only
upstream(isRequest ? input.url : input, init)back toupstream(input, init)(keeping the init forwarding) leaves every test green, catpaw combination included. That's harmless today, because Bun letsinit.bodyreplace the spent stream. Just know that nothing tests that half.
I didn't run the repo-root suite this round: mote's load was ~960, and the PR touches only packages/inkstone. I'll run it at the next head before merging.
inkstone 0.1.5: the window closes within about half a minute, refused keys are removed instead of dead-ending, and an unchanged body goes out byte-for-byte
Closes #839. Closes #840.
Follow-up to #832 (0.1.3), rebased on #841 (0.1.4), covering the second review
round on this PR.
Blocking
keep_sign_inkeeps theprevious
uaa-tokenrow, so "a row exists" is not "this sign-in finished".The probe now records the rows present at launch (
creation_utc/last_update_utc) and accepts only a row that is new or whoselast_update_utcmoved; it also filtersexpires_utc > nowand limitshost_keyto the console's domain. The database is copied into the 0700profile folder for the query, not into the system temp folder.
serveKeys()fake. inkstone: strict fake /keys, refused-key cleanup test, injectable probe backoff #841 landed the strict fakefirst, as asked; this PR rebases on it. The fake now also serves DELETE,
and a new test drives the orphan-deleting
listKeysthrough it, so everylistKeyscaller is held to the fake.orphan is deleted by name and the create retried with a fresh name
(-15108 and the -15100 soft refusal are handled the same way); the
"create one in the console and paste it instead" wording is gone.
softRetryDelaysis injectable, mirroring inkstone: strict fake /keys, refused-key cleanup test, injectable probe backoff #841'sprobeDelays.cookieProbethrough
signInWithBrowser(removing the wiring turns it red); anotherruns the real sqlite probe against a kept profile that still carries the
previous sign-in's row (dropping the launch baseline turns it red).
window closes "within about half a minute" after the console session
lands (Chrome writes cookies to disk on a timer), not straight away.
Non-blocking
rewriteBodyreturns an unchanged body byte-for-byte again (an internalmarker records whether anything was rewritten); a test pins it.
chatFetch, aRequestwhose body is not JSON is re-attached after itis read, so the upstream call never carries a spent body; tested through
the loader fetch.
cleanDetailJWT test input is back to main's.a concurrent run of another checkout is neither renamed away nor swept.
promise for every model.
titleOfcalls and asserts 0off Windows.
Version
0.1.4 → 0.1.5 (rebased on #841, which published 0.1.4).
What was run
bun test packages/inkstone: 116 pass / 0 fail (627 expects) inAsia/Shanghai, UTC, America/Los_Angeles and Pacific/Kiritimati.
bun scripts/check.mjs: exit 0 (all packages).cookieProbewiring removed (B4), orphan deletion off (B3), the -15108dead end restored, the pagination query restored at every
listKeyscallsite and separately at the orphan-deleting call site (B05/B2),
rewriteBodyreserializing an unchanged body (N1), the
Requestbody not re-attached(N2), and the title read on darwin (N7).