Compare commits

...

2 Commits

Author SHA1 Message Date
5a2a4bcbda phone_guard: pin phone_vd.sh record as a lease-free read of the session's own VD
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
Python tests / test (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WXd5qap8DWqZCS9mjh3CzH
2026-10-03 19:21:54 +02:00
f0d50d7375 i3blocks: issue_dashboard shows merged issues awaiting their opener
The issue dashboard now keeps merged-but-open issues (Merge only tags the
opener, kado-no-akari #21) out of `todo` and writes them as `awaiting` in
status.json. The block shows them as "· ⏳ N" between "✓" and "✗", only when
N > 0, without changing the colour (they wait on the opener, not kuhy).
`awaiting` is optional, so the old server's status.json still renders
numbers rather than grey. Still zero forks on the hot path. Prunes the oldest
evidence artifact to stay at the 60-file cap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WXd5qap8DWqZCS9mjh3CzH
2026-10-02 20:59:36 +02:00
7 changed files with 112 additions and 94 deletions

View File

@ -0,0 +1,37 @@
{
"intent": "Merged-but-open issues (Merge only tags the opener, kado-no-akari #21) get their own 'Awaiting opener' column in ~/src/issue-dashboard and an 'awaiting' count in status.json; the i3bar issue_dashboard block shows it as '⏳ N' instead of counting it as to do.",
"scope": [
"linux_configuration/i3blocks/issue_dashboard.sh - read the optional 'awaiting' field and show '· ⏳ N' between '✓' and '✗' when N > 0",
"linux_configuration/tests/test_i3blocks_issue_dashboard.sh - awaiting text, hidden at zero, ordering, colour, old-format file without the key",
"Non-goal: the dashboard change itself (local repo ~/src/issue-dashboard, commit 0e6077c); the running dashboard server was not restarted."
],
"changes": [
"awaiting is optional: a status.json from a server older than the column has no key and still renders '📋 N · ⚙ N · ✓ N', never grey.",
"awaiting never changes the colour (it waits on the opener, not kuhy) and stays out of the short text; zero is hidden like '✗'.",
"Still zero forks on the hot path: one more regex field read and an arithmetic test."
],
"verification": [
{
"command": "bash linux_configuration/tests/test_i3blocks_issue_dashboard.sh",
"result": "pass",
"evidence": "awaiting / hidden-at-zero / ordering with ✗ / colour / old-format / stale / missing / broken / empty / click asserted; strace still shows one execve and no clone/fork."
},
{
"command": "bash linux_configuration/tests/test_i3blocks_efficiency.sh",
"result": "pass",
"evidence": "All i3blocks efficiency regression tests passed."
},
{
"command": "ISSUE_DASHBOARD_STATUS=<status.json from a scratch issue-dashboard server on a fixture source> issue_dashboard.sh",
"result": "pass",
"evidence": "'📋 1 · ⚙ 0 · ✓ 1 · ⏳ 2 · ✗ 1' #FF5555 from {todo 1, ready 1, awaiting 2, failed 1}; the live old-format status.json still renders '📋 14 · ⚙ 0 · ✓ 0' #FFFFFF."
}
],
"risks": [
"'⏳' shows only once kuhy restarts the dashboard server; until then the old server keeps writing merged-open issues into todo."
],
"rollback": [
"git revert this commit; the block reads the old fields only.",
"Confirm the bar still renders '📋 N · ⚙ N · ✓ N'."
]
}

View File

@ -0,0 +1,29 @@
{
"intent": "Pin that `phone_vd.sh record start|stop` (new in ~/.claude: real MP4 video of a session's own virtual display via a read-only scrcpy) passes the phone_guard PreToolUse hook as a lease-free read, while the adb input that drives the recorded app still takes that app's lease.",
"scope": [
"python_pkg/phone_guard/tests/test_hook.py",
"Non-goal: changing phone_guard classification -- the hook only inspects commands containing 'adb', so `phone_vd.sh record` never reached it and needed no change"
],
"changes": [
"TestLeases.test_recording_own_display_is_a_read: record start/stop take no lease and are not blocked; `phone_vd.sh record start a.mp4 && adb shell input -d 9 swipe ...` on the session's own display takes exactly pkg:<its app>"
],
"verification": [
{
"command": "capped.sh python3 -m pytest python_pkg/phone_guard -q --cov-branch --cov-report=term-missing",
"result": "pass",
"evidence": "68 passed; every python_pkg/phone_guard module 100% statements and branches"
},
{
"command": "phone_vd.sh record start ~/data/claude-scratch/phone-record/vd37_final.mp4; 5 x adb shell input -d 37 swipe; phone_vd.sh record stop (Pixel 6a 23181JEGR08034, VD 37 running com.android.settings)",
"result": "pass",
"evidence": "ffprobe: h264 1080x2400, duration 10.511 s, 307 frames (~29 fps avg, ~35 fps while scrolling); the hook let every call through (the unit test pins that the swipe maps to pkg:<own app>; not observed live)"
}
],
"risks": [
"A raw `scrcpy --display-id=<other VD>` still bypasses the guard (no 'adb' in the command); phone_vd.sh only ever records the caller's own display"
],
"rollback": [
"git revert this commit; it only adds a test and this evidence file",
"Run python3 -m pytest python_pkg/phone_guard afterwards"
]
}

View File

@ -1,37 +0,0 @@
{
"intent": "Allow the Pre-commit checks workflow to be re-run manually, so a caching change can be verified on an unchanged tree instead of being asserted.",
"scope": [
".github/workflows/pre-commit.yml (triggers only)",
"Non-goal: changing what the job runs"
],
"changes": ["Added workflow_dispatch to the Pre-commit checks triggers."],
"verification": [
{
"command": "gh run view 32645759168 --log | grep for cache keys",
"result": "pass",
"evidence": "'Cache not found for input keys: pre-commit-Linux-py3.12-...' then 'Cache saved with key: ...' -- the env cache missed because that commit changed .pre-commit-config.yaml, which is the key. It is populated now."
},
{
"command": "gh run view 32645759168 --log | grep -c 'Installing environment'",
"result": "pass",
"evidence": "6 hook environments built from scratch, including pylint's with a dozen extra packages -- the bulk of the 126s hook step"
},
{
"command": "gh run view 32645759168 --log | grep 'pytest with coverage enforcement'",
"result": "pass",
"evidence": "'....Skipped' -- the duplicate-suite skip from the previous commit took effect"
},
{
"command": "python3 -c \"import yaml; yaml.safe_load(...)\"",
"result": "pass",
"evidence": "workflow parses as valid YAML"
}
],
"risks": [
"A dispatch trigger lets anyone with write access run the job on demand; it runs the same read-only checks as a push, so there is no additional privilege."
],
"rollback": [
"Remove the workflow_dispatch line.",
"After rollback, confirm the workflow no longer offers a Run workflow button."
]
}

View File

@ -1,51 +0,0 @@
{
"intent": "Establish the safety net for the testsAndMisc restructure: a script that inventories every live reference into the repo, and the directory-depth gate written early as a dry run so the flattening work can be sized before any file moves.",
"scope": [
"meta/scripts/report_live_state.sh (new)",
"meta/scripts/check_directory_depth.sh (new, NOT yet wired into pre-commit)",
"docs/restructure-live-state.md (new)",
"Non-goal: no archives, extractions or moves in this commit",
"Non-goal: the depth gate is deliberately not enforced yet - the tree does not conform"
],
"changes": [
"report_live_state.sh enumerates systemd units, /etc config and $HOME symlinks that name an absolute path inside the repo; --check exits 1 while any remain, making it the post-move gate.",
"check_directory_depth.sh enforces a 2-directory cap, modelled on check_file_length.sh (--all/per-file, EXCLUDED_PREFIXES). Exempts third_party/, docs/superpowers/, .github/skills/ by prefix and any lib/ or tests/ path segment, matched as whole segments so libvirt/ and lib.sh are unaffected.",
"docs/restructure-live-state.md records the baseline inventory (6 systemd units, 2 /etc guard-lib targets, 19 symlinks) plus the depth dry-run sizing."
],
"verification": [
{
"command": "./meta/scripts/report_live_state.sh",
"result": "pass",
"evidence": "Reported 6 systemd units (media-organizer, dns-blocklist-refresh, endurain-import, kcd2-dice-build, morning-routine, syncyomi-guard), 2 /etc/guard-lib/targets/*.conf plugin paths, and 19 symlinks under ~/.config/i3blocks (13), ~/.local/bin (3), ~/.oh-my-zsh/custom (3)."
},
{
"command": "./meta/scripts/report_live_state.sh --check; echo $?",
"result": "pass",
"evidence": "Exit code 1 with 'live references into /home/kuhy/src/testsAndMisc remain', which is correct at baseline since nothing has moved yet."
},
{
"command": "14 hand-built path cases through check_directory_depth.sh",
"result": "pass",
"evidence": "a/b/c.sh=0, a/b/c/d.sh=1, boot_recovery/tests/lib/x.sh=0, focus_policy/tests/test_model.py=0, meta/scripts/lib/trace_stubs.sh=0, meta/scripts/fixtures/mutations/monitor.json=1, third_party+docs/superpowers+.github/skills prefixes=0. False-positive guards: a/b/libvirt/c.sh=1 and a/b/c/lib.sh=1 both correctly NOT exempt."
},
{
"command": "./meta/scripts/check_directory_depth.sh --all",
"result": "fail (expected - dry run only, gate not wired)",
"evidence": "556 violations at baseline. 349 disappear with the planned archives/extractions; 207 remain as the step D worklist, dominated by linux_configuration/scripts/single_use (~130)."
},
{
"command": "pre-commit run --files meta/scripts/check_directory_depth.sh meta/scripts/report_live_state.sh docs/restructure-live-state.md",
"result": "pass",
"evidence": "All hooks passed, including shellcheck, the 250-line file cap, and the shell-coverage ratchet."
}
],
"risks": [
"report_live_state.sh reads /etc without sudo, so a root-only-readable reference would be missed; every reference found so far is world-readable.",
"The symlink scan is depth-limited to 4 under $HOME, which covers all known locations but would miss a deeper one.",
"check_directory_depth.sh is intentionally not wired into pre-commit yet; wiring it now would block every unrelated commit, exactly as the file-length-cap comment warns."
],
"rollback": [
"git revert the commit; all three files are new and nothing sources them yet.",
"Confirm pre-commit run --all-files still passes, since no existing hook or workflow references these scripts."
]
}

View File

@ -2,7 +2,7 @@
# ============================================================================
# issue-dashboard status for i3blocks: issues to do, agents working, work
# ready to merge.
# ready to merge, and merged issues awaiting their opener's close.
#
# Opened the same way as book_guard.sh: a click runs issue-dashboard-desktop,
# which reuses the dashboard server if it is answering (starting it detached
@ -57,6 +57,7 @@ field todo
field working
field ready
field failed
field awaiting
field updated_epoch
if [[ -z $todo || -z $working || -z $ready || -z $failed || -z $updated_epoch ]]; then
@ -71,6 +72,12 @@ if ((now - updated_epoch > STALE_SECONDS)); then
fi
text="📋 ${todo} · ⚙ ${working} · ✓ ${ready}"
# Merged, waiting for the opener to close: shown only when there is some, and
# never a colour, since it waits on someone else. Optional because a server
# older than the awaiting column does not write it.
if ((${awaiting:-0} > 0)); then
text="$text · ⏳ ${awaiting}"
fi
short="📋 ${todo}"
color=$WHITE
if ((failed > 0)); then

View File

@ -39,13 +39,15 @@ chmod +x "$BIN_DIR/launcher"
STATUS="$TMP_DIR/status.json"
# status <todo> <working> <ready> <failed> <age-seconds>
# status <todo> <working> <ready> <failed> <age-seconds> [awaiting]
# With no awaiting the file has no "awaiting" key, as an older server writes.
status() {
local epoch
local epoch awaiting=''
printf -v epoch '%(%s)T' -1
epoch=$((epoch - $5))
printf '{"repo": "Sepci0/kado-no-akari", "todo": %s, "working": %s, "ready": %s, "failed": %s, "updated": "x", "updated_epoch": %s}\n' \
"$1" "$2" "$3" "$4" "$epoch" >"$STATUS"
[[ -n ${6:-} ]] && awaiting=", \"awaiting\": $6"
printf '{"repo": "Sepci0/kado-no-akari", "todo": %s, "working": %s, "ready": %s%s, "failed": %s, "updated": "x", "updated_epoch": %s}\n' \
"$1" "$2" "$3" "$awaiting" "$4" "$epoch" >"$STATUS"
}
run_block() {
@ -75,6 +77,22 @@ out=$(run_block)
assert_eq '📋 3 · ⚙ 0 · ✓ 2 · ✗ 1' "$(line 1 "$out")" 'failed text'
assert_eq '#FF5555' "$(line 3 "$out")" 'a failed agent is red'
printf 'Checking merged issues awaiting their opener...\n'
status 3 0 0 0 5 2
out=$(run_block)
assert_eq '📋 3 · ⚙ 0 · ✓ 0 · ⏳ 2' "$(line 1 "$out")" 'awaiting text'
assert_eq '📋 3' "$(line 2 "$out")" 'awaiting stays out of the short text'
assert_eq '#FFFFFF' "$(line 3 "$out")" 'awaiting alone is white'
status 3 0 0 0 5 0
assert_eq '📋 3 · ⚙ 0 · ✓ 0' "$(line 1 "$(run_block)")" 'zero awaiting is hidden'
status 3 0 2 1 5 2
out=$(run_block)
assert_eq '📋 3 · ⚙ 0 · ✓ 2 · ⏳ 2 · ✗ 1' "$(line 1 "$out")" 'awaiting sits between ready and failed'
assert_eq '#FF5555' "$(line 3 "$out")" 'failed still wins the colour'
printf 'Checking failure states are never blank or stale numbers...\n'
status 4 1 2 0 600
@ -94,7 +112,7 @@ assert_eq '📋 dashboard' "$(line 1 "$(run_block)")" 'empty status'
printf 'Checking the hot path forks nothing...\n'
status 4 1 2 0 5
status 4 1 2 0 5 1
if command -v strace >/dev/null 2>&1; then
ISSUE_DASHBOARD_STATUS="$STATUS" strace -f -o "$TMP_DIR/trace" -e trace=execve,clone,clone3,fork,vfork \
bash "$BLOCK" >/dev/null

View File

@ -75,6 +75,21 @@ class TestLeases:
assert run("adb shell input -d 9 tap 5 5") == 0
assert acquire.call_args.kwargs["scope"] == "pkg:dev.kuhy.todo"
def test_recording_own_display_is_a_read(
self, acquire: MagicMock, isolated_state: Path
) -> None:
# `phone_vd.sh record` mirrors this session's VD read-only (scrcpy
# --no-control), like `shot`: never blocked, no lease. Only the input
# that drives the recorded app takes that app's lease.
make_display(isolated_state, "S", "claude_1", "9", "dev.kuhy.todo")
assert run("~/.claude/scripts/phone_vd.sh record start out/a.mp4") == 0
assert run("~/.claude/scripts/phone_vd.sh record stop") == 0
acquire.assert_not_called()
both = "phone_vd.sh record start a.mp4 && adb shell input -d 9 swipe 1 2 3 4"
assert run(both) == 0
scopes = [call.kwargs["scope"] for call in acquire.call_args_list]
assert scopes == ["pkg:dev.kuhy.todo"]
def test_another_sessions_display_is_refused(
self,
acquire: MagicMock,