Measure each chunk by one rule: a merge commit, or a run of commits sharing one commit time
This commit is contained in:
+33
-39
@@ -6,11 +6,12 @@ Run it inside a project checkout or one of its worktrees. It fetches origin, whe
|
||||
that remote, and reads origin's default branch, or else the local main or master; a failed fetch
|
||||
reads origin as last fetched and says so on stderr.
|
||||
|
||||
Git history is the record. A chunk is a merge commit on the default branch's first-parent line
|
||||
whose change removed items from todo.md, and changed more than todo.md and the records below; it
|
||||
shipped those items. Each item's guess is the scores it held in the todo.md of the merge's first
|
||||
parent: L, E, I, R and S. An item scored before L, E and I replaced C holds R and S, and C too where
|
||||
its table also had A, G and Goals. The chunk measures:
|
||||
Git history is the record. The default branch's first-parent line is cut into chunks by one rule: a
|
||||
merge commit is a chunk of its own, and any other commit joins the commit above it when both share a
|
||||
commit time, else starts a chunk. A chunk whose change removed items from todo.md, and changed more
|
||||
than todo.md and the records below, shipped those items. Each item's guess is the scores it held in
|
||||
the todo.md the chunk started from: L, E, I, R and S. An item scored before L, E and I replaced C
|
||||
holds R and S, and C too where its table also had A, G and Goals. The chunk measures:
|
||||
|
||||
- lines changed: lines added plus lines deleted against the first parent, leaving out todo.md and
|
||||
the records tools append to, docs/comprehension-history.md and docs/reading-cost.md;
|
||||
@@ -21,14 +22,12 @@ its table also had A, G and Goals. The chunk measures:
|
||||
such as `Answer stability round 1: 1 🔴, 2 🟡; flag a deleted test`. Unknown where a round title
|
||||
lacks the counts, or the branch has no round.
|
||||
|
||||
After the first-parent line's newest merge commit, where a project merges by rebase or squash, a
|
||||
chunk is instead a run of commits on that line sharing one commit time, as a rebase merge replays a
|
||||
pull request's commits at once; it measures against the commit before its first, whose todo.md
|
||||
holds the guesses, and its titles are its commits'. It is marked `by rebase` where a commit time
|
||||
differs from its author time, and `never replayed` where none does, since a pushed or
|
||||
fast-forwarded commit may be part of a pull request. Two pull requests merged in the same second
|
||||
read as one chunk. Rebase drops a round's commit that changed no file, so such a chunk gives its
|
||||
rounds and findings as lower bounds, `at least`, and the report ends saying all this.
|
||||
A chunk is marked `by rebase` where a commit in it has a committer time apart from its author time,
|
||||
since a rebase replays a pull request's commits at once, and `never replayed` where none does, since
|
||||
a pushed or fast-forwarded commit may be part of a pull request. A merge's titles are its branch's
|
||||
commits'; any other chunk's are its own. Two pull requests merged in the same second read as one
|
||||
chunk. Rebase drops a round's commit that changed no file, so such a chunk gives its rounds and
|
||||
findings as lower bounds, `at least`, and the report ends saying all this.
|
||||
|
||||
Given L, E and I, on the levels ~/.claude/rules/todo-items.md defines, and S, it works out R from
|
||||
L, E and I, as rank_todo.py does, and lists the 5 finished items whose guesses sit closest, closest
|
||||
@@ -37,7 +36,7 @@ scored before L, E and I, the newest first among equals. Each line gives what th
|
||||
measured, which items shipped with it, and its tagline.
|
||||
|
||||
Then the project's anchors, the shipped items its docs/score-anchors.md names for each level of L,
|
||||
E and I, read from the checkout's working tree, each line as above, or that no merge shipped it. A
|
||||
E and I, read from the checkout's working tree, each line as above, or that no chunk shipped it. A
|
||||
file that cannot be read, a row that does not hold a level on its scale and a list of IDs, or a
|
||||
level named twice leaves the anchors out, saying why.
|
||||
|
||||
@@ -132,47 +131,42 @@ def read_anchors() -> Anchors | Failure:
|
||||
|
||||
|
||||
def read_outcomes(default: str) -> list[Outcome] | Failure:
|
||||
"""What each chunk measured: each merge commit on the default branch's first-parent line, and each run of commits after the newest that share one commit time."""
|
||||
"""What each chunk on the default branch's first-parent line measured."""
|
||||
if partial := full_history():
|
||||
return partial
|
||||
merges = git("log", "--first-parent", "--merges", "--format=%H %h %ct", default, "--", "todo.md")
|
||||
if isinstance(merges, Failure):
|
||||
return merges
|
||||
chunks = read_chunks(default)
|
||||
if isinstance(chunks, Failure):
|
||||
return chunks
|
||||
outcomes: list[Outcome] = []
|
||||
for line in merges.splitlines():
|
||||
merge, short, time = line.split()
|
||||
measured = measure(f"{merge}^1", merge, short, utc(int(time)), f"{merge}^1..{merge}^2", "merge")
|
||||
if isinstance(measured, Failure):
|
||||
return measured
|
||||
outcomes += measured
|
||||
replays = read_replays(default)
|
||||
if isinstance(replays, Failure):
|
||||
return replays
|
||||
for first, last, committed, landed in replays:
|
||||
label = f"{first}^..{last}" if first != last else first
|
||||
measured = measure(f"{first}^1", last, label, utc(committed), f"{first}^1..{last}", landed)
|
||||
for first, last, committed, landed in chunks:
|
||||
label = first if first == last else f"{first}^..{last}"
|
||||
titled = f"{first}^1..{first}^2" if landed == "merge" else f"{first}^1..{last}"
|
||||
measured = measure(f"{first}^1", last, label, utc(committed), titled, landed)
|
||||
if isinstance(measured, Failure):
|
||||
return measured
|
||||
outcomes += measured
|
||||
return outcomes
|
||||
|
||||
|
||||
def read_replays(default: str) -> list[tuple[str, str, int, Landing]] | Failure:
|
||||
"""Each run of commits on the default branch's first-parent line after its newest merge commit that share one commit time: its first and last commit, as short hashes, that time, and whether a rebase replayed it, which leaves a commit time apart from its author time."""
|
||||
def read_chunks(default: str) -> list[tuple[str, str, int, Landing]] | Failure:
|
||||
"""Each chunk on the default branch's first-parent line, newest first: its first and last commit as short hashes, its commit time, and how it reached the branch. A merge commit is a chunk of its own; any other commit joins the commit above it when both share a commit time."""
|
||||
log = git("log", "--first-parent", "--format=%h %ct %at %p", default)
|
||||
if isinstance(log, Failure):
|
||||
return log
|
||||
runs: list[tuple[str, str, int, Landing]] = []
|
||||
chunks: list[tuple[str, str, int, Landing]] = []
|
||||
joinable = False
|
||||
for line in log.splitlines():
|
||||
short, committed, authored, *parents = line.split()
|
||||
if len(parents) > 1:
|
||||
break
|
||||
replayed = committed != authored
|
||||
if runs and runs[-1][2] == int(committed):
|
||||
runs[-1] = (short, runs[-1][1], int(committed), "rebase" if replayed or runs[-1][3] == "rebase" else "push")
|
||||
chunks.append((short, short, int(committed), "merge"))
|
||||
joinable = False
|
||||
elif joinable and chunks[-1][2] == int(committed):
|
||||
_, newest, time, landed = chunks[-1]
|
||||
chunks[-1] = (short, newest, time, "rebase" if landed == "rebase" or committed != authored else "push")
|
||||
else:
|
||||
runs.append((short, short, int(committed), "rebase" if replayed else "push"))
|
||||
return runs
|
||||
chunks.append((short, short, int(committed), "rebase" if committed != authored else "push"))
|
||||
joinable = True
|
||||
return chunks
|
||||
|
||||
|
||||
def measure(before: str, tip: str, label: str, merged: str, titled: str, landed: Landing) -> list[Outcome] | Failure:
|
||||
|
||||
Reference in New Issue
Block a user