Keep configs in ~/.config/build-release/ and tool state in ~/.local/state/build-release/, under XDG_* where set
CI / tests (pull_request) Successful in 6m34s

This commit is contained in:
2026-12-03 18:56:28 +01:00
parent 20c83f861f
commit 1ca2c8efe0
142 changed files with 1095 additions and 933 deletions
+21 -20
View File
@@ -15,8 +15,8 @@ stderr; the other four exit 1.
The history is docs/comprehension-history.md in the checkout.
review-folder makes the chunk's review folder, where each reviewer writes its report, and prints its
path: ~/.local/state/larv-review/ followed by the worktree's path relative to ~, or to / outside it.
It leaves ~/.local/state/larv-review readable by you alone.
path: ~/.local/state/build-release/larv-review/ followed by the worktree's path relative to ~, or to / outside it.
It leaves ~/.local/state/build-release/larv-review readable by you alone.
ruling-base prints the commit a paired ruling reads against, then which of these found it. The last
measured commit is the default branch's newest merged change that adds a paired ruling or a scoring
@@ -165,6 +165,7 @@ when git cannot start, finds no checkout or no default branch, cannot fetch orig
needs-scoring-run, scoring-run-owed or record-scoring, or cannot read or write the history, todo.md, the review
folder or a file prepare-scoring reads.
"""
import os
import pathlib
import re
import sys
@@ -209,11 +210,11 @@ def are_ids(given: list[str]) -> bool:
def run_needs_scoring_run(given: list[str]) -> Failure | None:
return with_default_branch(lambda default: needs_scoring_run(default, [int(id_) for id_ in given], pathlib.Path.home()), stale_ok=False)
return with_default_branch(lambda default: needs_scoring_run(default, [int(id_) for id_ in given], pathlib.Path.home(), os.environ), stale_ok=False)
def run_record_scoring(given: list[str]) -> Failure | None:
return with_default_branch(lambda default: record_scoring(default, pathlib.Path(given[0]), [int(id_) for id_ in given[1:]], pathlib.Path.home(), time.time(), print, warn), stale_ok=False)
return with_default_branch(lambda default: record_scoring(default, pathlib.Path(given[0]), [int(id_) for id_ in given[1:]], pathlib.Path.home(), os.environ, time.time(), print, warn), stale_ok=False)
def fits_reviewer_header(given: list[str]) -> bool:
@@ -221,23 +222,23 @@ def fits_reviewer_header(given: list[str]) -> bool:
def run_reviewer_header(given: list[str]) -> Failure | None:
return with_default_branch(lambda default: printed(reviewer_header(default, given[0], given[1:] == ["--rerun"], pathlib.Path.home())), stale_ok=True)
return with_default_branch(lambda default: printed(reviewer_header(default, given[0], given[1:] == ["--rerun"], pathlib.Path.home(), os.environ)), stale_ok=True)
# One row per subcommand: main, USAGE and `--help` all read this table.
COMMANDS = {
"review-folder": Command("review-folder", no_arguments, lambda given: make_review_folder()),
"ruling-base": Command("ruling-base", no_arguments, lambda given: with_default_branch(lambda default: show_ruling_base(default, pathlib.Path.home()), stale_ok=False)),
"ruling-base": Command("ruling-base", no_arguments, lambda given: with_default_branch(lambda default: show_ruling_base(default, pathlib.Path.home(), os.environ), stale_ok=False)),
"round-count": Command("round-count", no_arguments, lambda given: with_default_branch(round_count, stale_ok=True)),
"needs-scoring-run": Command("needs-scoring-run [<item ID>...]", are_ids, run_needs_scoring_run, ids_from=0),
"scoring-run-owed": Command("scoring-run-owed", no_arguments, lambda given: with_default_branch(lambda default: owed(default, pathlib.Path.home()), stale_ok=False)),
"record-ruling": Command("record-ruling <votes file>", lambda given: len(given) == 1, lambda given: printed(record_ruling(pathlib.Path(given[0]), pathlib.Path.home(), time.time()))),
"scoring-run-owed": Command("scoring-run-owed", no_arguments, lambda given: with_default_branch(lambda default: owed(default, pathlib.Path.home(), os.environ), stale_ok=False)),
"record-ruling": Command("record-ruling <votes file>", lambda given: len(given) == 1, lambda given: printed(record_ruling(pathlib.Path(given[0]), pathlib.Path.home(), os.environ, time.time()))),
"prepare-scoring": Command("prepare-scoring", no_arguments, lambda given: prepared_scoring()),
"record-scoring": Command("record-scoring <scores file> [<item ID>...]", lambda given: bool(given) and are_ids(given[1:]), run_record_scoring, ids_from=1),
"places": Command("places", no_arguments, lambda given: printed(read_places(pathlib.Path.home()))),
"agreement": Command("agreement", no_arguments, lambda given: printed(read_agreement(pathlib.Path.home()))),
"places": Command("places", no_arguments, lambda given: printed(read_places(pathlib.Path.home(), os.environ))),
"agreement": Command("agreement", no_arguments, lambda given: printed(read_agreement(pathlib.Path.home(), os.environ))),
"reviewer-header": Command("reviewer-header <pass> [--rerun]", fits_reviewer_header, run_reviewer_header),
"round-title": Command("round-title <pass>", lambda given: len(given) == 1 and given[0] in REVIEWERS, lambda given: with_default_branch(lambda default: printed(round_title(default, given[0], pathlib.Path.home())), stale_ok=True)),
"round-title": Command("round-title <pass>", lambda given: len(given) == 1 and given[0] in REVIEWERS, lambda given: with_default_branch(lambda default: printed(round_title(default, given[0], pathlib.Path.home(), os.environ)), stale_ok=True)),
"reviewer-context": Command("reviewer-context", no_arguments, lambda given: printed(hook_reply(sys.stdin.read(), pathlib.Path.home()))),
}
SHAPES = " | ".join(command.shape for command in COMMANDS.values())
@@ -291,22 +292,22 @@ def with_default_branch(command: typing.Callable[[str], Failure | None], stale_o
def prepared_scoring() -> Failure | None:
worktree = top()
return worktree if isinstance(worktree, Failure) else printed(prepare_scoring(worktree, pathlib.Path.home()))
return worktree if isinstance(worktree, Failure) else printed(prepare_scoring(worktree, pathlib.Path.home(), os.environ))
def make_review_folder() -> Failure | None:
worktree = top()
if isinstance(worktree, Failure):
return worktree
folder = made_review_folder(worktree, pathlib.Path.home())
folder = made_review_folder(worktree, pathlib.Path.home(), os.environ)
if isinstance(folder, Failure):
return folder
print(folder)
return None
def show_ruling_base(default: str, home: pathlib.Path) -> Failure | None:
changes = history_changes(default, home)
def show_ruling_base(default: str, home: pathlib.Path, env: typing.Mapping[str, str]) -> Failure | None:
changes = history_changes(default, home, env)
if isinstance(changes, Failure):
return changes
if found := measured_commit(changes):
@@ -320,7 +321,7 @@ def show_ruling_base(default: str, home: pathlib.Path) -> Failure | None:
def round_count(default: str) -> Failure | None:
summaries = branch_summaries(default, pathlib.Path.home())
summaries = branch_summaries(default, pathlib.Path.home(), os.environ)
if isinstance(summaries, Failure):
return summaries
for name, count in round_counts(summaries).items():
@@ -334,15 +335,15 @@ def cap_note(count: int, most: int) -> str:
return f", {'at' if count == most else 'past'} the cap: no more rounds"
def owed(default: str, home: pathlib.Path) -> Failure | None:
unrecorded = owed_scoring_run(default, home, warn)
def owed(default: str, home: pathlib.Path, env: typing.Mapping[str, str]) -> Failure | None:
unrecorded = owed_scoring_run(default, home, env, warn)
if unrecorded is None:
print("No scoring run owed.")
return unrecorded
def needs_scoring_run(default: str, ids: list[int], home: pathlib.Path) -> Failure | None:
reasons = plan_reasons(default, ids, home)
def needs_scoring_run(default: str, ids: list[int], home: pathlib.Path, env: typing.Mapping[str, str]) -> Failure | None:
reasons = plan_reasons(default, ids, home, env)
if isinstance(reasons, Failure):
return reasons
print(f"Scoring run due: the chunk {' and '.join(reasons)}." if reasons else "No scoring run due.")