Skip to content

Refuse moving an issue to review or merge until its pull request is recorded - #4409

Merged
mstomar125 merged 1 commit into
mainfrom
plays-pr-recorded
Dec 2, 2026
Merged

mstomar125 merged 1 commit into
mainfrom
plays-pr-recorded

Conversation

@mstomar125

@mstomar125 mstomar125 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

What

A new seeded core Play, "Require a pull request before an issue is reviewed". It refuses setting an issue's status to in_review or ready_to_merge while the issue's pull_request field is empty. The refusal says to record the pull request first. It is registered against issue, so a plain task is not checked. It is the rule of step 15 of Working an Issue in nodespace-core, written as a Play. It follows the shape of #4404: Play in core_plays.rs, change-log entry (additive / seeded_content), shape record regenerated (shape:gen, shape:check clean), skill:gen/skill:check report the skill reference is up to date (no change).

Why

The field is on the node and the check needs no judgment, so the rule should be enforced instead of read from a skill. The rule fires on a status change, not on creation: an issue created already in_review with no pull request is not refused (same limit as #4404).

Tests (core_model_plays_test.rs)

  • an_issue_without_a_pull_request_cannot_go_to_review_or_merge (both statuses refused, message says to record the pull request first, cancelling is free)
  • an_issue_with_a_pull_request_goes_to_review_and_merge (also: clearing the field takes the permission away again)
  • a_plain_task_goes_to_review_without_a_pull_request
  • Existing tests that moved issues to review without a pull request now record one first: issue_and_software_project_test.rs (helper issue(), one retype test) and packages/agent/tests/it/workflow_seeds.rs (test harness create only; no agent source or seed changed).
  • Ran green: nodespace-core --lib (2386), --test it modules core_model_plays / core_queries / issue_and_software / typed_flat (101), nodespace-agent --test it workflow_seeds (26), shape:check, skill:check, fmt; pre-push gate passed.

Mutation checks (each mutation applied alone, the 3 new tests run)

  • Condition on status never matches: 2 tests fail. Condition always true: the with-pull-request test fails. Rule dropping ready_to_merge: refusal test fails. Rule dropping in_review: refusal test fails. Pull-request condition replaced by false: fails. Rule registered against task: the 2 issue tests fail. Message text changed: refusal test fails.
  • Not killable by a test: registering the rule on task is not seen by the plain-task test, because a task has no pull_request field and the condition errors, which a reject rule treats as allow. The issue tests catch the registration, and the plain-task test only documents the behaviour.
  • The mutation runs were made on the first version of the condition (which also read the link's url). A link with an empty url cannot be stored, so the condition was simplified to !has(node.pull_request); the always-true / never-true / status-list / registration mutations were not re-run on the final text. The final text is covered by the 3 tests above, run green.

Overlaps

  • The planned "remove the plan type; spec --issues--> issue, issue --decisions--> decision" change does not touch this Play (it reads only status and pull_request of the issue).
  • Edits packages/agent/tests/it/workflow_seeds.rs (a test harness helper), which is in the agent package; flagging for Michael. Conflicts are possible with any open PR touching that helper or core_plays.rs / the shape record change log.

Unverified

  • No live run against a real daemon/CLI: only the integration tests above.
  • The step-15 skill text was not edited (agent lane); the message wording is not checked against the skill.
  • Full workspace tests were not run (shared machine), only the targeted sets above.

Note on a related item (project link at task creation)

A Play can trigger on node_created, on a relationship added or removed (matched on the source node type only), and on a schedule. None can check a project link at creation: a node and its links are separate writes, so an invariant on node_created runs before any link can exist and would refuse every task, and a link-added trigger cannot see an absent link. This stays in the filing skill, which is not in this repo.

🤖 Generated with Claude Code

@mstomar125

Copy link
Copy Markdown
Contributor Author

APPROVE at cfff47d

Independent review of the PR's own diff (base 6645d6a; main's later frontend-only PRs not considered).

What I checked and ran (CPU only):

  • Play (packages/core/src/playbook/core_plays.rs, issue_pull_request_rules): a property_changed trigger on issue.status, conditions status == in_review || ready_to_merge AND !has(node.pull_request), then reject. Scoped to issue, so plain tasks are untouched. Cancel, reopen, in_progress, changes_requested, done are not matched. An issue with a recorded PR passes. Clearing the field (null) makes has() false again; a test covers it.
  • "Recorded" means the pull_request link field is present. A link must be an object with exactly title and url, where url is absolute with a host and has no whitespace (LinkValue::from_json, enforced in node_service/crud.rs ~4355). So "", whitespace, {}, a string or a different property cannot satisfy it. It can still be satisfied by any well-formed URL; that is inherent to a presence check and fine.
  • Shape record: shape_record check passes, generate produces no diff against the committed current.json, shape_record_test 5/5, node-types:check ok. The change-log entry is additive / seeded_content / config with the right id, and its text matches the behaviour (fires on change, not creation; 0.3.14 build treats it as an ordinary play).
  • Agent lane: packages/agent changes are test-only (tests/it/workflow_seeds.rs harness gives each created issue a PR). No seed or skill text changed. The skill order is already right: implementing-a-task STEP 7 records the PR, STEP 8 moves to review. workflow_seeds 26/26 pass.
  • Tests: core_queries_test, issue_and_software_project_test, core_model_plays_test (80 passed), core_plays lib tests 12/12. Mutation check: replacing !has(node.pull_request) with false makes an_issue_without_a_pull_request_cannot_go_to_review_or_merge and an_issue_with_a_pull_request_goes_to_review_and_merge fail. Reverted afterwards.
  • Message: "This issue has no pull request recorded ... set its pull_request field to the pull request's title and URL ... do not retry the same change." Clear and actionable for CLI, UI and agent callers alike.

Blocking: none.

Should-fix: none.

Nits (non-blocking):

  1. packages/core/tests/it/core_model_plays_test.rs:~278 the_seven_plays_are_seeded_with_fixed_ids_and_enabled does not list the new Play (nor the earlier ones past seven), so "seeded, enabled, has rules" for ISSUE_PULL_REQUEST_PLAY_ID is only covered via CORE_PLAY_IDS unit tests. A one-line addition would close it.
  2. Legacy data: an existing issue already in_review with no PR is not touched, but moving it in_review -> ready_to_merge is refused until a PR is recorded (so a reviewer's pass fails with the message above). This is consistent with the intent and the message tells them what to do; worth a line in the release notes.
  3. Issues created directly in in_review skip the rule (documented in the change log and the doc comment).

🤖 Generated with Claude Code

…ecorded

A new seeded core Play refuses setting an issue's status to in_review or
ready_to_merge while its pull_request field is empty, and says to record the
pull request first. It is registered against issue, so a plain task is never
checked. Tests cover the refusal, an issue with a pull request moving on, and
a plain task. Existing issue tests record a pull request before review. The
shape record and its change log carry the new seeded Play.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@mstomar125
mstomar125 merged commit 5200f80 into main Dec 2, 2026
@mstomar125
mstomar125 deleted the plays-pr-recorded branch December 2, 2026 09:19
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