From 5f4bfb95cf98cc971594f7790a2a3f7a4bb709b8 Mon Sep 17 00:00:00 2001 From: "knowledge-sync[bot]" Date: Thu, 19 Nov 2026 19:32:03 +0000 Subject: [PATCH] security(sidecar): sync copies and skills pin from v0.70.1 --- .lokf/m365/ktl-docent-m365.md | 4 +-- .lokf/pyproject.toml | 2 +- .lokf/scripts/knowledge-report.sh | 25 +++-------------- .lokf/scripts/knowledge-sync.sh | 45 +++++++++++++++++++++++++------ .lokf/uv.lock | 8 +++--- CHANGELOG.md | 4 +++ 6 files changed, 51 insertions(+), 37 deletions(-) diff --git a/.lokf/m365/ktl-docent-m365.md b/.lokf/m365/ktl-docent-m365.md index 34b5a81..a001329 100644 --- a/.lokf/m365/ktl-docent-m365.md +++ b/.lokf/m365/ktl-docent-m365.md @@ -28,7 +28,7 @@ This is the Microsoft 365 Copilot build of the ktl-docent skill from [knowledge- 4. **Weigh what you found.** Derive each concept's trust label from its frontmatter (table below). Prefer *confirmed by a person*; treat *edited since a person last confirmed it* as unconfirmed, because the person confirmed an earlier text; use drafts and unchecked concepts, but say so; treat *retired* as history, not fact; treat *past its review date* as possibly stale. 5. **Say what you could not check.** Versions, endpoints, numbers and paths are summaries in the bundle; the concept's `resource` is authoritative, and this skill cannot open it. Where a `sources` entry carries an `excerpt`, give it as the passage the bundle quotes from that resource: it is the only part of the source the snapshot holds. State the value as the bundle gives it, say it was not checked at the source, and give the reader the source as a link (see [Source links](#source-links)). Give the link also when the question is about the present and the only concept is *nobody has checked this yet* or *edited since a person last confirmed it*. If the agent has another tool that can open that link, use it and say that you did. 6. **Answer with a footing.** Give the answer, then what it rests on: each concept (title, path) with its label, and the snapshot. Use plain words: the label names below, never RDF/IRI/tier. -7. **Stop at the edge of the bundle.** When no concept is relevant, or the only one is retired or stale and the question hinges on being current, say the bundle does not cover it. A retired concept's newest `**Deprecation**` line in `log.md` may link the concept that replaced it after "replaced by": answer from that concept first. Do not fill the gap from general knowledge as if it came from the repository. An answer from another knowledge source the agent has is fine when you name that source. +7. **Stop at the edge of the bundle.** When no concept is relevant, or the only one is retired or stale and the question hinges on being current, say the bundle does not cover it. A retired concept's `isReplacedBy` may name the concept that replaced it: answer from that concept first. Do not fill the gap from general knowledge as if it came from the repository. An answer from another knowledge source the agent has is fine when you name that source. 8. **Hand the gap back.** For a miss or a disagreement, end the answer with one entry the reader can paste into the repository's feedback (see [Reporting a gap](#reporting-a-gap)). Never claim the gap was recorded. ## Trust labels (the same words ktl-curator uses) @@ -45,7 +45,7 @@ This is the Microsoft 365 Copilot build of the ktl-docent skill from [knowledge- A bare `verified: { by, at }` counts as one event. Absent `status` means stable. Give each concept's labels on one line, in the order and form below. The repository's report script prints them the same way, so a reader sees the same words in Copilot and in the repository. -- Label a *retired* concept *retired*, and give it no other label. Add *replaced by* and the path of the concept that replaced it: the first that its `isReplacedBy` names, or else the one its newest `**Deprecation**` line in `log.md` links. +- Label a *retired* concept *retired*, and give it no other label. Add *replaced by* and the path of the concept that replaced it: the first that its `isReplacedBy` names. - Otherwise, start with the first of *edited since a person last confirmed it*, *confirmed by a person*, *checked by automation only* and *nobody has checked this yet* that applies. Add *still a draft*, then *past its review date*, where they apply. - After *confirmed by a person*, give the date of the latest `human:` event. When that event carries a `revision`, add "against" and the revision: a commit hash cut to its first seven characters, a `sha256:` digest cut to the seven after `sha256:`, or an ETag as written. - *Edited since a person last confirmed it* takes the place of *confirmed by a person*, because the person confirmed an earlier text. Give both dates, as in "(confirmed 2026-09-01, edited 2026-09-20)", or both full times when they fall on one day. Compare `generated.at` with the latest `human:` `verified[].at` whole, as strings, never cut to the day: an edit at 14:00 follows a confirmation at 10:00 the same day. Use the v0.1 `timestamp` where `generated.at` is missing. A concept with neither cannot carry this label. diff --git a/.lokf/pyproject.toml b/.lokf/pyproject.toml index 848e444..b3d827f 100644 --- a/.lokf/pyproject.toml +++ b/.lokf/pyproject.toml @@ -12,7 +12,7 @@ description = "LOKF knowledge-bundle tooling for SLSA." # Keep in sync with the `lokf` toolkit's own requires-python floor. requires-python = ">=3.11" dependencies = [ - "ktl==0.69.2", + "ktl==0.70.1", "lokf[build]>=0.9.0", "rust-just==1.59.0", ] diff --git a/.lokf/scripts/knowledge-report.sh b/.lokf/scripts/knowledge-report.sh index f29d0b3..00a9158 100755 --- a/.lokf/scripts/knowledge-report.sh +++ b/.lokf/scripts/knowledge-report.sh @@ -44,9 +44,7 @@ # concept waits in .lokf/feedback.md # retired `status: deprecated`; no other label applies, # and it names the concept that replaced it -# when its isReplacedBy names one, or else -# the newest **Deprecation** line in log.md -# links one +# when its isReplacedBy names one # # The whole report also prints the queue of ktl-curator, Worth ten minutes # today, and what ranks it: review dates due within 30 days, confirmed @@ -1176,12 +1174,8 @@ function resolve(v, from, d, r) { # The concept that replaced a retired one, as Sretiredsuccessor. # Its isReplacedBy decides: the first target, in the field or in `relations`, -# that names a concept of the bundle. ktl-curator writes it on Retire. Where -# it names none, the link after "replaced by" in the newest **Deprecation** -# line of log.md that links the retired concept, in the `../` form that -# ktl-curator and the KTL Curator plugin write; a retirement recorded before -# the slot has only that line. A line with no such link names no successor. -# The first S line for a concept is the one read. +# that names a concept of the bundle. ktl-curator writes it on Retire. A +# **Deprecation** line in log.md is history and names no successor. successors() { printf '%s\n' "$all" | awk -F'\t' -v base="$(bundle_base)" "$resolve_fn"' $1 == "C" { nc++; order[nc] = $2; st[$2] = $4 } @@ -1195,19 +1189,6 @@ successors() { named[p] = 1; print "S\t" p "\t" t } }' - [ -f "$bundle/log.md" ] || return 0 - awk ' - function target(s, a, b) { - a = index(s, "]("); if (!a) return ""; s = substr(s, a + 2); b = index(s, ")"); if (!b) return "" - rest = substr(s, b + 1); s = substr(s, 1, b - 1); sub(/^\.\.\//, "", s); sub(/^\.\//, "", s); return s - } - /^[*-] \*\*Deprecation\*\*: \[/ { - old = target($0); if (old == "" || (old in seen)) next - seen[old] = 1 # the newest line for this concept decides, whether or not it names a successor - c = index(rest, "replaced by ["); if (!c) next - new = target(substr(rest, c)); if (new == "") next - print "S\t" old "\t" new - }' "$bundle/log.md" } # Each Disagreement of a reader that names a concept and still waits, as diff --git a/.lokf/scripts/knowledge-sync.sh b/.lokf/scripts/knowledge-sync.sh index 85bea8b..ccd9d32 100755 --- a/.lokf/scripts/knowledge-sync.sh +++ b/.lokf/scripts/knowledge-sync.sh @@ -43,6 +43,11 @@ # every workflow change into --held for a person to apply # --held where --apply writes the held workflow changes # +# KNOWLEDGE_SYNC_INDEX_WAIT, a number of seconds, keeps asking the index for +# a release it does not show yet, for a sync asked right after the release: +# a mirror trails PyPI by a minute or so. Unset or 0, a missing release is +# final. +# # Exit 0 when the host is synced or already was. Exit 1 when the host was # skipped (no .lokf/, no git, no ktl pin, uncommitted changes, the branch # exists) or a check failed. Exit 2 when the arguments or the release are @@ -76,6 +81,28 @@ usage() { exit 2 } die() { echo "knowledge-sync: $*" >&2; exit 2; } +# The sync writes plain files alone, never through a link: . +plain_file() { [[ ! -L "$1" ]] || die "$1 is a link, and the sync writes plain files alone"; } + +# Lock the pin from the index: [uv args...]. uv's words are +# the output when it fails. For KNOWLEDGE_SYNC_INDEX_WAIT seconds, a release +# the index does not show yet is asked for again, as the header says. +lock_pin() { + local dir="$1" waited=0 wait="${KNOWLEDGE_SYNC_INDEX_WAIT:-0}" said step + shift + [[ "$wait" =~ ^[0-9]+$ ]] || { echo "KNOWLEDGE_SYNC_INDEX_WAIT is '$wait', not a number of seconds"; return 2; } + while :; do + if said="$(cd "$dir" && uv lock --quiet --refresh-package ktl "$@" 2>&1)"; then return 0; fi + if (( waited < wait )) && printf '%s' "$said" | grep -qF "no version of ktl=="; then + step=$(( wait - waited < 30 ? wait - waited : 30 )) + echo " waiting the index does not show the release yet; asking again in $step s" >&2 + sleep "$step"; waited=$(( waited + step )) + continue + fi + printf '%s\n' "$said" + return 1 + done +} # The run's temporary folder, and the undo for a stop between moving the # pin and reading the release: the pin's two files, and in branch mode the @@ -203,13 +230,11 @@ apply_patch() { git reset --quiet --hard die "uv is not installed, and the lock the patch brings is checked with it" fi - err="$(mktemp)" if git cat-file -e "HEAD:$lock" 2>/dev/null; then git show "HEAD:$lock" > "$lock"; else rm -f "$lock"; fi - if ! (cd .lokf && uv lock --quiet --refresh-package ktl) 2>"$err"; then + if ! err="$(lock_pin .lokf)"; then git reset --quiet --hard - die "uv could not lock the patch's pin ($(tr '\n' ' ' < "$err" | cut -c1-300))" + die "uv could not lock the patch's pin ($(printf '%s' "$err" | tr '\n' ' ' | cut -c1-300))" fi - rm -f "$err" if ! git diff --quiet -- "$lock"; then git reset --quiet --hard die "the patch's $lock differs from the one uv resolves from the index for its pin, so it was not taken" @@ -332,8 +357,8 @@ main() { echo " no default branch to start from (origin/HEAD, main or master); skipped" >&2 return 1 fi - if git -C "$host" rev-parse -q --verify "refs/heads/$branch" >/dev/null; then - echo " $branch already exists in $host: finish it, or delete it, first; skipped" >&2 + if git -C "$host" rev-parse -q --verify "refs/heads/$branch" >/dev/null || git -C "$host" rev-parse -q --verify "refs/remotes/origin/$branch" >/dev/null; then + echo " $branch already exists in $host, or on its origin: finish it, or delete it, first; skipped" >&2 return 1 fi previous="$(git -C "$host" symbolic-ref --quiet --short HEAD 2>/dev/null || git -C "$host" rev-parse HEAD)" @@ -390,7 +415,7 @@ main() { rm -f "$host/$pyproject.sync-bak" fi echo " locking ktl==$version" - if ! said="$(cd "$host/.lokf" && uv lock --quiet --refresh-package ktl ${from[@]+"${from[@]}"} 2>&1)"; then + if ! said="$(lock_pin "$host/.lokf" ${from[@]+"${from[@]}"})"; then if printf '%s' "$said" | grep -qF "no version of ktl=="; then die "no release $tag of ktl on the index: publish the release first, then sync (that order is the point)" elif printf '%s' "$said" | grep -qF "ktl was not found"; then @@ -497,6 +522,7 @@ main() { continue fi mkdir -p "$(dirname "$host/$dst")" + plain_file "$host/$dst" tpl "$src" > "$host/$dst" [[ ! -x "$new_t/$src" ]] || chmod +x "$host/$dst" added+=("$dst ($why)") @@ -525,6 +551,7 @@ main() { else copied+=("$dst") fi + plain_file "$host/$dst" cat "$want" > "$host/$dst" rm -f "$was" fi @@ -549,6 +576,7 @@ main() { dst="$site/$rel"; [[ "$rel" == gitignore ]] && dst="$site/.gitignore" if [[ ! -f "$host/$dst" ]]; then mkdir -p "$(dirname "$host/$dst")" + plain_file "$host/$dst" cat "$new_w/website/$rel" > "$host/$dst" [[ ! -x "$new_w/website/$rel" ]] || chmod +x "$host/$dst" added+=("$dst (the site cannot build without it)") @@ -560,6 +588,7 @@ main() { else copied+=("$dst") fi + plain_file "$host/$dst" cat "$new_w/website/$rel" > "$host/$dst" [[ ! -x "$new_w/website/$rel" ]] || chmod +x "$host/$dst" fi @@ -696,7 +725,7 @@ main() { ( rc=0 cd "$host/.lokf" - if [[ -x scripts/knowledge-preflight.sh ]]; then + if [[ -f scripts/knowledge-preflight.sh ]]; then echo "preflight: $(bash scripts/knowledge-preflight.sh | tail -1)" fi if command -v uv >/dev/null 2>&1; then diff --git a/.lokf/uv.lock b/.lokf/uv.lock index cae314d..fed4623 100644 --- a/.lokf/uv.lock +++ b/.lokf/uv.lock @@ -796,11 +796,11 @@ wheels = [ [[package]] name = "ktl" -version = "0.69.2" +version = "0.70.1" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/6f/f2/cb72906f948d1bf8cd0ddf36c6c7887b8d38501b5bb20a84d191a8864efd/ktl-0.69.2.tar.gz", hash = "sha256:60d2bb906f83bd0575ff4496042e226c2d511e1e5f68b0351887c0296d729784", size = 865055, upload-time = "2026-11-18T23:54:27.079Z" } +sdist = { url = "https://files.pythonhosted.org/packages/a4/fb/862f7b7667793c0016e2b369c68c20c60fe6852efda7c06938685a689bfb/ktl-0.70.1.tar.gz", hash = "sha256:766e4c224a74b83eca1c0888783ecb59f898ec0c9a85e6ade146cd014e778ca2", size = 865903, upload-time = "2026-11-19T02:21:15.672Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/e3/a5/006c3b870563f31ee2fb380addb9ef5a46cc2ca4aa91292a3dd8307a3ff5/ktl-0.69.2-py3-none-any.whl", hash = "sha256:dcf971f27d7487e74e4c4cd72296a000d0f0aab191d79693ddadb05d1c35acf4", size = 980702, upload-time = "2026-11-18T23:54:25.276Z" }, + { url = "https://files.pythonhosted.org/packages/51/ec/aac103aafc809e4072c80044bd849aa1552a8945f01d0490d5380fc8fd33/ktl-0.70.1-py3-none-any.whl", hash = "sha256:5fd25df258e66830cb7cfdb82460ba6d15b733b008922e8a1d9ac4280991699c", size = 981664, upload-time = "2026-11-19T02:21:13.769Z" }, ] [[package]] @@ -2027,7 +2027,7 @@ dependencies = [ [package.metadata] requires-dist = [ - { name = "ktl", specifier = "==0.69.2" }, + { name = "ktl", specifier = "==0.70.1" }, { name = "lokf", extras = ["build"], specifier = ">=0.9.0" }, { name = "rust-just", specifier = "==1.59.0" }, ] diff --git a/CHANGELOG.md b/CHANGELOG.md index 9873d29..497d8ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ The `v0.1.0` tag is a baseline, not a release: it marks where versioning starts ## [Unreleased] +### Security + +- **The sidecar copies and the skills pin are at Knowledge Trust Ladder [v0.70.1](https://github.com/noelmcloughlin/knowledge-trust-ladder/compare/v0.69.2...v0.70.1).** The release changed `.github/workflows/knowledge-release.yaml`, `.github/workflows/knowledge-sync.yaml`, `.lokf/scripts/knowledge-report.sh`, `.lokf/scripts/knowledge-sync.sh` and `.lokf/m365/ktl-docent-m365.md` here. + ## [0.11.4] - 2026-11-19 ### Security