Skip to content

feat(http): the reviewer check reads the principal's kind - #785

Merged
ajianaz merged 1 commit into
developfrom
feat/reviewer-by-kind
Dec 5, 2026
Merged

ajianaz merged 1 commit into
developfrom
feat/reviewer-by-kind

Conversation

@ajianaz

@ajianaz ajianaz commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

What

ADR-0022, slice 14: the reviewer check moves to the kind. Who may set a review state of a batch, and who may make or read a checkpoint, is now the principal's kind: a person may, an agent never may, whatever its actor string says. MELDFRAME_REVIEWERS is no longer read by meldframe-http; it lives in the development-token adapter and lists the development actors that are people.

Stacked on #783 (slice 15a, feat/principal-aware-policy): the base of this pull request is that branch, so the diff holds this slice only. If #783 merges first, this branch is rebased onto develop and the base is changed by its owner.

Why

ADR-0021 denied by default and let only actors named in MELDFRAME_REVIEWERS review, because Principal had no kind and an actor string cannot be trusted (claude, Agent:x, person:x). The kind exists since slice 2 and Principal::policy reads it since 15a, so the check can say what it means. An agent that holds every tier and carries a person's actor string is still an agent, which a test of the real server shows. The sign-in session (slice 11b) will decide the kind by its own authenticator, and nothing in this slice has to change for it.

One logical change: the rule, the adapter that now owns the list, and the script and docs that name the dev identity.

