Merge remote-tracking branch 'origin/main' into item-539
CI / tests (pull_request) Has been cancelled
CI / tests (pull_request) Has been cancelled
This commit is contained in:
@@ -2,6 +2,10 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
- The technical principles ask code to read why a call failed from a status code, a documented exit code or a typed error, and not from message text.
|
||||
- `chunk-preflight` reports a project whose tracked code is mostly space-indented while no `.editorconfig` or formatter setting sets the indent, and the technical principles' hard-tabs default is overridden only by such a setting plus a recorded decision.
|
||||
- `chunk-pr push` waits for the forge to show the pushed commit as the head of the branch's open pull request before it asks for a review, and fails naming the pull request where the forge does not.
|
||||
- `chunk-pr merge` honours `merge = "human"` and `wait-for-approval` for a chunk whose recorded base is origin's default branch.
|
||||
- larv-review's claimed-output step runs each claim in a fresh clone, without the ignored files earlier runs wrote, and checks claims about what a command writes.
|
||||
- stability-reviewer now flags a regex that validates a whole input with `$`, which also matches before a final newline.
|
||||
- stability-reviewer checks that a guard on whether a file, row or record exists looks at every place the thing passes through.
|
||||
|
||||
+61
-24
@@ -43,7 +43,9 @@ ready marks the pull request ready for review. On Gitea a draft is a pull req
|
||||
as the pull request's title first; where that fails, the pull request stays a draft.
|
||||
push pushes the branch, setting its upstream. Where its pull request is open and goes into an
|
||||
epic's working branch, it then asks for a review as ready does. Use it for each push
|
||||
after ready there, and wait for that review as for any other.
|
||||
after ready there, and wait for that review as for any other. Before it asks, it waits up
|
||||
to a minute for the forge to show the pushed commit as the head of the branch's open
|
||||
pull request, and fails, naming the pull request, where the forge still doesn't after that.
|
||||
merge merges the pull request in its turn: the chunks of one project on this machine take
|
||||
turns, one at a time. Run it in the background. In its turn it:
|
||||
1. fetches origin and merges its default branch into the branch, as sync does;
|
||||
@@ -120,7 +122,7 @@ import time
|
||||
import typing
|
||||
|
||||
from chunk_pr.approval import approval, approved, awaited, left_to_a_person, left_to_park, PARKS, unanswered
|
||||
from forge.pulls import checks_passed, merged_pull, open_pull, other_base, required_checks
|
||||
from forge.pulls import checks_passed, merged_pull, open_pull, other_base, pull_from, required_checks
|
||||
from git_cli.git_repo import CHUNK_BASE, Git
|
||||
from git_cli import epic_branch
|
||||
from failure import Failure
|
||||
@@ -139,6 +141,9 @@ QUEUE = "chunk-pr-merge-queue"
|
||||
# A turn lasts as long as its checks, which chunk-pr waits half an hour for on Gitea, so a queue still held after that is reported, not waited out.
|
||||
QUEUE_SECONDS = 30 * 60
|
||||
QUEUE_POLL_SECONDS = 10
|
||||
# How long push waits for the forge to show the pushed commit as the head of the branch's open pull request, polling every PUSH_POLL_SECONDS: GitHub may list the old head for a while after a push.
|
||||
PUSH_SECONDS = 60
|
||||
PUSH_POLL_SECONDS = 5
|
||||
# The line record-ruling writes into the comprehension history, as git's -G reads it.
|
||||
RULING = "^Ruling: "
|
||||
# The project's config, loaded once per step, on the first call that needs it.
|
||||
@@ -164,8 +169,8 @@ def main(argv: list[str]) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
def step(argv: list[str], run: Run, config: Config, parks: bool = False) -> str | Failure:
|
||||
"""Run the step argv names: the line to print, or a Failure. A malformed argv doesn't run anything. parks is whether a merge fails at once where it would wait for an approval (`merged`)."""
|
||||
def step(argv: list[str], run: Run, config: Config, parks: bool = False, sleep: typing.Callable[[float], None] = time.sleep) -> str | Failure:
|
||||
"""Run the step argv names: the line to print, or a Failure. A malformed argv doesn't run anything. parks is whether a merge fails at once where it would wait for an approval (`merged`). sleep is how push and merge wait."""
|
||||
match argv:
|
||||
case ["open", title, *body] if len(body) <= 1 and not title.startswith("-"):
|
||||
return Failure("give a title of one line") if not one_line(title) else misfit(title, run, config) or opened(title, body[0] if body else "", run)
|
||||
@@ -175,12 +180,12 @@ def step(argv: list[str], run: Run, config: Config, parks: bool = False) -> str
|
||||
return Failure("give a title of one line") if title and not one_line(title[0]) else (misfit(title[0], run, config) if title else None) or readied(run, title[0] if title else None, config)
|
||||
# Three readers, seated as those who run `chunk-pr`, picked the spellings `push`, 3-0, and `open-epic`, 2-1.
|
||||
case ["push"]:
|
||||
return pushed(run, config)
|
||||
return pushed(run, config, sleep)
|
||||
case ["open-epic", epic, title, *body] if len(body) <= 1 and not any(given.startswith("-") for given in (epic, title)):
|
||||
return Failure("give a title of one line") if not one_line(title) else epic_opened(epic, title, body[0] if body else "", run, config)
|
||||
case ["merge", *given]:
|
||||
finishes = finishes_of(given)
|
||||
return Failure(USAGE) if finishes is None else merged(run, config, time.sleep, finishes=finishes, parks=parks)
|
||||
return Failure(USAGE) if finishes is None else merged(run, config, sleep, finishes=finishes, parks=parks)
|
||||
case ["clean"]:
|
||||
return cleaned(run)
|
||||
return Failure(USAGE)
|
||||
@@ -235,12 +240,13 @@ class Base:
|
||||
|
||||
|
||||
def base_of(branch: str, run: Run) -> Base | Failure:
|
||||
"""The Base of the pull request from branch: the epic's working branch the checkout records for it (`git_repo.record_chunk_base`), else origin's default branch."""
|
||||
recorded = run(["git", "config", "--get", f"branch.{branch}.{CHUNK_BASE}"])
|
||||
if not isinstance(recorded, Failure) and recorded.strip():
|
||||
return Base(recorded.strip(), True)
|
||||
"""The Base of the pull request from branch: the epic's working branch the checkout records for it (`git_repo.record_chunk_base`), else origin's default branch. A recorded base equal to origin's default branch isn't an epic's working branch: the pull request merges into the default branch, so `merge = "human"` and `wait-for-approval` apply to it."""
|
||||
default = default_branch(run)
|
||||
return default if isinstance(default, Failure) else Base(default, False)
|
||||
if isinstance(default, Failure):
|
||||
return default
|
||||
recorded = run(["git", "config", "--get", f"branch.{branch}.{CHUNK_BASE}"])
|
||||
recorded = "" if isinstance(recorded, Failure) else recorded.strip()
|
||||
return Base(recorded, True) if recorded and recorded != default else Base(default, False)
|
||||
|
||||
|
||||
def pull(run: Run) -> tuple[Forge, str, str] | Failure:
|
||||
@@ -363,24 +369,59 @@ def marked_ready(run: Run, title: str | None) -> str | Failure:
|
||||
return f"Marked pull request #{number} ready, titled “{title}”." if title is not None else f"Marked pull request #{number} ready."
|
||||
|
||||
|
||||
def pushed(run: Run, config: Config) -> str | Failure:
|
||||
"""Push the branch checked out, and ask for a review of its open pull request as `review_asked` does."""
|
||||
def pushed(run: Run, config: Config, sleep: typing.Callable[[float], None]) -> str | Failure:
|
||||
"""Push the branch checked out, and ask for a review of its open pull request as `review_asked` does, once the forge shows the pushed commit as that pull request's head."""
|
||||
found = checkout(run)
|
||||
if isinstance(found, Failure):
|
||||
return found
|
||||
forge, branch, head = found
|
||||
sent = run(["git", "push", "--quiet", "--set-upstream", "origin", branch])
|
||||
number = sent if isinstance(sent, Failure) else open_pull(forge, branch, head, run)
|
||||
if isinstance(sent, Failure):
|
||||
return sent
|
||||
comment = review_comment(run, config)
|
||||
if isinstance(comment, Failure):
|
||||
return Failure(f"pushed {branch}, but could not ask for a review: {comment.reason}")
|
||||
if comment is None:
|
||||
return f"Pushed {branch}."
|
||||
number = shown_pull(forge, branch, head, run, sleep)
|
||||
if number is None:
|
||||
return f"Pushed {branch}."
|
||||
if isinstance(number, Failure):
|
||||
return number
|
||||
asked = review_asked(forge, number, run, config) if number is not None else None
|
||||
if isinstance(asked, Failure):
|
||||
return Failure(f"pushed {branch}, but could not ask for a review: {asked.reason}")
|
||||
return f"Pushed {branch}, and asked for a review of pull request #{number} with “{asked}”." if asked else f"Pushed {branch}."
|
||||
made = comment_on(forge, number, comment, run)
|
||||
return Failure(f"pushed {branch}, but could not ask for a review: {made.reason}") if isinstance(made, Failure) else f"Pushed {branch}, and asked for a review of pull request #{number} with “{comment}”."
|
||||
|
||||
|
||||
def shown_pull(forge: Forge, branch: str, head: str, run: Run, sleep: typing.Callable[[float], None]) -> str | None | Failure:
|
||||
"""The number of branch's open pull request at head, just pushed. Right after a push the forge may still list that pull request at an older head. While it does, this polls for up to PUSH_SECONDS, then returns a Failure naming the pull request. None where no pull request from branch is open: `push` before `open` is normal."""
|
||||
other = None
|
||||
for waited in range(0, PUSH_SECONDS + 1, PUSH_POLL_SECONDS):
|
||||
number = open_pull(forge, branch, head, run)
|
||||
if number is not None:
|
||||
return number
|
||||
other = pull_from(forge, branch, run)
|
||||
if not isinstance(other, str):
|
||||
return other
|
||||
if waited < PUSH_SECONDS:
|
||||
sleep(PUSH_POLL_SECONDS)
|
||||
return Failure(f"pushed {branch}, but pull request #{other} still doesn't show {head[:12]} as its head after {PUSH_SECONDS} seconds, so no review was asked for; once it does, run chunk-pr push again")
|
||||
|
||||
|
||||
def review_asked(forge: Forge, number: str, run: Run, config: Config) -> str | None | Failure:
|
||||
"""Comment on the pull request numbered number with the config's `review-request-comment`, where the pull request goes into an epic's working branch: a forge's auto-reviewer may review only pull requests into the default branch unless asked. The comment made; None where the config names none or the pull request goes into the default branch."""
|
||||
"""Comment on the pull request numbered number as `review_comment` says. The comment made; None where it says none."""
|
||||
comment = review_comment(run, config)
|
||||
if comment is None or isinstance(comment, Failure):
|
||||
return comment
|
||||
made = comment_on(forge, number, comment, run)
|
||||
return made if isinstance(made, Failure) else comment
|
||||
|
||||
|
||||
def comment_on(forge: Forge, number: str, comment: str, run: Run) -> str | Failure:
|
||||
return run(["gh", "pr", "comment", number, "--body", comment] if forge == "gh" else ["tea", "comment", number, comment])
|
||||
|
||||
|
||||
def review_comment(run: Run, config: Config) -> str | None | Failure:
|
||||
"""The config's `review-request-comment`, where the pull request from the branch checked out goes into an epic's working branch: a forge's auto-reviewer may review only pull requests into the default branch unless asked. None where the config names none or the pull request goes into the default branch."""
|
||||
branch = answers(run, ["symbolic-ref", "--short", "HEAD"])
|
||||
base = branch if isinstance(branch, Failure) else base_of(branch[0], run)
|
||||
if isinstance(base, Failure):
|
||||
@@ -388,11 +429,7 @@ def review_asked(forge: Forge, number: str, run: Run, config: Config) -> str | N
|
||||
if not base.to_epic:
|
||||
return None
|
||||
loaded = config()
|
||||
if isinstance(loaded, Failure) or loaded.review_request_comment is None:
|
||||
return loaded if isinstance(loaded, Failure) else None
|
||||
comment = loaded.review_request_comment
|
||||
made = run(["gh", "pr", "comment", number, "--body", comment] if forge == "gh" else ["tea", "comment", number, comment])
|
||||
return made if isinstance(made, Failure) else comment
|
||||
return loaded if isinstance(loaded, Failure) else loaded.review_request_comment
|
||||
|
||||
|
||||
def epic_opened(epic: str, title: str, body: str, run: Run, config: Config) -> str | Failure:
|
||||
|
||||
@@ -12,7 +12,7 @@ import unittest
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from chunk_pr.approval import awaited
|
||||
from chunk_pr.main import cleaned, merged, QUEUE, step, turn, USAGE
|
||||
from chunk_pr.main import Base, base_of, cleaned, merged, QUEUE, step, turn, USAGE
|
||||
from failure import Failure
|
||||
from test_env import isolated_env
|
||||
from project_config.settings import ProjectConfig
|
||||
@@ -22,8 +22,9 @@ from forge.reviews import THREADS
|
||||
TOOL = pathlib.Path(__file__).resolve().parents[1] / "chunk-pr"
|
||||
GITHUB = "git@github.com:me/project.git"
|
||||
GITEA = "ssh://git@gitea.example.org:22/me/project.git"
|
||||
HEAD = "c0ffee"
|
||||
HEAD = "c0ffee" * 7
|
||||
PUSH = ["git", "push", "--quiet", "--set-upstream", "origin", "item-7"]
|
||||
OLD = "badc0de" * 6
|
||||
GH_LIST = ["gh", "pr", "list", "--head", "item-7", "--json", "number,headRefOid,isCrossRepository", "--template", "{{range .}}{{.number}}\t{{.headRefOid}}\t{{.isCrossRepository}}\n{{end}}"]
|
||||
TEA_LIST = ["tea", "api", "repos/{owner}/{repo}/pulls?state=open&limit=50"]
|
||||
GH_SETTINGS = ["gh", "repo", "view", "--json", "mergeCommitAllowed,rebaseMergeAllowed,squashMergeAllowed"]
|
||||
@@ -61,6 +62,8 @@ class Checkout:
|
||||
self.chunk_base = ""
|
||||
# The branch the forge merges the pull request into on each read; the last one repeats. Empty where the forge has the checkout's: chunk_base, else main.
|
||||
self.bases: list[str] = []
|
||||
# The heads GitHub lists pull request #12 at on each read; the last one repeats. Empty where it lists HEAD.
|
||||
self.listed_heads: list[str] = []
|
||||
# What GitHub reports as the pull request's review decision on each read; the last one repeats.
|
||||
self.decisions = ["APPROVED"]
|
||||
# Set, what GitHub prints instead of a decision's JSON.
|
||||
@@ -101,7 +104,7 @@ class Checkout:
|
||||
if command[2:3] == ["create"]:
|
||||
self.open = True
|
||||
if command == GH_LIST:
|
||||
return f"12\t{HEAD}\tfalse\n" if self.open else ""
|
||||
return f"12\t{self.listed_heads.pop(0) if len(self.listed_heads) > 1 else self.listed_heads[0] if self.listed_heads else HEAD}\tfalse\n" if self.open else ""
|
||||
if command == TEA_LIST:
|
||||
return json.dumps([{"number": 12, "head": {"ref": "item-7", "label": "item-7", "sha": HEAD, "repo": {"full_name": "me/project"}}, "base": {"repo": {"full_name": "me/project"}}}] if self.open else [])
|
||||
if command == TEA_STATUS:
|
||||
@@ -365,6 +368,13 @@ class Merge(unittest.TestCase):
|
||||
self.assertEqual(merged(checkout, checkout.config, slept.append), "Merged pull request #12 (merge).")
|
||||
self.assertEqual(sum(slept), 60)
|
||||
|
||||
def test_the_merge_step_waits_with_the_sleep_it_is_given(self):
|
||||
checkout = Checkout(GITEA, open=True)
|
||||
checkout.statuses = [json.dumps({"total_count": 0, "state": "pending", "statuses": []})] * 7
|
||||
slept: list[float] = []
|
||||
self.assertEqual(step(["merge"], checkout, checkout.config, sleep=slept.append), "Merged pull request #12 (merge).")
|
||||
self.assertEqual(sum(slept), 60)
|
||||
|
||||
def requiring_approval(self, origin: str = GITHUB, *decisions: str) -> Checkout:
|
||||
"""A Checkout whose project config sets wait-for-approval, and which reports each of decisions in turn as the review decision."""
|
||||
checkout = Checkout(origin, open=True)
|
||||
@@ -1078,6 +1088,27 @@ class EpicBranch(unittest.TestCase):
|
||||
self.assertEqual(step(["merge"], checkout, checkout.config, parks=True), "Merged pull request #12 (merge).")
|
||||
self.assertNotIn(GH_DECISION, checkout.ran)
|
||||
|
||||
def test_a_recorded_base_that_is_origins_default_branch_leaves_the_pull_request_to_a_person(self):
|
||||
checkout = self.checkout()
|
||||
checkout.chunk_base = "main\n"
|
||||
checkout.answers[(PROJECT_CONFIG, "merge")] = "human\n"
|
||||
done = step(["merge"], checkout, checkout.config)
|
||||
self.assertIn("awaits a person's merge", str(done))
|
||||
self.assertFalse(any("merge" in command[1:4] for command in checkout.acted() if command[0] != "git"), checkout.acted())
|
||||
|
||||
def test_a_branch_whose_base_git_does_not_record_merges_into_the_default_branch(self):
|
||||
self.assertEqual(base_of("item-7", self.unrecorded), Base("main", False))
|
||||
|
||||
def test_a_recorded_base_is_an_epics_working_branch_unless_it_is_the_default_branch(self):
|
||||
self.assertEqual(base_of("item-7", self.recorded("main")), Base("main", False))
|
||||
self.assertEqual(base_of("item-7", self.recorded("ABC-1")), Base("ABC-1", True))
|
||||
|
||||
def unrecorded(self, command: list[str]) -> str | Failure:
|
||||
return Failure("git config: exit 1") if command[:3] == ["git", "config", "--get"] else "origin/main\n"
|
||||
|
||||
def recorded(self, base: str) -> Run:
|
||||
return lambda command: f"{base}\n" if command[:3] == ["git", "config", "--get"] else "origin/main\n"
|
||||
|
||||
def test_merge_fails_naming_both_branches_where_the_forge_merges_the_pull_request_into_another_branch_than_the_checkout_records(self):
|
||||
for origin in (GITHUB, GITEA):
|
||||
with self.subTest(origin):
|
||||
@@ -1185,6 +1216,40 @@ class EpicBranch(unittest.TestCase):
|
||||
self.assertEqual(step(["push"], checkout, checkout.config), "Pushed item-7.")
|
||||
self.assertEqual(checkout.acted(), [PUSH])
|
||||
|
||||
def test_push_waits_for_the_forge_to_show_the_new_head_before_it_asks_for_a_review(self):
|
||||
checkout, slept = self.checkout(), []
|
||||
checkout.listed_heads = [OLD, OLD, OLD, OLD, HEAD]
|
||||
self.assertEqual(step(["push"], checkout, checkout.config, sleep=slept.append), "Pushed item-7, and asked for a review of pull request #12 with “@reviewer review”.")
|
||||
self.assertEqual(slept, [5, 5])
|
||||
|
||||
def test_push_fails_naming_the_pull_request_where_the_forge_still_shows_the_old_head_after_a_minute(self):
|
||||
checkout, slept = self.checkout(), []
|
||||
checkout.listed_heads = [OLD]
|
||||
done = step(["push"], checkout, checkout.config, sleep=slept.append)
|
||||
self.assertIsInstance(done, Failure)
|
||||
for fact in ("pushed item-7", "pull request #12", f"{HEAD[:12]} as", "60 seconds"):
|
||||
self.assertIn(fact, done.reason)
|
||||
self.assertEqual(sum(slept), 60)
|
||||
self.assertNotIn(self.COMMENT_GH, checkout.ran)
|
||||
|
||||
def test_push_asks_for_a_review_where_the_forge_shows_the_new_head_at_the_last_poll(self):
|
||||
checkout, slept = self.checkout(), []
|
||||
checkout.listed_heads = [OLD] * 24 + [HEAD]
|
||||
self.assertIn("asked for a review of pull request #12", str(step(["push"], checkout, checkout.config, sleep=slept.append)))
|
||||
self.assertEqual(sum(slept), 60)
|
||||
|
||||
def test_push_does_not_wait_where_the_pull_request_goes_into_the_default_branch(self):
|
||||
checkout, slept = self.checkout(), []
|
||||
checkout.chunk_base = ""
|
||||
checkout.listed_heads = [OLD]
|
||||
self.assertEqual(step(["push"], checkout, checkout.config, sleep=slept.append), "Pushed item-7.")
|
||||
self.assertEqual(slept, [])
|
||||
|
||||
def test_push_does_not_wait_where_no_pull_request_is_open(self):
|
||||
checkout, slept = self.checkout(open=False), []
|
||||
self.assertEqual(step(["push"], checkout, checkout.config, sleep=slept.append), "Pushed item-7.")
|
||||
self.assertEqual(slept, [])
|
||||
|
||||
def test_a_failed_push_asks_for_no_review(self):
|
||||
checkout = self.checkout()
|
||||
checkout.answers[tuple(PUSH)] = Failure("git push: rejected")
|
||||
|
||||
@@ -8,6 +8,7 @@ from forge.commands import Forge
|
||||
from chunk_preflight.gathered import Gathered, ItemFacts, NamedPath, Ran
|
||||
from text_files.markdown_text import listed, quoted
|
||||
from chunk_preflight.choices import PULLS_LIST
|
||||
from chunk_preflight.indentation import SpaceIndented
|
||||
from plan.release import version
|
||||
|
||||
|
||||
@@ -19,7 +20,7 @@ def render(found: Gathered) -> list[str]:
|
||||
"""One `- ` line per fact, then the item's tagline and detail, the detail of each item that may join its chunk, and what each tool printed."""
|
||||
note = [f"- {found.note}"] if found.note else []
|
||||
unseen = [f"- {UNSEEN_RELEASES}"] if found.plan_outside else []
|
||||
head = [*note, f"- {last_release(found.default, found.cut)}", *unseen, *merge_lines(found)]
|
||||
head = [*note, f"- {last_release(found.default, found.cut)}", *unseen, *merge_lines(found), *indentation_lines(found.indentation)]
|
||||
paths = f"- The project's config puts its files and plan at: {'; '.join(f'{setting} {path}' for setting, path in found.places.items())}."
|
||||
texts = f"- The project's config sets: {'; '.join(f'{setting} {text}' for setting, text in found.texts.items())}."
|
||||
if isinstance(found.item, NoItem):
|
||||
@@ -38,6 +39,15 @@ def merge_lines(found: Gathered) -> list[str]:
|
||||
return [*left, *over, *unread]
|
||||
|
||||
|
||||
def indentation_lines(found: SpaceIndented | Failure | None) -> list[str]:
|
||||
"""The fact about indentation, where the project's code is space-indented and no setting sets the indent, else why that cannot be read. It reports only and never fails the run, since a client's repo belongs to its team."""
|
||||
if isinstance(found, Failure):
|
||||
return [f"- Whether the project's code is space-indented cannot be read: {found.reason}"]
|
||||
if found is None:
|
||||
return []
|
||||
return [f"- The project's code is space-indented ({found.spaced} lines against {found.tabbed} with tabs), and neither an `.editorconfig` with `indent_style` nor a formatter setting (`rustfmt.toml` `hard_tabs`, Prettier `useTabs`, Biome `indentStyle`) sets the indent. The technical principles indent with hard tabs unless a setting a tool reads, plus a decision in the project's decision log that names the reason, overrides that. Don't reindent in a chunk with another purpose. Where the plan holds no item for either way out, file one: convert the code to tabs, or record the override in `.editorconfig` and a decision."]
|
||||
|
||||
|
||||
def last_release(default: str, release: LastCut) -> str:
|
||||
if isinstance(release.tag, Failure):
|
||||
return f"Last version cut: cannot be read: {release.tag.reason}"
|
||||
|
||||
@@ -6,6 +6,7 @@ from failure import Failure
|
||||
from forge.commands import Forge
|
||||
from release_plan.release_standing import LastCut
|
||||
from release_plan.next_chunk import NextChunk, NoItem
|
||||
from chunk_preflight.indentation import SpaceIndented
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@@ -75,3 +76,5 @@ class Gathered:
|
||||
merges_unread: Failure | None = None
|
||||
# The worktrees `chunk-pr clean` is still to remove.
|
||||
left: tuple[LeftWorktree, ...] = ()
|
||||
# The line counts of the project's code where it is space-indented and no setting sets the indent, or why they cannot be read; None where it is not.
|
||||
indentation: SpaceIndented | Failure | None = None
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
"""Whether a project's code is space-indented where no tool setting sets the indent.
|
||||
|
||||
The technical principles indent with hard tabs by default, and let a setting a tool reads override that. Code that is mostly space-indented, with no such setting, reads as a first session's habit that later sessions followed, not as a choice."""
|
||||
import dataclasses
|
||||
import os
|
||||
import pathlib
|
||||
import re
|
||||
|
||||
from failure import Failure
|
||||
from git_cli.git_repo import git
|
||||
|
||||
# Files of common programming languages, by extension. The check skips Markdown, JSON and YAML, which are prose or data.
|
||||
CODE = re.compile(r".*\.(py|js|mjs|cjs|jsx|ts|tsx|rs|go|php|java|kt|kts|scala|rb|c|h|cc|cpp|hpp|cs|swift|sh|bash|lua|ex|exs|dart|vue|svelte)", re.IGNORECASE)
|
||||
# Committed copies of other people's code follow their authors' style.
|
||||
VENDORED = re.compile(r"(^|/)(vendor|node_modules|third_party)/")
|
||||
# The key that, present in a file of that name, means the project sets its indent, whatever the key's value. Prettier also reads `package.json`.
|
||||
SETTINGS = (
|
||||
(re.compile(r"\.editorconfig"), "indent_style"),
|
||||
(re.compile(r"\.?rustfmt\.toml"), "hard_tabs"),
|
||||
(re.compile(r"\.prettierrc(\.\w+)?|prettier\.config\.\w+|package\.json"), "useTabs"),
|
||||
(re.compile(r"biome\.jsonc?"), "indentStyle"),
|
||||
)
|
||||
# Two spaces is the narrowest space indent; a lone leading space aligns a comment's continuation.
|
||||
SPACED_LINE = re.compile(r"^ {2,}\S", re.MULTILINE)
|
||||
TABBED_LINE = re.compile(r"^\t+\S", re.MULTILINE)
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class SpaceIndented:
|
||||
"""Lines of tracked code that start with spaces, and lines that start with tabs."""
|
||||
spaced: int
|
||||
tabbed: int
|
||||
|
||||
|
||||
def space_indented(base: pathlib.Path, timeout: float | None = None) -> SpaceIndented | Failure | None:
|
||||
"""The line counts of the tracked code under base, where it has more space-indented than tab-indented lines and no tracked file holds an indent key; else None. A Failure where git cannot list the files or a file cannot be read."""
|
||||
tracked = git("ls-files", "-z", cwd=str(base), timeout=timeout, errors="replace")
|
||||
if isinstance(tracked, Failure):
|
||||
return tracked
|
||||
spaced = tabbed = 0
|
||||
for name in filter(None, tracked.split("\0")):
|
||||
if VENDORED.search(name):
|
||||
continue
|
||||
code = CODE.fullmatch(name)
|
||||
key = next((key for pattern, key in SETTINGS if pattern.fullmatch(name.rsplit("/", 1)[-1])), None)
|
||||
path = base / name
|
||||
if not (code or key) or not os.path.isfile(path):
|
||||
continue
|
||||
try:
|
||||
text = path.read_text(encoding="utf-8", errors="replace")
|
||||
except OSError as failure:
|
||||
return Failure(f"{name}: {failure}")
|
||||
if key and key in text:
|
||||
return None
|
||||
if code:
|
||||
spaced += len(SPACED_LINE.findall(text))
|
||||
tabbed += len(TABBED_LINE.findall(text))
|
||||
return SpaceIndented(spaced, tabbed) if spaced > tabbed else None
|
||||
@@ -21,6 +21,12 @@ and prints that the release reviews and the cuts are the human's to call. It pri
|
||||
finished on the branch of an open pull request that is not a draft, where the checkout holds
|
||||
the plan. Where no item of the release can start and one awaits such a merge, it names those
|
||||
pull requests and says the working loop stops there;
|
||||
- where the project's tracked code (files of common programming languages, by extension; not
|
||||
Markdown, JSON or YAML, nor anything under vendor/, node_modules/ or third_party/) has more
|
||||
space-indented than tab-indented lines, and neither an `.editorconfig` with `indent_style` nor a
|
||||
formatter setting (`rustfmt.toml` `hard_tabs`, Prettier `useTabs`, Biome `indentStyle`) sets the
|
||||
indent, one line naming the technical principles' hard-tabs default and the two ways out. It
|
||||
reports only, and never fails the run;
|
||||
- the next release and its first item that does not wait, the item loop-claude routes on, with its L
|
||||
and E + I; with --item <ID>, the plan item of that ID instead, which loop-claude names in a window
|
||||
named for an item. An item waits while it is marked question, while an item still in todo.md
|
||||
@@ -101,6 +107,7 @@ from release_plan.next_chunk import NextChunk, NoItem, plan_name, planned
|
||||
from release_plan.release_standing import project_plan
|
||||
from project_config.settings import ProjectConfig
|
||||
from chunk_preflight.choices import pulls_command, worktree_add, worktree_on, worktrees
|
||||
from chunk_preflight.indentation import space_indented
|
||||
from project_config import templates
|
||||
|
||||
BIN = pathlib.Path(__file__).resolve().parents[1]
|
||||
@@ -165,7 +172,7 @@ def preflight(root: pathlib.Path, timeout: float, make: bool, item_id: int | Non
|
||||
item = plan if isinstance(plan, NoItem) else item_facts(root, ref, plan, timeout, make, epic_branch_of(config))
|
||||
# A `checkout:` path lands in the worktree the chunk works in.
|
||||
made = located(str(item.worktree.path), pathlib.Path.home()) if isinstance(item, ItemFacts) and isinstance(item.worktree, Worktree) else config
|
||||
return render(Gathered(ref, note, held.cut, item, plan_name(ref, outside), (config if isinstance(made, Failure) else made).places, outside is not None, config.texts, merges_unread=held.merges_unread, left=left_worktrees(root, forge_run) if config.merge == "human" else ()))
|
||||
return render(Gathered(ref, note, held.cut, item, plan_name(ref, outside), (config if isinstance(made, Failure) else made).places, outside is not None, config.texts, merges_unread=held.merges_unread, left=left_worktrees(root, forge_run) if config.merge == "human" else (), indentation=space_indented(item.worktree.path if isinstance(item, ItemFacts) and isinstance(item.worktree, Worktree) else root, timeout)))
|
||||
|
||||
|
||||
def epic_branch_of(config: ProjectConfig) -> str | None | Failure:
|
||||
|
||||
@@ -23,6 +23,7 @@ from release_plan.awaiting_merge import marked
|
||||
from release_plan import next_chunk
|
||||
from chunk_preflight.facts import open_pulls, render
|
||||
from plan_store.todo_md import plan_of
|
||||
from chunk_preflight.indentation import SpaceIndented
|
||||
from chunk_preflight.choices import worktree_add, worktree_on, worktrees
|
||||
from project_config.doubles import write_config
|
||||
|
||||
@@ -801,6 +802,44 @@ class Running(unittest.TestCase):
|
||||
self.assertIsNone(line_count(folder))
|
||||
|
||||
|
||||
class IndentationFact(unittest.TestCase):
|
||||
def said(self, indentation):
|
||||
found = dataclasses.replace(gathered(item_facts()), indentation=indentation)
|
||||
return [line for line in render(found) if "indent" in line]
|
||||
|
||||
def test_names_the_counts_the_principle_and_the_two_ways_out(self):
|
||||
(line,) = self.said(SpaceIndented(spaced=120, tabbed=3))
|
||||
self.assertIn("space-indented (120 lines against 3 with tabs)", line)
|
||||
self.assertIn("The technical principles indent with hard tabs", line)
|
||||
self.assertIn("file one: convert the code to tabs, or record the override in `.editorconfig` and a decision", line)
|
||||
|
||||
def test_says_nothing_where_the_code_is_not_space_indented_and_why_where_it_cannot_be_read(self):
|
||||
self.assertEqual(self.said(None), [])
|
||||
self.assertEqual(self.said(Failure("cannot read a.py: denied")), ["- Whether the project's code is space-indented cannot be read: cannot read a.py: denied"])
|
||||
|
||||
def test_prints_it_from_a_checkout_of_spaced_code_and_only_then(self):
|
||||
tabbed = Repo(self)
|
||||
self.assertNotIn("space-indented", tabbed.preflight().stdout)
|
||||
spaced = Repo(self)
|
||||
spaced.write(spaced.root, "src/app.py", "def run():\n if True:\n return 1\n")
|
||||
spaced.commit(spaced.root, "spaces")
|
||||
done = spaced.preflight()
|
||||
self.assertEqual(done.returncode, 0, done.stderr)
|
||||
self.assertIn("- The project's code is space-indented (2 lines against 0 with tabs)", done.stdout)
|
||||
spaced.write(spaced.root, ".editorconfig", "[*]\nindent_style = space\n")
|
||||
spaced.commit(spaced.root, "setting")
|
||||
self.assertNotIn("space-indented", spaced.preflight().stdout)
|
||||
|
||||
def test_reads_the_item_worktree_made_off_origins_default_branch_not_the_checkout(self):
|
||||
repo = Repo(self)
|
||||
repo.write(repo.root, "src/app.py", "def run():\n if True:\n return 1\n")
|
||||
repo.commit(repo.root, "spaces, not pushed")
|
||||
self.assertIn("space-indented", repo.preflight().stdout)
|
||||
done = repo.preflight("--worktree")
|
||||
self.assertEqual(done.returncode, 0, done.stderr)
|
||||
self.assertNotIn("space-indented", done.stdout, "the worktree holds origin/main, whose code is indented with tabs")
|
||||
|
||||
|
||||
class BesideTest(unittest.TestCase):
|
||||
"""The fact that names the items that may start chunks beside the next one."""
|
||||
# Items 3 and 4 touch other parts of one file, and item 6 touches what item 3 does.
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from test_env import assert_not_root, isolated_env
|
||||
from failure import Failure
|
||||
from chunk_preflight.indentation import space_indented, SpaceIndented
|
||||
|
||||
TABBED = "def run():\n\tif True:\n\t\treturn 1\n"
|
||||
SPACED = "def run():\n if True:\n return 1\n"
|
||||
|
||||
|
||||
class SpaceIndentation(unittest.TestCase):
|
||||
"""Each case is a fake checkout whose tracked files are those given."""
|
||||
|
||||
def checkout(self, **files):
|
||||
temp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(temp.cleanup)
|
||||
root = pathlib.Path(os.path.realpath(temp.name))
|
||||
for name, text in files.items():
|
||||
path = root / name.replace("__", "/")
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text(text)
|
||||
subprocess.run(["git", "init", "--quiet"], cwd=root, check=True, env=isolated_env())
|
||||
subprocess.run(["git", "add", "-A"], cwd=root, check=True, env=isolated_env())
|
||||
return root
|
||||
|
||||
def test_stays_silent_for_code_indented_with_tabs(self):
|
||||
self.assertIsNone(space_indented(self.checkout(**{"app.py": TABBED})))
|
||||
|
||||
def test_counts_the_lines_of_code_indented_with_spaces_where_no_tool_setting_says_so(self):
|
||||
root = self.checkout(**{"app.py": SPACED, "lib__more.rs": SPACED, "web__page.ts": TABBED, "README.md": SPACED})
|
||||
self.assertEqual(space_indented(root), SpaceIndented(spaced=4, tabbed=2))
|
||||
|
||||
def test_stays_silent_where_a_tool_reads_a_setting_that_says_so(self):
|
||||
settings = {
|
||||
"editorconfig": (".editorconfig", "[*]\nindent_style = space\n"),
|
||||
"rustfmt": ("rustfmt.toml", "hard_tabs = false\n"),
|
||||
"prettier": (".prettierrc.json", '{"useTabs": false}\n'),
|
||||
"prettier in package.json": ("package.json", '{"prettier": {"useTabs": false}}\n'),
|
||||
"biome": ("biome.jsonc", '{"formatter": {"indentStyle": "space"}}\n'),
|
||||
"a nested editorconfig": ("src__.editorconfig", "indent_style = space\n"),
|
||||
"an editorconfig two folders down": ("src__web__.editorconfig", "indent_style = space\n"),
|
||||
}
|
||||
for label, (name, text) in settings.items():
|
||||
with self.subTest(label):
|
||||
self.assertIsNone(space_indented(self.checkout(**{"app.py": SPACED, name: text})))
|
||||
|
||||
def test_reports_a_file_that_names_no_such_setting(self):
|
||||
for name, text in ((".editorconfig", "[*]\nend_of_line = lf\n"), ("package.json", '{"name": "x"}\n'), ("notes.txt", "indent_style = space\n")):
|
||||
with self.subTest(name):
|
||||
self.assertIsInstance(space_indented(self.checkout(**{"app.py": SPACED, name: text})), SpaceIndented)
|
||||
|
||||
def test_stays_silent_for_a_repo_without_code(self):
|
||||
self.assertIsNone(space_indented(self.checkout(**{"README.md": SPACED, "data.json": SPACED, "ci.yml": SPACED})))
|
||||
|
||||
def test_leaves_out_vendored_code_and_the_settings_files_it_holds(self):
|
||||
self.assertIsNone(space_indented(self.checkout(**{"vendor__lib.py": SPACED, "web__node_modules__x__index.js": SPACED})))
|
||||
vendored = self.checkout(**{"z.py": SPACED, "vendor__lib__.editorconfig": "indent_style = space\n", "third_party__x__package.json": '{"useTabs": false}'})
|
||||
self.assertEqual(space_indented(vendored), SpaceIndented(spaced=2, tabbed=0))
|
||||
|
||||
def test_reads_a_checkout_with_a_file_name_that_is_not_utf8(self):
|
||||
root = self.checkout(**{"a.py": SPACED})
|
||||
(root / os.fsdecode(b"caf\xe9.py")).write_text(SPACED)
|
||||
subprocess.run(["git", "add", "-A"], cwd=root, check=True, env=isolated_env())
|
||||
self.assertEqual(space_indented(root), SpaceIndented(spaced=2, tabbed=0))
|
||||
|
||||
def test_stays_silent_where_tabs_are_as_many_as_spaces(self):
|
||||
self.assertIsNone(space_indented(self.checkout(**{"a.py": SPACED, "b.py": TABBED})))
|
||||
|
||||
def test_sums_the_tabbed_lines_of_every_file(self):
|
||||
self.assertIsNone(space_indented(self.checkout(**{"a.py": SPACED, "b.py": SPACED, "c.py": TABBED, "d.py": TABBED, "e.py": TABBED})))
|
||||
|
||||
def test_skips_a_tracked_file_that_is_gone_from_the_disk(self):
|
||||
root = self.checkout(**{"a.py": SPACED, "gone.py": SPACED})
|
||||
(root / "gone.py").unlink()
|
||||
self.assertEqual(space_indented(root), SpaceIndented(spaced=2, tabbed=0))
|
||||
|
||||
def test_reads_a_file_that_is_not_utf8(self):
|
||||
root = self.checkout(**{"a.py": ""})
|
||||
(root / "a.py").write_bytes(b"\xff\xfe\n x\n y\n")
|
||||
self.assertEqual(space_indented(root), SpaceIndented(spaced=2, tabbed=0))
|
||||
|
||||
def test_names_a_file_it_cannot_read(self):
|
||||
assert_not_root(self)
|
||||
root = self.checkout(**{"a.py": SPACED})
|
||||
(root / "a.py").chmod(0)
|
||||
self.addCleanup((root / "a.py").chmod, 0o644)
|
||||
failed = space_indented(root)
|
||||
self.assertIsInstance(failed, Failure)
|
||||
self.assertTrue(failed.reason.startswith("a.py: "), failed.reason)
|
||||
|
||||
def test_says_why_it_cannot_read_a_checkout(self):
|
||||
self.assertIsInstance(space_indented(pathlib.Path("/nonexistent-checkout")), Failure)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
+8
-3
@@ -22,26 +22,31 @@ def open_pull(forge: Forge, branch: str, head: str, run: Run) -> str | None | Fa
|
||||
return pull_at(forge, branch, head, "open", run)
|
||||
|
||||
|
||||
def pull_from(forge: Forge, branch: str, run: Run) -> str | None | Failure:
|
||||
"""The number of the open pull request from origin's own branch, whatever its head is; None where there is none."""
|
||||
return pull_at(forge, branch, None, "open", run)
|
||||
|
||||
|
||||
def merged_pull(forge: Forge, branch: str, head: str, run: Run) -> str | None | Failure:
|
||||
"""The number of the merged pull request from origin's own branch whose head was head; None where there is none. A rebase or a squash merge counts: the pull request keeps the head it had."""
|
||||
return pull_at(forge, branch, head, "merged", run)
|
||||
|
||||
|
||||
def pull_at(forge: Forge, branch: str, head: str, state: typing.Literal["open", "merged"], run: Run) -> str | None | Failure:
|
||||
def pull_at(forge: Forge, branch: str, head: str | None, state: typing.Literal["open", "merged"], run: Run) -> str | None | Failure:
|
||||
if forge == "gh":
|
||||
# gh lists the open pull requests unless told another state.
|
||||
listed = run(["gh", "pr", "list", "--head", branch, *(["--state", "merged"] if state == "merged" else []), "--json", "number,headRefOid,isCrossRepository", "--template", "{{range .}}{{.number}}\t{{.headRefOid}}\t{{.isCrossRepository}}\n{{end}}"])
|
||||
if isinstance(listed, Failure):
|
||||
return listed
|
||||
rows = [line.split("\t") for line in listed.splitlines()]
|
||||
return next((row[0] for row in rows if row[1:] == [head, "false"]), None)
|
||||
return next((row[0] for row in rows if len(row) == 3 and row[2] == "false" and head in (None, row[1])), None)
|
||||
# Gitea lists at most 50 a page; the pull request sought is among the newest. Gitea has no merged state: a merged pull request is a closed one marked merged.
|
||||
pulls = gitea(run, f"repos/{{owner}}/{{repo}}/pulls?state={'open' if state == 'open' else 'closed'}&limit=50")
|
||||
if isinstance(pulls, Failure):
|
||||
return pulls
|
||||
try:
|
||||
# Match the label, not the ref: once origin deletes a merged branch, Gitea reports its ref as refs/pull/<N>/head.
|
||||
return next((str(pull["number"]) for pull in pulls if pull["head"]["label"] == branch and pull["head"]["sha"] == head and pull["head"]["repo"]["full_name"] == pull["base"]["repo"]["full_name"] and (state == "open" or pull["merged"] is True)), None)
|
||||
return next((str(pull["number"]) for pull in pulls if pull["head"]["label"] == branch and (head is None or pull["head"]["sha"] == head) and pull["head"]["repo"]["full_name"] == pull["base"]["repo"]["full_name"] and (state == "open" or pull["merged"] is True)), None)
|
||||
except (KeyError, TypeError):
|
||||
return Failure(f"tea api listed pull requests in a shape that can't be read: {str(pulls)[:200]}")
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import unittest
|
||||
|
||||
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
||||
|
||||
from forge.pulls import BEHIND, CheckFailed, checks_now, checks_passed, CONFLICTS, open_pull, other_base, Pending, POLL_SECONDS, ready_pulls, ReadyPull, required_checks, unmergeable, WAIT_SECONDS
|
||||
from forge.pulls import BEHIND, CheckFailed, checks_now, checks_passed, CONFLICTS, open_pull, other_base, Pending, POLL_SECONDS, pull_from, ready_pulls, ReadyPull, required_checks, unmergeable, WAIT_SECONDS
|
||||
from failure import Failure
|
||||
from forge.commands import forge_of, gitea, runner, url_beside
|
||||
|
||||
@@ -46,6 +46,14 @@ class Gitea(unittest.TestCase):
|
||||
|
||||
|
||||
class OpenPull(unittest.TestCase):
|
||||
def test_finds_the_open_pull_request_from_a_branch_whatever_its_head_is(self):
|
||||
gh = "12\told\tfalse\n13\tfork\ttrue\n"
|
||||
tea = json.dumps([{"number": 14, "head": {"label": "item-3", "sha": "old", "repo": {"full_name": "o/r"}}, "base": {"repo": {"full_name": "o/r"}}}, {"number": 15, "head": {"label": "item-3", "sha": "fork", "repo": {"full_name": "f/r"}}, "base": {"repo": {"full_name": "o/r"}}}])
|
||||
self.assertEqual(pull_from("gh", "item-3", lambda command: gh), "12")
|
||||
self.assertEqual(pull_from("tea", "item-3", lambda command: tea), "14")
|
||||
self.assertEqual(open_pull("gh", "item-3", "new", lambda command: gh), None)
|
||||
self.assertIsNone(pull_from("gh", "item-3", lambda command: "13\tfork\ttrue\n"))
|
||||
|
||||
def test_fails_quoting_the_first_200_characters_where_tea_lists_pull_requests_in_another_shape(self):
|
||||
self.assertEqual(open_pull("tea", "item-3", "abc", lambda command: LONG).reason, f"tea api listed pull requests in a shape that can't be read: {LONG[:200]}")
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
- Enumerate the cases that can go wrong and return them as explicit results (e.g. a result DTO with an optional error), so failure is part of the signature instead of a hidden second channel.
|
||||
- try/catch lives only at the edges, wrapped tightly around the call that can actually throw (DB, HTTP, filesystem), converting the exception into an explicit result right there. Pure functions and core logic never throw or catch for control flow.
|
||||
- A function that both returns a result and throws for some inputs has two error channels; collapse to one. Throw only for a truly unrecoverable state.
|
||||
- Where code branches on why a call failed, it reads a status code, an exit code the tool documents, or a typed error. It reads message text only where the tool documents that text as unique to one cause, and treats every other failure as unknown, which stops the run.
|
||||
* Commands and Queries Separation (CQS)-ish
|
||||
- Queries must never modify data, commands may only return data that is the result of their change.
|
||||
* Copy important contextual information on buisness transactions and equal data, instead of referencing it.
|
||||
@@ -117,4 +118,6 @@
|
||||
- A Python script with a `#!/usr/bin/env python3` shebang runs identically across systems where shell dialects and builtins differ.
|
||||
- Read config (credentials, hosts, paths) from CLI params or env vars, never hardcoded.
|
||||
* Indent with hard tabs by default.
|
||||
- A project's own settings win: `.editorconfig`, linter/formatter config (Prettier, `rustfmt.toml`, …), or the surrounding file's existing indentation.
|
||||
- Overriding it takes two things: a setting a tool reads (`.editorconfig` or a formatter's config, such as Prettier, `rustfmt.toml` or Biome) and a decision in the decision log that names the reason. A prose rule in `AGENTS.md`, or the existing files' habit, doesn't override it.
|
||||
- A format that forbids tabs, such as YAML, and output a spec fixes, such as a JSON example it prints, are outside the rule.
|
||||
- A file already indented with spaces keeps them until the project converts it or records the override, so no file mixes the two. `chunk-preflight` reports a project whose code is mostly indented with spaces where `.editorconfig`, `rustfmt.toml`, Prettier and Biome set nothing about it.
|
||||
|
||||
@@ -14,11 +14,7 @@
|
||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||
| 477 | 0.17.0 | | question | **Rewrite `## Goals` and `## Audience` for a setup others install and run apart from their own `~/.claude`.** | 1 | 1 | 2 | 2 | 2 | | 0.0 |
|
||||
| 478 | 0.17.0 | | question | **Name the project, its repo and its two commands, today proposed as `do-release` and `do-epic`.** | 1 | 1 | 2 | 2 | 1 | | 0.0 |
|
||||
| 548 | 0.17.0 | | defect | **Treat a chunk whose recorded base is origin's default branch as merging into that branch, so `chunk-pr merge` honours `merge = "human"` and `wait-for-approval` there.** | 1 | 2 | 2 | 3 | 1 | 1.1 by 3 | 1.3 |
|
||||
| 552 | 0.17.0 | | defect | **Ask for a review on `chunk-pr push` once the forge shows the pushed head on the pull request, and fail where no open pull request takes it, so a push never skips the review request without saying so.** | 1 | 2 | 2 | 3 | 2 | 1.1 by 3 | 1.2 |
|
||||
| 542 | 0.17.0 | | | **Make chunk-preflight report a project whose code is space-indented with no `.editorconfig` or formatter setting that says so, and narrow the tabs principle to explicit overrides.** | 2 | 2 | 3 | 5 | 4 | 1.1 by 4 | 1.2 |
|
||||
| 523 | 0.17.0 | | | **Make the security pass and stability-reviewer check that a new secret's docs name its scope and its reach, such as the other repositories its account can use.** | 1 | 1 | 2 | 2 | 1 | 1.1 by 2 | 0.9 |
|
||||
| 547 | 0.17.0 | | | **Add a technical principle: tell a failure's cause from a status code or a typed error, never from a tool's message text unless the tool documents that text as unique to the cause.** | 1 | 2 | 2 | 3 | 1 | 1.1 by 2 | 0.9 |
|
||||
| 541 | 0.17.0 | | | **Find a Gitea pull request by its branch and head however many pull requests are newer, so `chunk-pr clean`, `chunk-pr merge` and `chunk-preflight` see an older one.** | 2 | 2 | 3 | 5 | 2 | 1 by 2 | 0.8 |
|
||||
| 545 | 0.17.0 | | | **Have chunk-preflight name each next-release item with no `Touches:` list while others wait, and have loop-claude launch a subagent that writes the lists before it starts the next chunk.** | 3 | 2 | 3 | 6 | 6 | 1.1 by 4 | 0.6 |
|
||||
| 539 | 0.17.0 | | | **Leave out of a `task-bench` fix a change Haiku makes to a Rust test kept in a file of its own.** | 2 | 2 | 1 | 3 | 3 | 1.1 by 1 | 0.4 |
|
||||
@@ -121,61 +117,10 @@ Part of the standalone-install plan lilleman approved on 2026-11-20. `do-release
|
||||
|
||||
Part of the standalone-install plan lilleman approved on 2026-11-20. Later items say `do-release` and `do-epic` for the names this item picks. The names set the install folders, such as `~/.config/do-release/`, so items 482, 485 and 496, and every item they block, wait for them.
|
||||
|
||||
### 548. Treat a chunk whose recorded base is origin's default branch as merging into that branch, so `chunk-pr merge` honours `merge = "human"` and `wait-for-approval` there.
|
||||
|
||||
`base_of` in `bin/chunk_pr/main.py` returns `to_epic=True` for any branch whose `branch.<branch>.chunk-base` is set in git's config. In a project that sets `epic-branch`, a chunk that goes into the default branch instead of the epic's working branch can still record `chunk-base = main`. Then `chunk-pr merge` skips `merge = "human"` and `wait-for-approval` and runs `gh pr merge` into `main`. In one chunk, only the repo's branch protection stopped that merge. A repo without protection would have merged into its default branch with no person involved.
|
||||
|
||||
The fix: where the recorded base equals origin's default branch, `base_of` returns `Base(default, False)`. Write the test first: a checkout that records `chunk-base` as the default branch under `merge = "human"` leaves the pull request unmerged.
|
||||
|
||||
Touches:
|
||||
|
||||
- `bin/chunk_pr/main.py`: `base_of` (small)
|
||||
- `bin/chunk_pr/test_chunk_pr.py`
|
||||
|
||||
### 552. Ask for a review on `chunk-pr push` once the forge shows the pushed head on the pull request, and fail where no open pull request takes it, so a push never skips the review request without saying so.
|
||||
|
||||
`pushed` finds the pull request by the head it just pushed, through `open_pull`. Right after the push, GitHub may still list the pull request's old head. Then `open_pull` returns None, and `push` prints only `Pushed <branch>.` with no review request and no warning. That happened on a pull request into an epic's working branch: the external auto-reviewer reviewed only once someone posted the configured comment by hand, about twenty minutes later.
|
||||
|
||||
Fix: after the push, wait a bounded time for an open pull request whose head is the pushed commit, polling as `forge.pulls` already does for checks. Where a pull request from the branch is open but never shows the new head, fail and name it. Where none is open at all, keep printing `Pushed <branch>.`, since `push` before `open` is normal.
|
||||
|
||||
Touches:
|
||||
- `bin/chunk_pr/main.py`: `pushed`
|
||||
- `bin/chunk_pr/test_chunk_pr.py`
|
||||
|
||||
### 542. Make chunk-preflight report a project whose code is space-indented with no `.editorconfig` or formatter setting that says so, and narrow the tabs principle to explicit overrides.
|
||||
|
||||
`principles/technical-principles.md` says "Indent with hard tabs by default. A project's own settings win: `.editorconfig`, linter/formatter config, or the surrounding file's existing indentation." The last clause lets a first session set spaces and every later session follow it, and nothing checks that anyone chose it. adf-codec's `AGENTS.md` has said "Two-space indent" since its first commit, with no reason, and 177 code files, 14,500 indented lines, followed it. A survey of the projects on this machine on 2026-11-26 found the same in plainpages, scheduler (`rustfmt.toml` doesn't set `hard_tabs`), oss-opportunity-research, secondhand-watch and playwright-for-agents. Only plainpages-plugin-fastjira says so in an `.editorconfig`.
|
||||
|
||||
Two changes, the tool first:
|
||||
|
||||
- `chunk-preflight` prints one fact where the project's tracked code (the files its language tooling covers, not Markdown, JSON or YAML) has more space-indented than tab-indented lines, and neither an `.editorconfig` with `indent_style` nor a formatter setting (`rustfmt.toml` `hard_tabs`, Prettier `useTabs`, Biome `indentStyle`) says so. The fact names the principle and the two ways out: convert to tabs, or record the override in `.editorconfig` and a decision. It reports and never fails, since a client's repo belongs to its team.
|
||||
- The principle's override clause counts only a setting a tool reads, `.editorconfig` or a formatter's config, plus a decision in `docs/decisions.md` that names the reason. A prose rule in `AGENTS.md`, or the existing files' habit, no longer overrides it. Output formats a spec fixes, such as a spelling's JSON, are outside the rule.
|
||||
|
||||
Test it with a fake checkout per case: tabs, spaces with a setting, spaces without one, and a repo of Markdown only.
|
||||
|
||||
Touches:
|
||||
|
||||
- `bin/chunk_preflight/facts.py`
|
||||
- `bin/chunk_preflight/gathered.py`
|
||||
- `bin/chunk_preflight/test_chunk_preflight.py`
|
||||
- `principles/technical-principles.md`: `* Indent with hard tabs by default.` (small)
|
||||
|
||||
### 523. Make the security pass and stability-reviewer check that a new secret's docs name its scope and its reach, such as the other repositories its account can use.
|
||||
|
||||
An outside reviewer found it on a client project's PR that added a secret: a Gitea token documented as able to run Actions on one repository, "and nothing wider". The token reaches every repository its owning account can, so the docs had to require a dedicated account with access to that repository only. Neither `/security-review` nor stability-reviewer raised it. Where a change adds a secret or a token, ask each to check that the doc beside it states what the credential can reach, not only what the change uses it for.
|
||||
|
||||
### 547. Add a technical principle: tell a failure's cause from a status code or a typed error, never from a tool's message text unless the tool documents that text as unique to the cause.
|
||||
|
||||
An outside auto-reviewer found a fault that our passes missed. A script told a missing container image apart from one it couldn't read by matching the text a CLI printed on stderr. Older versions of that CLI print the same text for a missing image, a refused credential and a failed request. So the script read "no access" as "missing" and went on as if the image didn't exist. The stability and security passes both read the code and took the message at its word.
|
||||
|
||||
The fix asked the registry's HTTP API for the status instead: 404 is missing, and any other failure stops the run. The principle makes that the rule. Where code branches on why a call failed, it reads a status code, an exit code the tool documents, or a typed error. It reads message text only where the tool documents that text as unique to one cause, and it treats every other failure as unknown, which stops the run rather than guessing.
|
||||
|
||||
No deterministic check fits: a linter can't tell whether a string match on output decides a failure's cause. Reviewers apply the principles, so a principle is the first place that fits.
|
||||
|
||||
Touches:
|
||||
|
||||
- `principles/technical-principles.md`: `Handle errors explicitly, as values — avoid the exception path.` (small)
|
||||
|
||||
### 541. Find a Gitea pull request by its branch and head however many pull requests are newer, so `chunk-pr clean`, `chunk-pr merge` and `chunk-preflight` see an older one.
|
||||
|
||||
Today `pull_at` in `bin/forge/pulls.py` reads only Gitea's first page of 50 pull requests, open or closed, and looks for the branch among them. A pull request with 50 newer ones in that state is missed. PR #652 here merged after 50+ newer PRs had closed, and `chunk-pr clean` then said "no merged pull request from filing-prose-reentry", leaving the worktree and branch to remove by hand. The same lookup serves `open_pull`, so `ready` and `merge` miss an old open one too, and `chunk-preflight` misses a merged chunk's worktree.
|
||||
|
||||
Reference in New Issue
Block a user