Merge branch 'feature/hub-header-rates' into unify/skills-20261114

# Conflicts:
#	docs/requirements/README.md
#	orchestrator/templates/page-resources.js
#	orchestrator/templates/page-settings.js
#	skills/kvb-check-score/scripts/score.py
#	tests/test_resources_sample.py
This commit is contained in:
Kevin Veen-Birkenbach committed 2026-11-14 22:02:20 +00:00
commit f824ea27cf
28 files changed
+1449 -102

No files matched your search

+5 -1
View File
@@ -3,7 +3,11 @@
Each `--message-block` render appends one row to
`scores.jsonl` in the council root that `councilroot.py root` prints: time, origin
remote, top level path, branch, `sha` null, the six values and the block's
digest. The hub's burndown draws it as overlays; no gate reads it. A failed
digest. The commit table after the commit (`--commit-table <repo> --commit
<sha>`) appends the same row for that repository with the full sha and the
commit time, unless the journal holds one for that remote and sha already;
the hub counts each such row once as a commit. The hub's burndown draws the
rows as overlays; no gate reads them. A failed
append prints one stderr line and keeps the exit code; a linked council
root or a link, FIFO or other non-regular file at the journal fails it
without blocking, through `nofollow.py` of `kvb-org-organize`; when that
+1 -18
View File
@@ -21,7 +21,6 @@ Exit codes:
from __future__ import annotations
import argparse
import json
import re
import sys
from collections import deque
@@ -36,9 +35,9 @@ from journal import (
entry,
git_read,
journal_path,
known,
load_labels,
origin,
read,
)
FIELD = "\x00"
@@ -187,22 +186,6 @@ def scan(repo: Path, since: str | None, named: dict[str, str], extras: set[str],
return place[1], rows
def known(path: Path) -> set[tuple[str | None, str]]:
try:
text = read(path)
except FileNotFoundError:
return set()
keys = set()
for line in text.splitlines():
try:
row = json.loads(line)
except ValueError:
continue
if isinstance(row, dict) and isinstance(row.get("sha"), str):
keys.add((row.get("remote"), row["sha"]))
return keys
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
parser.add_argument("--repo", type=Path, nargs="+", action="extend", required=True)
+22
View File
@@ -199,3 +199,25 @@ def read(path: Path) -> str:
Its text, undecodable bytes replaced.
"""
return nofollow(lambda helper: helper.read_text(path.parent, path))
def known(path: Path) -> set[tuple[str | None, str]]:
"""Args:
path: the journal, read through read(); a missing one holds none.
Returns:
(remote, sha) of every row with a sha.
"""
try:
text = read(path)
except FileNotFoundError:
return set()
keys = set()
for line in text.splitlines():
try:
row = json.loads(line)
except ValueError:
continue
if isinstance(row, dict) and isinstance(row.get("sha"), str):
keys.add((row.get("remote"), row["sha"]))
return keys
+40 -10
View File
@@ -17,7 +17,9 @@ Args:
that repository, then a blank line, `📁 Worktree:` and the top level path
alone in a ```text block, so it copies in one go.
--commit <sha>: with --commit-table, the diff stat of that commit instead of
the staged one, plus a commit column.
the staged one, plus a commit column; appends one row with the full sha
and the commit time to the score journal of journal.py unless it holds
one for that remote and sha, so the hub counts the commit once.
--message-block: print the commit message block instead of the two lines, one
value per line: `🎯 Fix: <f> %`, `💥 Break: <b> %`, `💸 Tokens: <c>`,
`⏱️ Velocity: <t>`, `🛡️ Security: <n> %`, `💰 Value: <n:n>` with --value only,
@@ -63,6 +65,7 @@ from journal import (
git,
git_read,
journal_path,
known,
load_labels,
origin,
)
@@ -260,6 +263,10 @@ def main() -> int:
if args.value:
header.insert(list(metrics).index("tokens") + 1, value_header)
row.insert(list(metrics).index("tokens") + 1, args.value)
lines = [f"{metric['emoji']} {metric['label']}: {measured[key]}" for key, metric in metrics.items()]
if args.value:
lines.insert(list(metrics).index("score"), f"{value_header}: {args.value}")
block = "\n".join((*lines, f"{extras['gate']['emoji']} {extras['gate']['label']}: {verdict_cell}"))
if args.commit_table:
try:
lead, cells = commit_cells(args.commit_table, args.commit)
@@ -268,15 +275,12 @@ def main() -> int:
print(f"score: {error}", file=sys.stderr)
return 4 if code == 4 else 2
print(table([*lead, *header], [*cells, *row]))
print(f"\n{WORKTREE}\n\n```text\n{top}\n```")
print(f"\n{WORKTREE}\n\n```text\n{top}\n```", flush=True)
if args.commit:
committed(args.commit_table, args.commit, values_of(args, total), block)
elif args.table:
print(table(header, row))
elif args.message_block:
lines = [f"{metric['emoji']} {metric['label']}: {measured[key]}" for key, metric in metrics.items()]
if args.value:
lines.insert(list(metrics).index("score"), f"{value_header}: {args.value}")
gate_label = extras["gate"]
block = "\n".join((*lines, f"{gate_label['emoji']} {gate_label['label']}: {verdict_cell}"))
print(block, flush=True)
journal(args, total, block)
else:
@@ -291,11 +295,14 @@ def plain(value: float | str) -> float | int | None:
return int(value) if value.is_integer() else value
def journal(args: argparse.Namespace, total: int, block: str) -> None:
values = {
def values_of(args: argparse.Namespace, total: int) -> dict:
return {
"fix": plain(args.fix), "break": plain(args.risk), "tokens": plain(args.efficiency),
"velocity": plain(args.speed), "security": plain(args.security[0]), "score": total,
}
def journal(args: argparse.Namespace, total: int, block: str) -> None:
try:
path = journal_path()
except OSError as error:
@@ -303,10 +310,33 @@ def journal(args: argparse.Namespace, total: int, block: str) -> None:
return
try:
here = Path.cwd()
append(path, [entry(int(time.time()), origin(here), git_read(here, "branch", "--show-current") or None, None, values, block)])
append(path, [entry(int(time.time()), origin(here), git_read(here, "branch", "--show-current") or None, None, values_of(args, total), block)])
except (OSError, ValueError) as error:
print(f"score: journal {path}: {getattr(error, 'strerror', None) or error}", file=sys.stderr)
def committed(repo: str, commit: str, values: dict, block: str) -> None:
"""Args:
repo: the --commit-table repository.
commit: the --commit revision.
values: values_of() the block.
block: the message block the commit carries.
Returns:
Appends one row with the full sha and the commit time unless the
journal holds one for its remote and sha; a failure prints one
stderr line.
"""
path = journal_path()
try:
sha = git(repo, "rev-parse", "--verify", f"{commit}^{{commit}}")
place = origin(Path(repo))
if (place[0], sha) not in known(path):
when = int(git(repo, "show", "-s", "--format=%ct", sha))
append(path, [entry(when, place, git_read(Path(repo), "branch", "--show-current") or None, sha, values, block)])
except (OSError, ValueError, LookupError) as error:
print(f"score: journal {path}: {getattr(error, 'strerror', None) or error}", file=sys.stderr)
if __name__ == "__main__":
sys.exit(main())
+6 -1
View File
@@ -452,8 +452,13 @@ def cmd_kr(args: argparse.Namespace) -> int:
index = int(args.value) - 1
if args.action == "rm":
results.pop(index)
elif args.action == "met":
if results[index].get("met") is not True:
results[index]["met_at"] = stamp()
results[index]["met"] = True
else:
results[index]["met"] = args.action == "met"
results[index]["met"] = False
results[index].pop("met_at", None)
if not results:
entry.pop("key_results")
print(f"{args.task}: key result {args.action} {args.value}")