Changes

  • meldframe-auth: DevPersons (dev_persons.rs, the parser of the old Reviewers: trimmed, empty entries ignored, a bad entry or more than 32 an error that names the entry's number and never its text) and DevTokens::with_persons, which makes a token whose actor is listed a Person and leaves every other token an Agent (exact, case-sensitive match of the whole actor; the client kind of MELDFRAME_DEV_TOKEN_KINDS is kept in either order).
  • meldframe-http: Setter::can_review is as_person() plus the registry's policy for batch_review; the setter's forbidden and the list's canReview are that one rule. The checkpoint create and state routes read the kind the same way (canCreate agrees). activity/reviewers.rs and the checkpoint May closure are gone, and Service::with_review takes only the policy.
  • apps/server: dev_persons_from_env reads the variable once, before anything opens, serving or not. A list that names no token's actor prints a warning that names the variable only.
  • scripts/dev-env.sh (new) and scripts/dev.sh: dev_export_identity lists the dev actor agent:dev first and keeps a list already in .env, so the editor of just dev is a person.
  • Docs: a "Built, slice 14" note in the ADR-0022 Plan (with what was decided where the ADR was silent, what is not covered and what slices 13a and 17 must know), an amendment in ADR-0021, wording in ADR-0023, the E5.1 and E5.3 notes of docs/epics.md, GLOSSARY Review, AGENTS.md (the variable's meaning and a slice 14 entry), docs/architecture.md, docs/collab-ux.md, docs/error-codes.md, docs/quickstart-agent.md, .env.example, the justfile comment, two feature comments and the header of m1-demo.mjs.
  • No protocol type changed (canReview is still a bool), so tools/check-protocol.sh was not needed and the web client is unchanged.

Decided where the ADR was silent: the variable keeps its name and means "development actors that are people"; it is orthogonal to MELDFRAME_DEV_TOKEN_KINDS and the two compose; a listed actor that no token has is a warning, not an error; the kind rule also covers the checkpoint routes, because their closure was built from the same list; a person still needs the registry's policy for batch_review to let the call through; two tokens with one listed actor in two workspaces are two people. I found no sentence in ADR-0021 or the epic that worded the reviewer rule as "owner"; the rule said "a person" and "an actor listed in MELDFRAME_REVIEWERS", and both are corrected. The "owner" of GLOSSARY Approval and Policy and of docs/error-codes.md is the answer to an Ask, which slices 17 and 21 change.

Testing

New tests:

  • crates/core/meldframe-auth/tests/dev_persons.rs, 15 tests, native and under WASM (cargo test --target wasm32-unknown-unknown --tests -p meldframe-auth, 15 passed there): the parser, ADR-0021's table of actors (a person's name, agent:, claude, Agent:x, person:x) as development tokens, near misses, workspace, actor and tiers kept, the client kind kept in both orders, a person's Ask read as Auto.
  • apps/server/tests/reviewer_kind.rs, 5: over REST on the real server, no agent sets a review whatever tiers it holds or what it is called, an agent that borrows a person's actor is judged by its credential, a person sets, flags and clears and the same state sends no frame, a refused agent writes nothing and sends no frame, and canReview reaches the app layer.
  • apps/server/tests/reviewer_binary.rs, 8: the real binary: listed means person, other means agent, exact match, an unset or empty list, a list that names no token (warning, no entry or token echoed), the list and the client kinds compose, a bad list (cap, malformed actor, hidden characters, not text) stops the start serving or not and repeats no entry.
  • apps/server/tests/dev_script.rs, 3: scripts/dev-env.sh run in a clean shell and the real binary started on what it exports: the dev editor may review and make a checkpoint, an agent with a token of its own may not, a list from .env is kept.
  • scripts/dev-env-test.sh, 10 checks, added to just check.
  • Ported: setter.rs, probing.rs, checkpoint_routes.rs, principal_routes.rs and the activity and checkpoint worlds; reviewers.rs is replaced by reviewer_kind.rs.

Hand mutants, each of which fails at least one test (and each file restored): the setter reading the actor string, the setter letting an agent through, with_persons listing nobody, with_persons listing every token, the checkpoint create gate reading the actor string, dev-env.sh not listing the dev actor (this one fails dev_script.rs and dev-env-test.sh).

Commands run, all green on the head commit:

  • cargo fmt --all --check; cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace: 4707 passed, 0 failed (684 test binaries); cargo test -p meldframe-server: 762 passed, 1 ignored (112 binaries); the Postgres tests skip without DATABASE_URL, as everywhere
  • cargo test -p meldframe-server --no-default-features: 356 passed; with --features activity only: 520 passed; cargo build of meldframe-http and meldframe-server with no default features, with activity and with checkpoints
  • cargo xtask deps-check, mm-check (also --base), size-check (also --base), toolkit-swap --graph-only, portable-check; sh scripts/ci/principal-mint.sh; sh scripts/ci/selftest.sh; bash scripts/portable-shell-test.sh; bash -n of the three scripts

Not run: packages/web-panels/scripts/activity-e2e.mjs and the other browser scripts (they need Playwright, a server and two tokens; their command lines still hold because the variable is read as before), just check as a whole, just wasm-test beyond meldframe-auth, cargo xtask build-matrix and the Postgres tests. Not covered by this slice: a sign-in session is not a person yet (slice 11b), there is no role field, and the checkpoints feature still lists activity though the checkpoint code no longer reads it.

Cora (agent, local): the deterministic pass only, cora review --base feat/principal-aware-policy --no-llm, no issues after two false positives on comments (a "hardcoded secret" match on token:workspace:actor wording) were reworded; the agent review (cora mcp, review_prepare and review_finalize) was not run, because no independent reviewer was available to the session that wrote this change, so no independent review is claimed.


@ajianaz
ajianaz force-pushed the feat/principal-aware-policy branch 2 times, most recently from db16e81 to c7b9ad3 Compare December 5, 2026 01:28
ADR-0022, slice 14. Who may set a review state and who may make or read a
checkpoint is the kind of the principal: a person may, an agent never may,
whatever its actor is called. The setter's refusal and the list route's
canReview are one rule, and the checkpoint create and state routes read the
same kind, so meldframe-http no longer holds a reviewer list.

MELDFRAME_REVIEWERS moves into the development-token adapter. It lists the
development actors that are people (DevPersons, DevTokens::with_persons in
meldframe-auth); every other development token is an agent. It is read in one
place in the server binary, keeps its parser and its limits, and composes with
MELDFRAME_DEV_TOKEN_KINDS, which is the client kind. scripts/dev.sh gets the
two lines that name the dev identity from scripts/dev-env.sh, so the editor of
just dev is a person.

Tests: the parser and ADR-0021's table of actors as development tokens, the
table over REST on the real server, the real binary with good and bad lists,
the dev script in a clean shell and the server on what it exports, and the
review setter for a person and for an agent. Docs say "a person" where the
reviewer rule said a listed actor.

Signed-off-by: Anaz S. Aji <12648688+ajianaz@users.noreply.github.com>
@ajianaz
ajianaz changed the base branch from feat/principal-aware-policy to develop December 5, 2026 08:16
@ajianaz
ajianaz force-pushed the feat/reviewer-by-kind branch from e0a5f09 to 14e31a4 Compare December 5, 2026 08:16
@ajianaz
ajianaz merged commit d0587c5 into develop Dec 5, 2026
10 of 11 checks passed
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