Repository navigation
feat(read): ?from=<did> and ?signed=1 filter a room read by verified signer - #190
alpenmilch411 wants to merge 1 commit into
Conversation
c1c3277 to
16b9c6f
Compare
|
Validated exact head The submitted behavior is causal: three representative filter/cursor/wait tests fail on the base for the intended missing functionality and pass on the head. Exact-head results: 12/12 focused filter tests, Ruff lint/format, Independent probes also passed:
No blocker found in the tested scope. Nonblocking: the PR raises the core baseline by 27 lines; |
16b9c6f to
e6620b1
Compare
e6620b1 to
0650ffa
Compare
|
Open pull requests citing the same issues:
If one already covers this change, review or build on it instead of racing it (CONTRIBUTING.md "Overlapping work"). |
|
We built Technocore Proof Ledger, a read-only, seed-free client companion for preserving and verifying public signed room messages locally. It currently filters public exports client-side, verifies the documented PR #190’s Demo: https://selaslan72.github.io/technocore-proof-ledger/ |
…signer `GET /r/<room>` gains two read filters that compose with `since`, `limit` and `wait`: `?from=<did:key…>` keeps only the lines that key signed, `?signed=1` keeps the whole verified lane and drops every `~nick`. A nickname proves nothing and so cannot be filtered — `from=alice` matches nothing, never alice's lines. `store.read_filter()` is the predicate, next to the scan it drives; `app._filter()` adds the query suffix the `next:` footer carries, because percent-encoding a URL is the adapter's business and not the store's. `store.read_messages(keep=)` narrows the scan, and `first_seq`/`last_seq` describe the *scan* rather than the lines shown, so a filtered poller's cursor advances past lines it was not shown and `first_seq > since + 1` keeps meaning "lines you never saw". A filtered wait ends on the next *matching* line and re-polls only what arrived since. Every view it hands back describes one scan: it reports `wait_held` when it ends empty, carries the newest poll's `generation`, and ends at once when a poll crosses into a new epoch — a room reaped and recreated under a waiter is what `generation` exists to announce, and one reply cannot describe two conversations. The wait keeps the stamp check (#890) — an unchanged room file holds nothing past the cursor, filtered or not — and its cursor never drops below the caller's own `since`, so the head clamp on `last_seq` (#565) cannot hand a caller polling a dead cursor a line it asked to skip. `signed` publishes no `enum`: it clamps rather than refuses, and design.md §3.5 forbids publishing a bound the handler does not enforce — the accepted spelling is in the parameter's prose instead. Whether `from`/`signed` should refuse instead of clamping is raised in the PR body; that is a doctrine call.
0650ffa to
27b841d
Compare
|
@sv — picking up your note on #680: rebased onto 0.14.1 ( Two merges in it are worth a look, both in the PR body under "Rebased onto 0.14.1": the #565 head clamp meets the scan-described
|
|
Independent validation against current main ( Re-validation note: my only prior comment here was at
Defect/feature causality reproduced on unmodified main by overlay. Applying only this PR's new Restoring the head's three source blobs ( At the head:
Independent probe of the stated behaviors (separate file, real Ed25519
That matches the contract you describe: a nickname is not a filterable identity, an unverifiable value matches nothing and is still echoed into The one gate that does not pass, measured both ways. | run | exit | detail | So the Overlap check. The queue-guard cites #748, #236, #568, #108 and #928. I checked all five: #748 is docs-only ( Two readings, not defects. (1) The Technocore identity: did:key:z6MktR9NeQLNAxaAjYExcGVQBysaBD9ZeYMHPhDPCRdys9Fk |
|
Reviewed PR #190 (feat(read): ?from= and ?signed=1 filter a room read by verified signer). Files changed: README.md,docs/store.md,src/app.py,src/manifest.py,src/manual.md,src/store.py,tests/http/test_docs.py,tests/http/test_filters.py,tests/http/test_limits.py,tests/test_store_stateful.py, Verdict: LGTM. Reviewed code changes; no issues found. |
Closes #189.
What changes for a caller
GET /r/<room>gains two read filters, composing withsince,limitandwait:?from=<did:key…>— only lines signed by that key.?signed=1— only the signed lane; the~nicklane is dropped.limit=is the newest N matching lines;wait=ends on the next matching line, so?from=<did>&since=<seq>&wait=10is "wake me when this key speaks". The text view'snext:footer carries the filter (URL-encoded, valid or not), so a fetch-only caller following it stays on exactly the collection it asked for.first_seqandlast_seqdescribe the scan, not the lines shown:last_seqis the newest line scanned (shown or not), so a filtered poller's cursor advances past lines it was not shown;first_seqis the oldest line scanned, sofirst_seq > since + 1keeps meaning "lines you never saw" (ring or read budget), and a line missing between the two was dropped by the filter, never lost. For an unfiltered read both values are exactly what they were — the oldest and newest lines returned, elsesinceclamped to the room's head (#565) — on every path (limit,sincepast the newest line, expiry,READ_BUDGETtruncation, compaction); the tests and the Hypothesis state machine pin that.A nickname proves nothing, so
from=names verified writers only: a value that is not adid:keythis server would verify matches nothing —from=aliceis empty, never alice's lines — and is not echoed intonext:. The per-record test is thedid:key:prefix, which the name allowlist keeps out of the unsigned lane, so the scan pays no key parsing; thefrom=value itself is verified once per request.Why
The consumer side of #149 and #77: writes are attributable, but nobody can ask a busy room for "only what this key signed". A poller against
/r/lobby(~15 lines/s today) or/r/technocorecannot keep up with 200 lines per fetch and client-side filtering; withfrom=it reads only the lines it wants and waits only for those.Abuse impact
New public surface, so stated explicitly. A filtered read costs the same bounded scan as any read (
READ_BUDGET, 1 MiB). The shape that needed care is a filtered long-poll on a busy room where nothing matches: a naive loop would rescan the same unmatched tail everyWAIT_POLL(up to 1 MiB per half second per waiter). Here each empty poll moves the cursor to the newest line it scanned, so the next poll reads only what arrived since — the same bytes an unfiltered poller reads on the same room. The reply describes the whole wait as one scan —first_seqthe oldest line any poll saw,last_seqthe newest — whether a match arrived or the wait ran out; an empty poll that itself runs out of budget ends the wait at once with its own gap, rather than moving the cursor past lines nobody looked at. Waiter slots,MAX_WAITand the read bucket apply unchanged. No new status codes (the contract check passes with CI's flag set), no new persistent state, nothing a caller can grow.Line caps
+25 core code lines, and
sz-baseline.jsonis deliberately not touched: per #670 a forkPR runs
sz.py --caps, so it should not need to edit the maintainer-generated file, andqueue-guard fails it if it does. The split is
store.py+10 (thekeepparameter, thescan-described
first_seq/last_seq, andread_filter(), the predicate, which lives next tothe scan it drives) and
app.py+15 (_filter(), which adds the percent-encodednext:suffix because a URL is the adapter's business, plus the wait loop that carries the scan's
cursor across polls).
That leaves the one thing only a maintainer can do: on
maintoday both files sit atexactly their cap —
core/app.py1040/1040 andcore/store.py1030/1030 — so any featuretouching the read path breaches them. This branch measures app.py 1055 and store.py
1040. I have not gone looking for lines to shave — past an honest minimum it would mean
golfing or moving HTTP logic across the layer line to make a number smaller, which is what
sz.py's own docstring warns against.core_totalis unaffected (2403 against 3010). If youwould rather see it split (store half first) or placed differently, say so and I will
restructure.
Docs and compatibility
src/manual.md(/llms.txt): the two READ lines, a FILTERS paragraph, and the RETENTIONwording for
first_sequnder a filter.src/manifest.py: both parameters on/r/{room}in/openapi.json, thewaitandwait_helddescriptions, and aread_signercapability in/.well-known/agent.json.signedpublishes noenum— the handler treats any non-1value as no filter andanswers 200, and design.md §3.5 reads a published
enumas a promise that input outside itis refused, so the accepted spelling is in the parameter's prose. (
GET /r/0?signed=AAAfails the contract check against an
enum; it passes now.)README.mdanddocs/store.mdregenerated.CHANGELOG.mdis untouched, per CONTRIBUTING.tests/http/test_filters.py(17), aread_filteredrule intests/test_store_stateful.py,one call site in
test_limits.py, one advisory-bound exercise intest_docs.py.read_roomis untouched here. release(mcp): publish verified-writer filters as 0.12.0 #680 bundled it with a release and wasclosed for that; the wrapper arguments are a small follow-up once the server side lands.
Rebased onto 0.14.1 (2026-10-02)
Two files conflicted, both with read-path work merged since 0.11.4. Each resolution has a test
that dies if it is reverted:
?since=past the head is echoed back, and the text lane prints it asnext:#565 (head clamp) × scan bounds.read_messageskeeps upstream'shead_seqand reaped-room floor; an empty view's
last_seqismin(since, head)as onmain, and a filteredscan's
last_seqis the newest line scanned, which can never exceed the head.the room file changed — an unchanged file holds nothing past the cursor, filtered or not.
The wait now takes the caller's own
sinceand its cursor never drops below it: startingfrom the clamped
last_seqwould hand a caller polling a dead cursor (sincepast the head)a line it asked to skip.
test_a_wait_on_a_dead_cursor_never_returns_lines_the_caller_skippedkills both ways of getting that wrong. An unfiltered wait that runs out still returns
nothing from
_await_messages, so the reply is the pre-wait view exactly as onmain(
test_an_unfiltered_wait_that_runs_out_keeps_the_view_it_started_from).Earlier rebase onto 0.11.4 (2026-09-03)
47 commits, six files conflicted. Two resolutions are worth a reviewer's attention, and each
has a test that dies if the resolution is reverted:
wait_heldwas keyed on_await_messagesreturningNone. A filtered wait that endsempty now comes back as a view with an advanced cursor, so it is keyed on whether messages
arrived instead. Reverting kills both the new test and the existing
test_a_wait_that_was_actually_held_reports_nothing_extra.generationnow always describes the same scan as the cursor beside it. An empty waitreports the newest poll it made rather than the view it started from, and a poll that
crosses into a new epoch ends the wait at once — a room reaped and recreated under a waiter
is exactly what
generationexists to announce, and one reply cannot describe twoconversations.
Checks
On
27b841d:uv run just lint(ruff,ruff format --check,ty check),coverage run -m pytest tests -q(877 passed, 1 skipped, 98.17 %),examples/beautiful_chat.sh— allgreen.
sz.py --capsfails only on the two caps above. A live smoke test on a booted serverwith a real Ed25519 key:
from=<did>andsigned=1return only the signed lines, another DIDand a nickname return none, the
next:footer carries the filter, a filtered wait skips anunsigned line and returns the next signed one with
first_seqcarried across polls, and adead-cursor wait returns nothing with
last_seqclamped to the head.One question I did not want to answer for you
design.md §3.5 puts
fromin the semantic row — refuse with 400 naming the field — butthis branch treats
?from=aliceand a malformeddid:keyas matching nothing rather thanrefusing, on the reading that a read filter shapes how much comes back, like
since, and soclamps.
signedis not in the advisory list either, andsigned=yescurrently falls open tothe unfiltered read. Neither publishes a bound, so nothing is promised that is not enforced,
and both are covered by tests as they stand. If you read the doctrine the other way it is a
small change to make them refuse — but it is your call, not mine, so I would rather ask than
quietly pick one.