Skip to content

Comment routing: a pure adapter crate from a stored math result to the equation library's inputs (dormant; nothing calls it) - #3501

Draft
colinmegill wants to merge 10 commits into
routing/plan-prerequisitesfrom
routing/plan-adapter
Draft

colinmegill wants to merge 10 commits into
routing/plan-prerequisitesfrom
routing/plan-adapter

Conversation

@colinmegill

Copy link
Copy Markdown
Member

What this is

A new, pure Rust crate, queue-rs/polis-routing-plan, stacked on PR #3500. It holds one thing so far: the adapter that turns the parts of a stored math result into the typed input frames of the comment routing equation library. Nothing calls it, so nothing a person can observe changes.

  • No schema change. No route, no database, no switch, nothing under queue-rs/polis-api/.
  • It is the one crate the equation library's dependency rule allows to depend on it.

What it does

  • Parse, then frames. It reads a math result handed to it as bytes: per-comment counts by opinion group (agree, disagree, seen), the stored comment extremity, the groups, the comment ids and the meta comment ids. From those it builds the frames a rule needs, all naming the same math update. It reads counts only; no vote sign is interpreted anywhere.
  • Refusals are a closed list and never carry a comment id. A math result without the group inputs a rule needs (an older result, for example) is refused as missing, so a caller keeps today's draw for that conversation.
  • Bounds before work. Only objects are decoded (positional record shapes are refused). The number of distinct comment ids is limited before anything is expanded. Projection::parse_reservation(len, limits) gives, before parsing starts, an upper bound on the additional heap parsing can hold at once, for inputs that will be refused too; it is deliberately loose and is true on every constructed case, including one built to exercise the scanner's spill. The README says what that charge covers and what it does not (the caller's input buffer, inline and stack space, allocator overhead).
  • Pure. No I/O, clock, network or database. A source scan and a dependency rule in its check refuse those capabilities, including one reached through an alias.
  • make check-polis-routing-plan is the one local entry point; the hosted job calls the same command.

Checks

Passed locally at this head: make check-polis-routing-plan (42 tests, formatting, clippy, the source scan, the dependency rule), make check-polis-routing-equation (157 tests; today's equation still 1,386 of 1,386 grid cases and 3,257 of 3,257 replayed cells bit for bit against the Python formula) and make check-vote-sign-lint. Reviewed by the second reviewer over three rounds; its corrections are in the history.

All fixtures are constructed; no real conversation's data is used. Nothing here is a statement about speed.

🤖 Generated with Claude Code

colinmegill and others added 10 commits November 27, 2026 02:39
…ult into the routing equation's typed frames (draft for the box check)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… comes from in the math result

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…can and dependency rule are tightened, from review

The derived struct decoders also accepted positional sequences, which the
walk does not count by name: a positional base-cluster list could hide its
members from the memberships limit and the reservation. Group bodies,
cells, the pca object, group clusters and base clusters now decode only
from objects, with regressions for all five shapes, for absent and null
membership sources, for a truly escaped duplicate key and for empty and
partial group frames.

The source scan reads each file whole, so whitespace, line breaks and a
std alias cannot hide a forbidden path, and it carries its own witnesses.
The dependency rule also checks resolved package identities: the equation
crate at its own path and the other three from crates.io.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…on is limited at parse (draft for the box check)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he comment id union at parse

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ys, at parse

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…l; what the parse charge covers is written down

From review. The counting allocator in the tests subtracted the old
buffer before adding its replacement, so a reallocation that moves was
undercounted; it now counts both. A constructed input (distinct keys,
then compact repeats just past a capacity boundary) proves the
scanner's spill term is needed. The README says what the parse charge
covers (additional heap during parse), what it does not (the caller's
input buffer, inline and stack space, allocator overhead), and how
ownership of what is kept passes on. No runtime code changes.

This branch has not been deployed

No deployments
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