Skip to content

The meta-skill that builds and improves all your skills, including itself. Watches your work sessions (autonomous or human-led), captures patterns, corrections and judgement calls, and turns them into skill improvements and new skill candidates for your review. Practical application of the Augmented Expertise methodology. Open source: CC BY 4.0.

Close the scan with a summary line and read its output whole

Eoghan Henn28b2982d3275
diff --git a/SKILL.md b/SKILL.md
index 5cad353..e8f5dcf 100644
--- a/SKILL.md
+++ b/SKILL.md
@@ -164,8 +164,8 @@ skill" (some upload paths keep only `SKILL.md`); its episodes do not run.
bash "<skill directory>/scripts/session-start-scan.sh" "[ABSOLUTE PATH]"
```
- `scripts/session-start-scan.sh` is the scan (`<skill directory>`: the one
- holding this file); review what it runs and prints there, line by line.
+ `scripts/session-start-scan.sh` is the scan (in `<skill directory>`); review
+ it there, and read its output whole — never through `tail`, `head` or `grep`.
**Only the print can be refused, so it runs last** — a refused print is
never an empty log: load `references/observation-log.md` ("A refused
diff --git a/references/observation-log.md b/references/observation-log.md
index 2dcb43c..56d04ca 100644
--- a/references/observation-log.md
+++ b/references/observation-log.md
@@ -1488,7 +1488,12 @@ line is the protocol's own trace, for the same reason the checkpoint rule
is a write: a step whose value lies in happening at a specific moment needs
its own entry in the tool record. (Where the workspace prices every write —
the exception under "How to Log" — fold this line into the session's first
-write instead.)
+write instead.) Read the scan's output whole. Its finding lines (NOTE,
+LOST ENTRIES, GAP) and counts come first and the entry headers last, with
+one `end of scan` line closing it that repeats the counts and the number
+of finding lines; `tail`, `head` or a `grep` hides exactly the lines that
+matter while the checkpoint line still lands and the log looks
+compliant. A truncated scan is a skipped one.
### Two gaps the checkpoint pairing still leaves — and the rule behind both
diff --git a/scripts/session-start-scan.sh b/scripts/session-start-scan.sh
index f63f15a..5f77bae 100755
--- a/scripts/session-start-scan.sh
+++ b/scripts/session-start-scan.sh
@@ -15,9 +15,14 @@
# line (files, parsed, suspect, archive-suspect); a NOTE: pointer line when
# skill-observations/MOVED.md exists; a GAP line when the previous scan in
# checkpoints.log is 7 or more days old; the logs found under the root's
-# parent; the active principles' headings; and LAST the frontmatter
-# of every numbered entry, each header followed by one `---` line. Appends
-# one line to skill-observations/checkpoints.log:
+# parent; the active principles' headings; then the frontmatter of every
+# numbered entry, each header followed by one `---` line; and LAST one
+# `end of scan` line repeating the counts and how many finding lines
+# (NOTE / LOST ENTRIES / GAP) stand above the entries. The findings open the
+# output and the summary closes it, so a view cut by `head` keeps the
+# findings and one cut by `tail` keeps the summary and its finding count;
+# neither replaces reading the output whole, which the summary line says.
+# Appends one line to skill-observations/checkpoints.log:
# YYYY-MM-DD HH:MM [<cwd's last segment>] session-start scan: files=N parsed=N principles=N
#
# Exit status:
@@ -26,8 +31,8 @@
# scan halts there, before the checkpoint line and the content print
# 2 refused: no workspace root, or a root that is not an absolute path
# any other non-zero status is the content print's own (the counts and the
-# checkpoint line above it already ran) — a refused or failed print is
-# never an empty log
+# checkpoint line above it already ran, and the end-of-scan line names the
+# status) — a refused or failed print is never an empty log
#
# This is the inline scan SKILL.md carried in step 2, unchanged in what it
# runs and prints, moved into a file for two reasons. A reader can review it
@@ -119,7 +124,10 @@ a_sus=0; [ -d "$d/archive" ] && a_sus=$(LC_ALL=C find "$d/archive" -maxdepth 1 -
p="$root/skill-observations/cross-cutting-principles.md"
pa='/^(\140\140\140|~~~)/ {f=!f} f {next} /^## Active Principles/ {a=1; h=1; next} a && /^## / {a=0}'
pr=absent; [ -f "$p" ] && pr=$(awk "$pa"' a && /^### / {n++} END {print (h ? n+0 : "unparsed")}' "$p")
-[ "$pr" = unparsed ] && echo "NOTE: the principles file has no '## Active Principles' heading — 'could not parse', not 'no principles'; read it directly"
+# fx counts the finding lines (NOTE / LOST ENTRIES / GAP) printed above the
+# entries, for the end-of-scan line.
+fx=0
+[ "$pr" = unparsed ] && { echo "NOTE: the principles file has no '## Active Principles' heading — 'could not parse', not 'no principles'; read it directly"; fx=$((fx + 1)); }
# --- the guard: files present and nothing parsed is a broken command ----------
if [ "$n" -gt 0 ] && [ "$parsed" -eq 0 ]; then echo "SCAN COMMAND BROKEN — $n files present, 0 headers parsed"; exit 1; fi
@@ -127,10 +135,10 @@ if [ "$n" -gt 0 ] && [ "$parsed" -eq 0 ]; then echo "SCAN COMMAND BROKEN — $n
# --- findings ----------------------------------------------------------------
# Lost entries: a zero-byte numbered file, or one with no opening `---`.
lost=$( { find "$d" -maxdepth 1 -name '[0-9]*.md' -empty; LC_ALL=C find "$d" -maxdepth 1 -name '[0-9]*.md' ! -empty -exec awk 'FNR==1 {sub(/^\357\273\277/, ""); if (!/^---[[:space:]]*$/) print FILENAME; nextfile}' {} +; } | sed 's|.*/||' | LC_ALL=C sort | tr '\n' ' ')
-[ -n "$lost" ] && echo "LOST ENTRIES — no header, an interrupted write; report each, never reuse or delete: $lost"
+[ -n "$lost" ] && { echo "LOST ENTRIES — no header, an interrupted write; report each, never reuse or delete: $lost"; fx=$((fx + 1)); }
# Headers that did not parse, by name: no opening, or no closing `---`.
-[ "$parsed" -lt "$n" ] && echo "NOTE: $((n - parsed)) of $n headers did not parse (no opening or no closing ---):" && LC_ALL=C find "$d" -maxdepth 1 -name '[0-9]*.md' -exec awk 'FNR==1 {if (NR>1 && fm) print f; f=FILENAME; sub(/^\357\273\277/, ""); fm=/^---[[:space:]]*$/; if (!fm) {print f; nextfile}; next} fm && /^---[[:space:]]*$/ {fm=0; nextfile} END {if (fm) print f}' {} +
-[ "$suspect" -gt 0 ] || [ "$a_sus" -gt 0 ] && echo "NOTE: $suspect of $n headers (and $a_sus in archive/) look like invalid YAML (an unquoted ': ', text after a closing quote, a value opening with a backtick, @ or %, an undefined escape, a colon in an unquoted list entry) — quote or fix them (File format)"
+[ "$parsed" -lt "$n" ] && { echo "NOTE: $((n - parsed)) of $n headers did not parse (no opening or no closing ---):"; fx=$((fx + 1)); } && LC_ALL=C find "$d" -maxdepth 1 -name '[0-9]*.md' -exec awk 'FNR==1 {if (NR>1 && fm) print f; f=FILENAME; sub(/^\357\273\277/, ""); fm=/^---[[:space:]]*$/; if (!fm) {print f; nextfile}; next} fm && /^---[[:space:]]*$/ {fm=0; nextfile} END {if (fm) print f}' {} +
+[ "$suspect" -gt 0 ] || [ "$a_sus" -gt 0 ] && { echo "NOTE: $suspect of $n headers (and $a_sus in archive/) look like invalid YAML (an unquoted ': ', text after a closing quote, a value opening with a backtick, @ or %, an undefined escape, a colon in an unquoted list entry) — quote or fix them (File format)"; fx=$((fx + 1)); }
printf 'files: %s parsed: %s suspect (awk, a floor): %s archive-suspect: %s\n' "$n" "$parsed" "$suspect" "$a_sus"
# --- pointer: skill-observations/MOVED.md marks a root as abandoned ------------
@@ -143,6 +151,7 @@ if [ -f "$mv_ptr" ]; then
mv_line=$(head -n 1 "$mv_ptr" | tr -d '\r' | cut -c 1-200)
mv_after=$(find "$d" -maxdepth 1 -name '[0-9]*.md' -newer "$mv_ptr" 2>/dev/null | wc -l | tr -d ' ')
echo "NOTE: pointer at this root (skill-observations/MOVED.md): \"$mv_line\" — $mv_after entries written here since it; report both roots and ask, never consolidate or re-anchor on it"
+ fx=$((fx + 1))
fi
# --- gap: days since the previous session-start scan --------------------------
@@ -159,7 +168,7 @@ gap=$( [ -f "$ck" ] && LC_ALL=C awk -v today="$(date +%F)" '
return 365 * y + int(y / 4) - int(y / 100) + int(y / 400) + int((153 * (m - 3) + 2) / 5) + d }
/ session-start scan:/ && /^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]/ { last = substr($ 0, 1, 10) }
END { if (last != "") { g = dn(today) - dn(last); if (g >= 7) print last " " g } }' "$ck")
-[ -n "$gap" ] && echo "GAP: the previous session-start scan ran ${gap% *}, ${gap#* } days ago. If work happened in between, the skill was not activated in those sessions: check the activation instruction (references/environments.md, \"Verify activation in a NEW session\")"
+[ -n "$gap" ] && { echo "GAP: the previous session-start scan ran ${gap% *}, ${gap#* } days ago. If work happened in between, the skill was not activated in those sessions: check the activation instruction (references/environments.md, \"Verify activation in a NEW session\")"; fx=$((fx + 1)); }
# --- the trace: one line per session, with date, time and source -------------
printf '%s [%s] session-start scan: files=%s parsed=%s principles=%s\n' "$(date '+%F %H:%M')" "${PWD##*/}" "$n" "$parsed" "$pr" \
@@ -172,12 +181,22 @@ find "$(dirname "$root")" -maxdepth 3 -type d -path '*/skill-observations/observ
# --- content: printed with the headers below ---------------------------------
# The active principles' headings.
[ -f "$p" ] && awk "$pa"' a && /^### / {sub(/\r$/, ""); print}' "$p"
-# LAST: the frontmatter of every numbered entry, one awk for the whole set
-# over the directory's own glob (no word splitting of a spaced path). This is
-# the only half a content classifier can refuse, so everything above has
-# already run when it is.
+# The frontmatter of every numbered entry, one awk for the whole set over the
+# directory's own glob (no word splitting of a spaced path). This is the only
+# half a content classifier can refuse, so everything above has already run
+# when it is.
( export LC_ALL=C; [ "$n" -eq 0 ] || { cd "$d" && awk 'FNR==1 && NR>1 && fm {print "---"}
FNR==1 {sub(/^\357\273\277/, ""); fm=/^---[[:space:]]*$/; if (!fm) {print "---"; nextfile}; next}
fm && /^---[[:space:]]*$/ {fm=0; print "---"; nextfile}
fm
END {if (fm) print "---"}' [0-9]*.md; } )
+rc=$?
+
+# --- LAST: the end-of-scan line ----------------------------------------------
+# Repeats the counts and says how many finding lines stand above the entries,
+# so output cut to its last lines still shows that there were findings to
+# read; it is a pointer to the whole output, never its replacement.
+st=; [ "$rc" -eq 0 ] || st="; content print exited $rc"
+printf 'end of scan — files: %s parsed: %s suspect: %s archive-suspect: %s principles: %s; finding lines above the entries (NOTE / LOST ENTRIES / GAP): %s%s. Read the output whole: never cut it with head, tail or grep\n' \
+ "$n" "$parsed" "$suspect" "$a_sus" "$pr" "$fx" "$st"
+exit "$rc"