From 318dbb34b6ac6de4c8e4634a7ddfb082f1e523e0 Mon Sep 17 00:00:00 2001 From: cheshirecode Date: Sun, 9 Aug 2026 03:06:27 -0400 Subject: [PATCH 1/4] fix(worklog): accept --light as alias for --minimal in preamble.sh preamble.sh rejected --light (exit 2) even though SKILL.md and init.md documented it as a valid flag mapping to minimal mode. Add --light as a recognized alias that normalizes to --minimal before dispatch. --- skills/worklog/bin/preamble.sh | 5 +++-- skills/worklog/tests/init/test_light_init.sh | 22 +++++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/skills/worklog/bin/preamble.sh b/skills/worklog/bin/preamble.sh index 2634f60..690223a 100755 --- a/skills/worklog/bin/preamble.sh +++ b/skills/worklog/bin/preamble.sh @@ -22,9 +22,10 @@ set -euo pipefail mode="${1:---full}" case "$mode" in - --minimal|--full) ;; - *) echo "usage: $0 [--minimal|--full]" >&2; exit 2 ;; + --minimal|--light|--full) ;; + *) echo "usage: $0 [--minimal|--light|--full]" >&2; exit 2 ;; esac +[[ "$mode" == "--light" ]] && mode="--minimal" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=_lib.sh diff --git a/skills/worklog/tests/init/test_light_init.sh b/skills/worklog/tests/init/test_light_init.sh index 7760e94..0929ace 100755 --- a/skills/worklog/tests/init/test_light_init.sh +++ b/skills/worklog/tests/init/test_light_init.sh @@ -61,4 +61,24 @@ after_pull_mtime="$(stat -c %Y "$TMP/.cache/preamble-pull-stamp" 2>/dev/null || [[ "$after_kernel_mtime" == "$before_kernel_mtime" ]] [[ "$after_pull_mtime" == "$before_pull_mtime" ]] -echo "ok: default/light init routes to non-mutating minimal preamble" +echo "ok: --minimal accepted (non-mutating)" + +# Restore fixture for --light test +git -C "$TMP" checkout -- . +printf '\ndirty\n' >> "$TMP/people/tester/active/light-init.md" +before_status="$(git -C "$TMP" status --porcelain)" +before_kernel_mtime="$(stat -c %Y "$TMP/.cache/compact-kernels.json" 2>/dev/null || stat -f %m "$TMP/.cache/compact-kernels.json")" +before_pull_mtime="$(stat -c %Y "$TMP/.cache/preamble-pull-stamp" 2>/dev/null || stat -f %m "$TMP/.cache/preamble-pull-stamp")" + +WORKLOG_REPO="$TMP" WORKLOG_LDAP=tester \ + "$WORKLOG_BIN/preamble.sh" --light >/dev/null + +after_status="$(git -C "$TMP" status --porcelain)" +after_kernel_mtime="$(stat -c %Y "$TMP/.cache/compact-kernels.json" 2>/dev/null || stat -f %m "$TMP/.cache/compact-kernels.json")" +after_pull_mtime="$(stat -c %Y "$TMP/.cache/preamble-pull-stamp" 2>/dev/null || stat -f %m "$TMP/.cache/preamble-pull-stamp")" + +[[ "$after_status" == "$before_status" ]] +[[ "$after_kernel_mtime" == "$before_kernel_mtime" ]] +[[ "$after_pull_mtime" == "$before_pull_mtime" ]] + +echo "ok: --light accepted and behaves identically to --minimal" From 5bc7979a9de72b0160da5f69d47aef99570e031f Mon Sep 17 00:00:00 2001 From: cheshirecode Date: Sun, 9 Aug 2026 03:30:09 -0400 Subject: [PATCH 2/4] fix(worklog): re-compute active counts after pull in preamble.sh active_namespace and active_total were computed before the pull but used in the roster-health count comparison after it. If the pull adds or removes tasks, the stale pre-pull count masks cache-staleness. Re-compute both counts after the pull so the comparison uses current state. --- skills/worklog/bin/preamble.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/skills/worklog/bin/preamble.sh b/skills/worklog/bin/preamble.sh index 690223a..5e72dfd 100755 --- a/skills/worklog/bin/preamble.sh +++ b/skills/worklog/bin/preamble.sh @@ -88,6 +88,10 @@ else printf 'PULL=skip (minimal)\n' fi +# Re-compute counts after pull so roster-health comparison uses current state. +active_total="$(find people -path '*/active/*.md' -type f 2>/dev/null | wc -l | tr -d '[:space:]')" +active_namespace="$(find "people/$LDAP/active" -maxdepth 1 -name '*.md' -type f 2>/dev/null | wc -l | tr -d '[:space:]')" + # Roster (fresh kernels JSON or a read-only raw Markdown fallback). The health # line is intentionally separate so fresh agents can tell degraded cache state # from "no work". From 5e2b5d34b688a5420b7e4b583c96e4cd36ca42d0 Mon Sep 17 00:00:00 2001 From: cheshirecode Date: Sun, 9 Aug 2026 03:31:01 -0400 Subject: [PATCH 3/4] fix(worklog): replace stale CLAUDE_HOOK env var with actual session IDs in sync.md does not exist in the codebase. The actual session identifiers are CLAUDE_CODE_SESSION_ID, CODEX_SESSION_ID, CURSOR_SESSION_ID, and OPENAI_SESSION_ID (see bin/_lib.sh::resolve_session_id). --- skills/worklog/modes/sync.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skills/worklog/modes/sync.md b/skills/worklog/modes/sync.md index 82026ee..7c13929 100644 --- a/skills/worklog/modes/sync.md +++ b/skills/worklog/modes/sync.md @@ -4,7 +4,7 @@ One command handles every save path. Pick the first applicable in order; stop th ## Non-interactive guard -If `$CLAUDE_HOOK` is set or stdin is not a TTY, skip conversation-WIP detection (it requires judgment). Fall through to autosave only. +If `$CLAUDE_CODE_SESSION_ID`, `$CODEX_SESSION_ID`, `$CURSOR_SESSION_ID`, or `$OPENAI_SESSION_ID` is set — or stdin is not a TTY — skip conversation-WIP detection (it requires judgment). Fall through to autosave only. ## Precedence From d70dccd3a798d43085b0262a8c11a6c78e6270fe Mon Sep 17 00:00:00 2001 From: cheshirecode Date: Sun, 9 Aug 2026 03:31:50 -0400 Subject: [PATCH 4/4] test(worklog): add adversarial edge case for unknown preamble flags Verify preamble.sh rejects --bogus with non-zero exit. --- skills/worklog/tests/init/test_light_init.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/skills/worklog/tests/init/test_light_init.sh b/skills/worklog/tests/init/test_light_init.sh index 0929ace..95b376b 100755 --- a/skills/worklog/tests/init/test_light_init.sh +++ b/skills/worklog/tests/init/test_light_init.sh @@ -82,3 +82,10 @@ after_pull_mtime="$(stat -c %Y "$TMP/.cache/preamble-pull-stamp" 2>/dev/null || [[ "$after_pull_mtime" == "$before_pull_mtime" ]] echo "ok: --light accepted and behaves identically to --minimal" + +# Adversarial: unknown flags must be rejected. +if "$WORKLOG_BIN/preamble.sh" --bogus >/dev/null 2>&1; then + echo "FAIL: --bogus should have been rejected" + exit 1 +fi +echo "ok: --bogus rejected (exit != 0)"