Skip to content

feat(rules): issue/PR state as transitions, dense numbering, monotonic check runs (shared vectors) - #155

Merged
PastaPastaPasta merged 6 commits into
wipe/beta7from
feat/wipe-transitions-rules
Sep 29, 2026
Merged

PastaPastaPasta merged 6 commits into
wipe/beta7from
feat/wipe-transitions-rules

Conversation

@PastaPastaPasta

Copy link
Copy Markdown
Owner

What

This PR adds the shared pure rules for the fresh beta.7 registration (WIPE-PLAN §2.5–§2.7) and their shared conformance vectors. The Rust and TypeScript ports stay in lockstep. It targets the integration branch wipe/beta7, not master.

It carries merges of wipe/beta7 into this branch: master's dg ci (#148), import fidelity (#147) and the beta.7 SDK (#153). wipe/beta7 was fast-forwarded to master first so the §2.7 work could build on dg ci. The web PR and the CLI/import/relay PR stack on this one.

The code review's findings are addressed in f6be5e6.

rules::transition (Rust) / lib/rules/transition.ts (TS)

This is the state machine of STATE-COUNTS §2.1. Every state change is a transition whose per-target delta sum is the state code: 0 open, 1 closed, 2 merged, 8 draft, 9 closed draft.

  • next_transition(target, code, action, actor, number): the one legal move for close, reopen, merge, draft or ready from a given code. actor is Member, Author or Other. It returns the kind, delta, targetKind, asAuthor (0 for a member, else the target number) and the code after. It returns None for a stranger (40120) and wherever the contract's c1–c5 or f_authorNoMerge rules would refuse.
  • status_of_code, state_code, merge_transition.
  • repo_counts: the open, closed, merged and draft totals from the three proved counts of STATE-COUNTS §4, saturating at 0.
  • dense_number, names_dense_rule: the dense next number (§2.6), and recognising a 10422 refusal that names the dense rule.

rules::v2

  • issue_state_v2 / pr_state_v2: state comes from the code, while labels, assignees and the base ref still come from member events. State kinds carried on events are inert.
  • D-9: a merge is a chain fact. PrState.merge_on_base tells a reader whether the merge oid was a valid base tip. When it is false, readers label the PR "merge commit not found on the base".
  • trusted_upstream_number: upstreamNumber is trusted only from the repo owner or a current member (D-2, ISS-02).
  • check_run_write (D-5): decides create or replace for a report, and which startedAt, completedAt, conclusion and externalId it sets, so the forge-community checkRun rules hold (conclusionIfDone, doneIfConclusion, startedIfRunning, runningIfStarted, completedAtIfDone, doneIfCompletedAt).
    • A report consensus would refuse whatever is stored returns None.
    • startedAt is set on the first report that is not queued, and completedAt on the first completed one, never before the start.
    • A stored value is never changed.
    • A backwards move, a changed conclusion, or another externalId becomes a new run.

The retired functions (fold_*_state_v2, allocate_number) stay for now so their callers compile. They are removed in the consumer PRs (web, CLI/import/relay).

Vectors

Change Vectors
Retired allocate_number__* (15); 10 fold vectors whose inputs consensus now refuses (author merge, author label, stranger author events, merge after close)
Reshaped fold_issue_v2__* and fold_pr_v2__*: inputs are now {transitions | sum (+mergeOid), events, base…}
New transition__* (14): every action from every code for a member, the author and a stranger, the state codes, sums, and the count formulas
New dense_number__* (5)
New upstream_number__* (5)
New check_run_write__* (18)

Expected values were generated by a third, independent Python model of the rules. Both harnesses refuse unknown keys.

Tested offline

  • cargo test -p forge-core --lib rules: conformance plus unit tests, on the beta.7 tag.
  • cargo clippy -p forge-core --all-targets -D warnings.
  • vitest lib/rules: 359 tests.

Totals, proofs and fees are not testable offline; they are listed as live checks in WIPE-PLAN §3.

🤖 Generated with Claude Code

PastaPastaPasta and others added 5 commits September 29, 2026 10:57
…ream numbers, with shared vectors

Adds rules::transition (Rust) and lib/rules/transition.ts: the delta table, legal moves, state codes, the repo count formulas of STATE-COUNTS §4, the dense next number and the 10422 dense refusal. The issue/PR folds take the state code and fold only labels, assignees and the base ref from events; a merge is the chain fact and carries mergeOnBase for the reader label (D-9). allocate_number__* retire; fold vectors move to transitions or sums; transition__, dense_number__ and upstream_number__ vectors are new.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…shared vectors

check_run_write / checkRunWrite decide create or replace and the times a report sets so the forge-community checkRun rules hold (D-5): startedAt on the first non-queued report, completedAt on the first completed one, never before the start, a stored time never changed, a backwards move or changed conclusion is a re-run. 13 check_run_write__ vectors.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…l ids, parity edges

next_transition takes Member/Author/Other (a stranger gets no move); check_run_write enforces conclusionIfDone/doneIfConclusion, carries conclusion and externalId (a changed externalId is a re-run); an empty merge oid is unknown in both ports; saturating counts; denseNumber >= 1; STATUS_RANK is a Map; vector names in the docs follow the reshape; review_kinds vector keeps threadResolve.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 4058dd26-322e-4bee-ba23-a96bf72824bf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@PastaPastaPasta

Copy link
Copy Markdown
Owner Author

The web check fails in two tests: lib/sdk/contract-seed.test.ts (devnet-moutai snapshot) and lib/private/conformance.test.ts.

Both already fail on wipe/beta7 since #153, and I checked this on a clean checkout of origin/wipe/beta7. The beta.7 loader refuses the beta.6-registered contract snapshot (refersTo lookup was replaced by findBy). #154 removes that snapshot. I'll merge wipe/beta7 into this branch once #154 lands, and re-run.


🤖 Posted autonomously by Claude on behalf of pasta.

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