Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

fix(context): suggest only anchored skills at prompt time

montjeffrey2a62742b02b2
diff --git a/docs/design/context-profile-delivery.md b/docs/design/context-profile-delivery.md
index 0765614f3..e238de80b 100644
--- a/docs/design/context-profile-delivery.md
+++ b/docs/design/context-profile-delivery.md
@@ -64,7 +64,7 @@ The task call sends the query and selected reference content on standard input t
## Prompt suggestions (opt-in hook)
-Ordinary interactive turns can receive advisory skill suggestions from a UserPromptSubmit hook. The hook prints up to three skill IDs with one-line descriptions and the `resolve` command to load one; it never returns a skill body, changes the saved mode or selection, or grants authority. Loading still goes through `resolve`, which re-verifies canonical sources.
+Ordinary interactive turns can receive advisory skill suggestions from a UserPromptSubmit hook. The hook prints up to three skill IDs with one-line descriptions and the `resolve` command to load one. Like implicit admission, a suggestion needs a matched term in the skill name or curated triggers, or an exact name; it never returns a skill body, changes the saved mode or selection, or grants authority. Loading still goes through `resolve`, which re-verifies canonical sources.
`ecc profile routing-index --state-root <store>` writes a metadata index for the current managed generation: the entries the resolver could suggest (not excluded, admissible without explicit selection), their curated triggers and precomputed retrieval vectors. Building refuses a store whose generation no longer matches the canonical sources. A small pointer named by the generation binds the index to the state receipt; the entries file is named by the SHA-256 of its bytes. A `set`, `mode` or `rollback` retires the index until it is rebuilt, and the hook then stays silent with a stderr diagnostic. `--dry-run` reports whether the current index exists.
diff --git a/docs/design/context-profile-delivery.tdd.md b/docs/design/context-profile-delivery.tdd.md
index 989eb863c..e00df0b64 100644
--- a/docs/design/context-profile-delivery.tdd.md
+++ b/docs/design/context-profile-delivery.tdd.md
@@ -103,6 +103,7 @@ The suggest-only prompt hook from #2945 now reads a generation-bound metadata in
- RED: routing-index and hook cases fail before the modules exist. GREEN adds a stored-vector key to the entry shape, a stale-source refusal and the session-start builder; all 16 cases pass, with a retrieval case proving stored vectors rank identically to computed ones.
- The resolver path took 300 to 500 ms per prompt from a source checkout, almost all in rehashing 293 skills and 584 files. Loading Ajv lazily and storing vectors moved the hook's own work to about 95 to 110 ms on a Full Claude index (276 entries, 1.8 MB); wrapper invocations measured 140 to 180 ms against a 71 ms disabled baseline on Linux x64.
+- RED: on the full registry the function-word prompt still produced three unanchored suggestions. GREEN applies the routing policy v5 anchor to suggestions; the prompt now yields none and a React keyboard-focus prompt still leads with `skill:frontend-a11y`.
- Selection, retrieval, profile CLI and hook-wrapper suites pass unchanged.
- No interactive Claude or Codex session loaded the hook; suggestion quality is bounded by the resolver ranking measured above.
diff --git a/scripts/lib/context-routing-index.js b/scripts/lib/context-routing-index.js
index 9ab251b84..c4742e715 100644
--- a/scripts/lib/context-routing-index.js
+++ b/scripts/lib/context-routing-index.js
@@ -103,10 +103,11 @@ function routingIndexStatus(stateRoot) {
const CONTROL_CHARACTERS = new RegExp('[\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029]+', 'g');
const singleLine = text => String(text).replace(CONTROL_CHARACTERS, ' ').replace(/\s+/g, ' ').trim();
-/** Rank index entries for a prompt. IDs and one-line descriptions only. */
+/** Rank index entries for a prompt. IDs and one-line descriptions only; like
+ * implicit admission, a suggestion needs a name or trigger anchor term. */
function suggestContext(index, prompt, { limit = MAX_SUGGESTIONS } = {}) {
return searchRetrieval(buildRetrievalIndex(index.entries), prompt, { limit: Math.min(limit, MAX_SUGGESTIONS) })
- .filter(candidate => /^skill:[a-z0-9]+(?:-[a-z0-9]+)*$/.test(candidate.id))
+ .filter(candidate => /^skill:[a-z0-9]+(?:-[a-z0-9]+)*$/.test(candidate.id) && (candidate.exact || candidate.anchorTerms.length > 0))
.map(candidate => {
const description = singleLine(candidate.description);
return { id: candidate.id,