fleet-kb: follow symlinked skill dirs so the corpus is the whole library (nix-config#1972) #2953

Open
hermes wants to merge 1 commit from kb/NCFG-1972-fleetkb-symlink into main
Collaborator

What

packages/fleet-kb-index/ingest.py::walk_skills called os.walk(root) with the default followlinks=False, so it never descended a skill directory that is a symlink — and in the shared library on vpn every installed skill is one (/var/lib/hermes/.hermes/skills/<category>/<skill> -> /nix/store/...-hermes-skills-<rev>/skills/...). The skill corpus therefore indexed only the real-directory part of the tree, and the aliases: routing chunk added for NCFGP#1879 was emitted for zero skills.

The skill corpus is the routing index for agent work: a skill the walk skips is a skill kb_search can never route to.

Measured (vpn, live root /var/lib/hermes/.hermes/skills)

probe before (origin/main 2f640240) after
find -L -name SKILL.md 391 391
find -name SKILL.md (no follow) 235 235
SKILL.md carrying an aliases: line, reachable 20 20
the same, reachable by the walk's own semantics 0 20
walk_skills() chunks=7168 sources=590 alias_chunks=0 chunks=16696 sources=1346 alias_chunks=20
--corpus skill --dry-run no alias_chunks field alias_chunks=20

How

  • _walk_dirs(): os.walk(root, followlinks=True) with a visited-inode guard. The guard is not decoration — the live tree carries two symlinks onto one store directory (following them without it double-indexes the skill; the schema is keyed on corpus/source/anchor) and a symlink back at the library root (without it the walk never terminates). It prunes the repeated directory, so a skill is indexed once however many links reach it.
  • --dry-run now reports alias_chunks, the number the card's DONE WHEN reads off the live host.
  • .forgejo/tests/test-fleet-kb-ingest-symlinks.py: the fixture is the shape of the live tree (a real category with a real skill, a symlinked skill under a real category, two links onto one store dir, a link back to the root) and it pins its own pre-fix arm — the module is re-loaded from a copy whose followlinks=True is rewritten to False and the symlinked skill must disappear from that arm. A suite that passed on the buggy code would prove nothing.

No workflow edit: forgejo-python-suites runs .forgejo/tests/test-*.py by GLOB, so the new suite is enforced by this PR. (test-reputation-ladder.py, landed today, is likewise unpinned; policy-gates.yml has two live foreign intents on it, so this PR stays off it.)

Card

nix-config#1972

## What `packages/fleet-kb-index/ingest.py::walk_skills` called `os.walk(root)` with the default `followlinks=False`, so it never descended a skill directory that is a symlink — and in the shared library on vpn **every installed skill is one** (`/var/lib/hermes/.hermes/skills/<category>/<skill> -> /nix/store/...-hermes-skills-<rev>/skills/...`). The skill corpus therefore indexed only the real-directory part of the tree, and the `aliases:` routing chunk added for NCFGP#1879 was emitted for **zero** skills. The skill corpus is the routing index for agent work: a skill the walk skips is a skill `kb_search` can never route to. ## Measured (vpn, live root `/var/lib/hermes/.hermes/skills`) | probe | before (`origin/main` 2f640240) | after | |---|---|---| | `find -L -name SKILL.md` | 391 | 391 | | `find -name SKILL.md` (no follow) | 235 | 235 | | `SKILL.md` carrying an `aliases:` line, reachable | 20 | 20 | | the same, reachable by the walk's own semantics | **0** | **20** | | `walk_skills()` | chunks=7168 sources=590 **alias_chunks=0** | chunks=16696 sources=1346 **alias_chunks=20** | | `--corpus skill --dry-run` | no `alias_chunks` field | `alias_chunks=20` | ## How - `_walk_dirs()`: `os.walk(root, followlinks=True)` with a visited-inode guard. The guard is not decoration — the live tree carries two symlinks onto one store directory (following them without it double-indexes the skill; the schema is keyed on `corpus/source/anchor`) and a symlink back at the library root (without it the walk never terminates). It prunes the repeated **directory**, so a skill is indexed once however many links reach it. - `--dry-run` now reports `alias_chunks`, the number the card's DONE WHEN reads off the live host. - `.forgejo/tests/test-fleet-kb-ingest-symlinks.py`: the fixture is the shape of the live tree (a real category with a real skill, a symlinked skill under a real category, two links onto one store dir, a link back to the root) and it pins **its own pre-fix arm** — the module is re-loaded from a copy whose `followlinks=True` is rewritten to `False` and the symlinked skill must disappear from that arm. A suite that passed on the buggy code would prove nothing. No workflow edit: `forgejo-python-suites` runs `.forgejo/tests/test-*.py` by GLOB, so the new suite is enforced by this PR. (`test-reputation-ladder.py`, landed today, is likewise unpinned; `policy-gates.yml` has two live foreign intents on it, so this PR stays off it.) ## Card nix-config#1972
fleet-kb: follow symlinked skill dirs so the corpus is the whole library (nix-config#1972)
All checks were successful
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 7s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 7s
PR base guard / Base drift / conflict check (pull_request) Successful in 18s
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 5s
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 5s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 6s
Secret Scan / gitleaks scan (pull_request) Successful in 13s
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 19s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 5s
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m17s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 5s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Successful in 1m47s
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 59s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 21s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Successful in 3m6s
NixOS Build Check / Gate summary (pull_request) Successful in 2s
Repo Gates / Repo gates (script-only battery) (pull_request) Successful in 5m15s
foremerge intent (advisory) all 2 changed path(s) covered by a live foremerge intent
44d3efb1a0
Every installed skill is a symlink into the store the skills converge
publishes (`<root>/<category>/<skill> -> /nix/store/...-hermes-skills-<rev>/skills/...`),
so `os.walk(root)` with the default `followlinks=False` descended only the
categories that happen to be real directories. The skill corpus therefore
held a fraction of the library, and the `aliases:` routing chunk added for
NCFGP#1879 was emitted for exactly zero skills.

Measured on vpn, same live root /var/lib/hermes/.hermes/skills:
  find -L: 391 SKILL.md, 20 of them carrying an `aliases:` line
  find   : 235 SKILL.md,  0 carrying one
  walk_skills before: chunks=7168 sources= 590 alias_chunks=0
  walk_skills after : chunks=16696 sources=1346 alias_chunks=20

`_walk_dirs()` follows symlinks with a visited-inode guard, because the
live tree also carries two symlinks onto one store directory and a symlink
back at the library root: following links without the guard duplicates the
first (the schema is keyed on corpus/source/anchor) and never terminates on
the second. The guard prunes the repeated DIRECTORY, so a skill is indexed
once no matter how many links reach it.

`--dry-run` now reports `alias_chunks`, which is the number the card's DONE
WHEN reads off the live host.

The regression suite pins the live shape (real category, symlinked skill,
two links onto one dir, link back to the root) and its own pre-fix arm: the
module is re-loaded from a copy whose `followlinks=True` is rewritten to
False, and the symlinked skill must disappear. A green run on the buggy code
would prove nothing.
All checks were successful
Policy Gates / Worker-scope reaper worker signature (mutation-tested) (pull_request) Successful in 7s
Policy Gates / Kanban pool capacity knob (runtime override + clamp, mutation-tested) (pull_request) Successful in 7s
PR base guard / Base drift / conflict check (pull_request) Successful in 18s
Required
Details
Policy Gates / Sentinel pass budget contract (prompt forbids the full board walk, mutation-tested) (pull_request) Successful in 5s
Policy Gates / CI-scratch reaper class table (mutation-tested) (pull_request) Successful in 5s
Policy Gates / Fleet cache sweep class table (mutation-tested) (pull_request) Successful in 6s
Secret Scan / gitleaks scan (pull_request) Successful in 13s
Required
Details
NixOS Build Check / Scope changed deployable hosts (pull_request) Successful in 19s
NixOS Build Check / Flake input regression guard (pull_request) Successful in 5s
Policy Gates / foremerge accept-order contract (real binary) (pull_request) Successful in 1m17s
Policy Gates / Scheduled foremerge reap command line (mutation-tested) (pull_request) Successful in 5s
NixOS Build Check / Hermes runtime gates (one eval of vpn's runtime) (pull_request) Successful in 1m47s
Policy Gates / .forgejo/tests python suites (hermetic) (pull_request) Successful in 59s
Policy Gates / Fleet control ledger (sealed profile fails the build, mutation-tested) (pull_request) Successful in 21s
NixOS Build Check / Build changed host closures (per-host budget) (pull_request) Successful in 3m6s
NixOS Build Check / Gate summary (pull_request) Successful in 2s
Required
Details
Repo Gates / Repo gates (script-only battery) (pull_request) Successful in 5m15s
foremerge intent (advisory) all 2 changed path(s) covered by a live foremerge intent
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin kb/NCFG-1972-fleetkb-symlink:kb/NCFG-1972-fleetkb-symlink
git switch kb/NCFG-1972-fleetkb-symlink
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ymrtech/nix-config!2953
No description provided.