mustflow 2.112.13 → 2.113.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/skill.js +13 -0
- package/dist/cli/lib/external-skill-import.js +194 -4
- package/package.json +1 -1
- package/schemas/skill-import-report.schema.json +75 -0
- package/templates/default/i18n.toml +6 -6
- package/templates/default/locales/en/.mustflow/skills/INDEX.md +16 -13
- package/templates/default/locales/en/.mustflow/skills/llm-token-cost-control-review/SKILL.md +62 -24
- package/templates/default/locales/en/.mustflow/skills/rag-pipeline-triage/SKILL.md +77 -23
- package/templates/default/locales/en/.mustflow/skills/search-index-integrity-review/SKILL.md +64 -14
- package/templates/default/locales/en/.mustflow/skills/security-privacy-review/SKILL.md +4 -1
- package/templates/default/locales/en/.mustflow/skills/vector-search-integrity-review/SKILL.md +59 -32
- package/templates/default/manifest.toml +1 -1
package/templates/default/locales/en/.mustflow/skills/llm-token-cost-control-review/SKILL.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
mustflow_doc: skill.llm-token-cost-control-review
|
|
3
3
|
locale: en
|
|
4
4
|
canonical: true
|
|
5
|
-
revision:
|
|
5
|
+
revision: 4
|
|
6
6
|
lifecycle: mustflow-owned
|
|
7
7
|
authority: procedure
|
|
8
8
|
name: llm-token-cost-control-review
|
|
9
|
-
description: Apply this skill when LLM API calls, prompt assembly, chat history, RAG context, tool schemas, structured output schemas, model routing, reasoning settings, token budgets, provider prompt caching, app-level response caching, retries, batch or flex processing, predicted outputs, image or file inputs, or LLM cost metrics are created, changed, reviewed, or reported and the risk is token spend or cost-per-success drifting out of control.
|
|
9
|
+
description: Apply this skill when LLM API calls, prompt assembly, chat history, RAG context, document metadata, chunk summaries, prompt packing, tool schemas, structured output schemas, model routing, reasoning settings, token budgets, provider prompt caching, app-level response caching, retries, batch or flex processing, predicted outputs, image or file inputs, or LLM cost metrics are created, changed, reviewed, or reported and the risk is token spend or cost-per-success drifting out of control.
|
|
10
10
|
metadata:
|
|
11
11
|
mustflow_schema: "1"
|
|
12
12
|
mustflow_kind: procedure
|
|
@@ -35,7 +35,7 @@ Review LLM cost as a product and systems contract, not as prompt brevity. A cost
|
|
|
35
35
|
<!-- mustflow-section: use-when -->
|
|
36
36
|
## Use When
|
|
37
37
|
|
|
38
|
-
- A change adds, edits, reviews, or reports an LLM request builder, prompt prefix, system or developer message, chat history assembly, memory compaction, RAG context, retrieved chunk packing, few-shot examples, tool definitions, structured output schema, image or file input, model selector, reasoning-effort setting, output limit, retry path, streaming or prediction path, batch processing path, flex or low-priority processing path, cache key, token counter, usage logger, cost dashboard, or LLM quota guard.
|
|
38
|
+
- A change adds, edits, reviews, or reports an LLM request builder, prompt prefix, system or developer message, chat history assembly, memory compaction, RAG context, retrieved chunk packing, document metadata, source maps, summary layers, few-shot examples, tool definitions, structured output schema, image or file input, model selector, reasoning-effort setting, output limit, retry path, streaming or prediction path, batch processing path, flex or low-priority processing path, cache key, token counter, usage logger, cost dashboard, or LLM quota guard.
|
|
39
39
|
- A task asks to reduce token cost, improve provider prompt-cache hit rate, lower cost per successful task, shrink context, split realtime and offline LLM work, route small tasks away from expensive models, or prevent a token bill spike.
|
|
40
40
|
- The product sends repeated instructions, examples, tool schemas, output schemas, documents, policies, conversation history, screenshots, files, or retrieved context to an LLM.
|
|
41
41
|
- The system records total tokens but cannot explain which feature, endpoint, model, prompt version, tool schema version, retry, or validation failure caused the spend.
|
|
@@ -55,9 +55,15 @@ Review LLM cost as a product and systems contract, not as prompt brevity. A cost
|
|
|
55
55
|
## Required Inputs
|
|
56
56
|
|
|
57
57
|
- Cost surface ledger: feature, endpoint, caller, model, provider, sync or async path, expected traffic shape, success definition, and current or target budget.
|
|
58
|
-
- Request ledger: stable instructions, examples, tools, schemas,
|
|
58
|
+
- Request ledger: stable instructions, examples, tools, schemas, authority lane for each block,
|
|
59
|
+
user input, retrieved context, memory, history, files, images, runtime metadata, volatile IDs,
|
|
60
|
+
dates, locale, and personalization fields.
|
|
59
61
|
- Cache ledger: provider prompt-cache eligibility, stable prefix boundary, canonical serialization, prompt version hash, tool and schema version, cache key policy, app-level response cache key, TTL, invalidation rule, and permission boundary.
|
|
60
|
-
- Context ledger: conversation-window rule,
|
|
62
|
+
- Context ledger: conversation-window rule, state-card fields, delta rule, inclusion test,
|
|
63
|
+
block role tags, document ids, frontmatter or metadata fields split by filter-only versus
|
|
64
|
+
LLM-visible use, summary layers, source maps, question-specific evidence cards, RAG top-k, chunk
|
|
65
|
+
size, chunk token counts, chunk ordering, evidence span policy, deduplication, compression,
|
|
66
|
+
prompt-packing rule, and current input-token measurement.
|
|
61
67
|
- Output ledger: output schema size, repeated key length, patch versus full-output policy, `max_output_tokens`, reasoning budget, retry repair inputs, validator errors, and incomplete-response handling.
|
|
62
68
|
- Routing ledger: deterministic prefilters, small-model router, expensive-model escalation rule, batch or flex eligibility, predicted-output eligibility, image or file preprocessing, and fallback behavior.
|
|
63
69
|
- Observability ledger: input tokens, cached tokens when exposed by the provider, output tokens, reasoning tokens when exposed or billable, retry count, validation failure count, cache hit rate, cost per successful task, model, endpoint, prompt version, tool version, schema version, and budget breach events.
|
|
@@ -75,7 +81,7 @@ Review LLM cost as a product and systems contract, not as prompt brevity. A cost
|
|
|
75
81
|
## Allowed Edits
|
|
76
82
|
|
|
77
83
|
- Refactor request assembly so stable instructions, examples, tool schemas, and output schemas are serialized before volatile user input, timestamps, request IDs, search results, personalization, and runtime metadata.
|
|
78
|
-
- Add or refine prompt version hashes, canonical serialization, provider cache keys, app-level cache keys, token counters, budget guards, model routers, context trimming, RAG chunk packing, output patch formats, retry repair paths, metrics, logs, tests, docs, route metadata, and directly synchronized templates.
|
|
84
|
+
- Add or refine prompt version hashes, canonical serialization, provider cache keys, app-level cache keys, token counters, token-budget metadata, budget guards, model routers, context trimming, RAG chunk packing, source-map references, original/index/prompt text separation, question-scoped compression, slot records, canonical block references, state snapshots, output patch formats, retry repair paths, metrics, logs, tests, docs, route metadata, and directly synchronized templates.
|
|
79
85
|
- Move deterministic work such as validation, parsing, enum mapping, deduplication, sorting, formatting, arithmetic, date math, and permission checks out of LLM calls when code can perform it.
|
|
80
86
|
- Add focused fixtures for cost-sensitive boundaries: cache-prefix drift, history growth, RAG chunk bloat, retry replay, oversized schema, full-file regeneration, image input size, and expensive-model routing.
|
|
81
87
|
- Do not rely on "make the prompt shorter" as the primary fix when repeated static payload, history replay, RAG bloat, retries, or output shape causes the spend.
|
|
@@ -88,29 +94,61 @@ Review LLM cost as a product and systems contract, not as prompt brevity. A cost
|
|
|
88
94
|
|
|
89
95
|
1. Name the cost unit. Decide whether the system optimizes per request, per successful task, per workflow, per user session, per batch job, or per tenant.
|
|
90
96
|
2. Measure before cutting. Prefer provider token-counting APIs, usage fields, or repository-local token accounting over character estimates, especially when tools, schemas, images, files, or reasoning models are involved.
|
|
91
|
-
3.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
97
|
+
3. Apply the output-changing test before packing context. If removing a document, transcript slice,
|
|
98
|
+
metadata field, example, or log would not change the answer, code, decision, citation, or
|
|
99
|
+
refusal state, keep it out of the model payload and preserve only a reference, count, or hash
|
|
100
|
+
when needed for traceability.
|
|
101
|
+
4. Keep authority lanes explicit. Stable rules, policies, and output contracts belong in
|
|
102
|
+
instruction blocks; user input, retrieved documents, examples, and tool observations belong in
|
|
103
|
+
tagged data blocks. Do not let retrieved text, examples, or summaries become equal-authority
|
|
104
|
+
instructions.
|
|
105
|
+
5. Split stable prefix from volatile suffix. Keep system and developer instructions, policy, examples, tool schemas, structured output schemas, and other repeated static context in a canonical stable order before user input, request IDs, dates, session IDs, retrieved snippets, and personalization.
|
|
106
|
+
6. Hash the expensive prefix. Record or derive a prompt version hash from canonical instructions, examples, tools, schemas, model settings, and output contract. If the hash varies per user without intent, treat it as cache-prefix drift.
|
|
107
|
+
7. Review provider prompt caching. Use provider cache keys only for requests that share the same stable prefix, distribute hot keys according to provider guidance, and log cached-token evidence when the provider exposes it.
|
|
108
|
+
8. Add app-level caching where identical normalized inputs can safely skip the model call. Include tenant, permission, locale, source version, policy version, and TTL in the cache key when they affect correctness.
|
|
109
|
+
9. Trim chat history by state, not by vibes. Keep recent turns, durable memory, active task state, confirmed user preferences, and unresolved tool results; avoid replaying full raw transcripts when a compact state is enough.
|
|
110
|
+
10. Shrink RAG by evidence span. Search broadly if needed, but pass the smallest source-backed spans that answer the question, deduplicate near-identical chunks, preserve source metadata, and use stable ordering when repeated workloads benefit from cache reuse.
|
|
111
|
+
Preserve conflicts with source, status, effective date, and authority instead of merging them into
|
|
112
|
+
one smooth but false summary.
|
|
113
|
+
11. Compress for the current question, not for the whole document. A refund-policy, implementation,
|
|
114
|
+
legal, and support answer may need different evidence from the same source; store the compression
|
|
115
|
+
goal, retained fields, dropped fields, and source coordinates.
|
|
116
|
+
12. Use evidence cards before raw chunks when the product can validate them. Include claim,
|
|
117
|
+
conditions, exceptions, numbers, source ids, section or line span, quote hash, and token count.
|
|
118
|
+
Expand the original source only when the answer, citation, or validator needs it.
|
|
119
|
+
13. Convert repetitive prose to structured slots. Prefer `condition`, `action`, `limit`,
|
|
120
|
+
`exception`, `source_ref`, and `confidence` fields over sentence-shaped padding when downstream
|
|
121
|
+
code or prompts consume rules.
|
|
122
|
+
14. Use state snapshots plus deltas. Carry the compact current state and the newest change rather
|
|
123
|
+
than replaying the full transcript or sending only a delta that has lost its baseline.
|
|
124
|
+
15. Put critical evidence where the model will see it. Do not bury the only decisive constraint in
|
|
125
|
+
the middle of a long context; put key evidence early and restate final hard constraints near the
|
|
126
|
+
end when the prompt shape is long.
|
|
127
|
+
16. Separate original, index, and prompt text. Keep original spans for evidence, enriched `index_text` for search recall, and compact `prompt_text` for model input. Do not let search-only synonyms or generated summaries look like original quoted evidence.
|
|
128
|
+
Keep search/filter metadata separate from LLM-visible metadata; tags, IDs, ACL fields, and
|
|
129
|
+
operational paths should reach the model only when they change the output or citation.
|
|
130
|
+
17. Pack by references before raw text. Prefer stable document ids, chunk ids, section anchors, source maps, block refs, and token counts when choosing context. Expand only the needed source spans instead of replaying a whole corpus or full document list.
|
|
131
|
+
18. Keep tool and schema payloads boring. Tool descriptions and JSON schemas should be long enough for correct routing and validation but not narrative prose. If permissions differ by user, keep schema stable and enforce permission at tool execution.
|
|
132
|
+
19. Route before calling the expensive model. Use deterministic code, regexes, database lookups, small models, or cheap classifiers for tasks that do not need a large reasoning model; escalate only ambiguous, high-value, or failed cases.
|
|
133
|
+
20. Budget reasoning and output together. Set reasoning effort and output limits according to task value; leave enough room for visible output, and handle incomplete responses instead of silently retrying the full expensive request.
|
|
134
|
+
21. Prefer patches over full regeneration when the product already owns most of the output. Use unified diff, JSON Patch, line-range replacement, IDs, labels, scores, or reason codes when downstream code can merge the result.
|
|
135
|
+
22. Repair failures without full replay. For parse failures, enum mismatches, missing fields, or validator errors, retry with previous output, validator error, and schema summary when safe instead of resending the entire original context.
|
|
136
|
+
23. Separate realtime and offline work. Move evals, bulk classification, enrichment, embeddings, report backfills, and log analysis to configured async, batch, or low-priority processing when user latency does not matter.
|
|
137
|
+
24. Treat predicted outputs as a latency tool unless current provider docs and usage evidence show cost behavior for the exact model and endpoint. Use `llm-response-latency-review` when the main goal is faster completion rather than cost control. Watch rejected prediction tokens or equivalent fields when exposed.
|
|
138
|
+
25. Reduce image and file input before the model. Crop screenshots, downsample where acceptable, extract DOM text or OCR first, and count the actual payload tokens when the provider supports it.
|
|
139
|
+
26. Evaluate compression as loss, not as style. Compare compressed and uncompressed answers on
|
|
140
|
+
answer exactness, citation recall, numeric accuracy, constraint violations, and correct refusals.
|
|
141
|
+
27. Instrument cost per success. Track endpoint, model, prompt version, tool version, schema version, corpus version, index version, source hash, input tokens, cached tokens, output tokens, reasoning tokens, retry count, validation failure rate, cache hit rate, and successful-task denominator.
|
|
142
|
+
28. When prompt-cache layout changes, run the configured prompt-cache audit intent if available and treat byte or token estimates as static layout evidence rather than provider billing proof.
|
|
143
|
+
29. Verify with the narrowest configured tests, fixtures, docs validation, release checks, and mustflow validation that cover request assembly, cache keys, budget guards, routing, retry repair, telemetry, and installed skill surfaces.
|
|
108
144
|
|
|
109
145
|
<!-- mustflow-section: postconditions -->
|
|
110
146
|
## Postconditions
|
|
111
147
|
|
|
112
148
|
- Stable LLM payload is separated from volatile data, hashed or versioned where useful, and cacheable by design when the provider supports prompt caching.
|
|
113
149
|
- Long context, chat history, RAG evidence, tools, schemas, files, images, reasoning, output, retries, and routing each have an explicit budget or reduction rule where relevant.
|
|
150
|
+
- Retrieved context distinguishes original evidence, enriched index text, prompt-ready text, question-specific evidence cards, source-map references, token counts, block references, and summary layers.
|
|
151
|
+
- Compression quality is evaluated against answer, citation, numeric, constraint, and refusal behavior rather than judged by shorter text alone.
|
|
114
152
|
- Deterministic work is handled outside the model unless language judgment is required.
|
|
115
153
|
- Metrics can explain cost per successful task, cache-prefix drift, retry cost, validation failures, and model routing decisions without leaking sensitive prompt or user data.
|
|
116
154
|
- Final reports distinguish proven cost-control evidence from assumed provider behavior, anecdotal token savings, and latency-only optimizations.
|
|
@@ -149,7 +187,7 @@ Use the narrowest configured fixture, unit, integration, telemetry, docs, packag
|
|
|
149
187
|
- LLM token-cost surface reviewed
|
|
150
188
|
- Cost unit, budget, and measurement source
|
|
151
189
|
- Stable prefix, volatile suffix, prompt hash, and provider cache behavior checked
|
|
152
|
-
- App cache, history, RAG, tool schema, structured schema, image or file input, and deterministic prefilter choices checked
|
|
190
|
+
- App cache, history, RAG, metadata, source-map, prompt-packing, tool schema, structured schema, image or file input, and deterministic prefilter choices checked
|
|
153
191
|
- Model routing, reasoning effort, output limit, patch-output, retry repair, Batch, Flex, and prediction choices checked
|
|
154
192
|
- Cost observability fields and sensitive-data redaction checked
|
|
155
193
|
- Files changed
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
mustflow_doc: skill.rag-pipeline-triage
|
|
3
3
|
locale: en
|
|
4
4
|
canonical: true
|
|
5
|
-
revision:
|
|
5
|
+
revision: 3
|
|
6
6
|
lifecycle: mustflow-owned
|
|
7
7
|
authority: procedure
|
|
8
8
|
name: rag-pipeline-triage
|
|
9
|
-
description: Apply this skill when a RAG, knowledge-base answer, grounded chat, citation answer, retrieval-augmented support bot, or document QA flow is wrong, stale, unsupported, slow, leaking data, over-refusing, or not yet localized to ingestion, parsing, chunking, retrieval, filtering, reranking, context assembly, prompt construction, generation, citation validation, or answerability boundaries.
|
|
9
|
+
description: Apply this skill when a RAG, knowledge-base answer, grounded chat, citation answer, retrieval-augmented support bot, or document QA flow is wrong, stale, unsupported, slow, leaking data, over-refusing, or not yet localized to ingestion, parsing, document metadata, source maps, chunking, retrieval, filtering, reranking, context assembly, prompt construction, generation, citation validation, or answerability boundaries.
|
|
10
10
|
metadata:
|
|
11
11
|
mustflow_schema: "1"
|
|
12
12
|
mustflow_kind: procedure
|
|
@@ -46,6 +46,9 @@ survive filtering and context assembly, and constrain the answer?"
|
|
|
46
46
|
generation, validators, citations, answerability, or access control.
|
|
47
47
|
- A review would otherwise tune the model, top-k, chunk size, reranker, or prompt before proving
|
|
48
48
|
which RAG layer failed.
|
|
49
|
+
- A document corpus, frontmatter contract, search index, chunk schema, ACL model, or prompt-packing
|
|
50
|
+
rule is being reviewed because token bloat, retrieval misses, stale context, or unsupported
|
|
51
|
+
citations may come from poor document structure rather than model behavior.
|
|
49
52
|
|
|
50
53
|
<!-- mustflow-section: do-not-use-when -->
|
|
51
54
|
## Do Not Use When
|
|
@@ -70,9 +73,14 @@ survive filtering and context assembly, and constrain the answer?"
|
|
|
70
73
|
context, filters, embedding model version, index version, candidate ids and scores, reranker
|
|
71
74
|
output, final context ids and order, prompt version, model version, answer, citations, validators,
|
|
72
75
|
latency, and cost when safe.
|
|
73
|
-
- Source ledger: authoritative source availability,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
- Source ledger: authoritative source availability, original text, parsed text, index text,
|
|
77
|
+
prompt text, source id, stable doc id, chunk id, parent document genealogy, chunk boundaries,
|
|
78
|
+
frontmatter or metadata schema, document type, status, authority, source-of-truth flag, title,
|
|
79
|
+
aliases, exact keywords, synthetic questions, negative metadata, heading path, breadcrumb ids or
|
|
80
|
+
text, source map, parent and adjacent chunks, section or document summaries, routing summaries,
|
|
81
|
+
lifecycle owner, version, revision, supersedes or superseded-by links, content hash, index
|
|
82
|
+
freshness, published and effective dates, stale or deleted documents, duplicates, and
|
|
83
|
+
conflicting sources.
|
|
76
84
|
- Comparison ledger: no-retrieval answer, retrieved-context answer, human-selected gold-context
|
|
77
85
|
answer, exact or keyword search result, vector search result, hybrid result, and expected
|
|
78
86
|
answerability state.
|
|
@@ -93,10 +101,11 @@ survive filtering and context assembly, and constrain the answer?"
|
|
|
93
101
|
<!-- mustflow-section: allowed-edits -->
|
|
94
102
|
## Allowed Edits
|
|
95
103
|
|
|
96
|
-
- Add or tighten trace fields, fixture queries, parsing checks,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
104
|
+
- Add or tighten trace fields, fixture queries, parsing checks, semantic or structure-aware chunking,
|
|
105
|
+
chunk metadata, frontmatter schemas, source maps, parent-child or adjacent chunk links,
|
|
106
|
+
ACL-prefilter checks, duplicate or stale source handling, retrieval comparisons, filter checks,
|
|
107
|
+
context-packing rules, prompt source separation, citation validators, answerability states, dirty
|
|
108
|
+
eval fixtures, metrics, docs, and directly synchronized templates.
|
|
100
109
|
- Add safe synthetic fixtures for missing-doc, correct-doc-unused, stale-doc, conflicting-doc,
|
|
101
110
|
unauthorized-doc, exact-id, keyword, vector, hybrid, reranker, citation, and abstain behavior.
|
|
102
111
|
- Do not change models, re-embed data, rebuild production indexes, widen access filters, disable
|
|
@@ -117,34 +126,74 @@ survive filtering and context assembly, and constrain the answer?"
|
|
|
117
126
|
headers, footers, and OCR can be broken even when the original file looks correct.
|
|
118
127
|
5. Inspect chunk boundaries and metadata. Verify title, parent section, version, dates, audience,
|
|
119
128
|
product, source authority, and neighboring context survive into chunks or parent retrieval.
|
|
120
|
-
6.
|
|
129
|
+
6. Check whether a single chunk can stand on its own. Each answerable chunk should carry enough
|
|
130
|
+
product, feature, version, lifecycle, and heading context that retrieval does not depend on the
|
|
131
|
+
model guessing the missing subject from a previous chunk.
|
|
132
|
+
7. Review headings as coordinates. Generic headings such as overview, details, or notes are weak
|
|
133
|
+
retrieval features; heading paths and breadcrumbs should name the product, workflow, rule, and
|
|
134
|
+
exception boundary that make the chunk answerable.
|
|
135
|
+
8. Separate original, index, and prompt text. The original span is evidence, enriched index text is
|
|
136
|
+
search bait, and prompt text is the compact model payload. Do not cite generated summaries,
|
|
137
|
+
aliases, or synonym-expanded text as if they were original source.
|
|
138
|
+
9. Check source maps and chunk graph. Verify file path or URL, section anchor, line or page span,
|
|
139
|
+
content hash, parent chunk, previous chunk, next chunk, and summary layer can lead back to the
|
|
140
|
+
source without loading the whole corpus.
|
|
141
|
+
10. Check document identity and lifecycle before merging evidence. Keep `source_id`, `doc_id`, and
|
|
142
|
+
`chunk_id` distinct; preserve rename-stable ids, `doc_type`, `status`, `authority`,
|
|
143
|
+
`source_of_truth`, `supersedes`, `superseded_by`, `valid_until`, and effective-date fields so
|
|
144
|
+
stale, draft, example, discussion, and canonical documents are not averaged into one answer.
|
|
145
|
+
11. Treat summaries as routers, not proof. A summary should carry what the document can answer,
|
|
146
|
+
what it cannot answer, entities, decisions, exceptions, related docs, deprecated content,
|
|
147
|
+
conditions, actions, numbers, and exact source coordinates; if it ages separately from the
|
|
148
|
+
source, classify the failure as stale entrance metadata before changing retrieval settings.
|
|
149
|
+
12. Check exact keywords and aliases. Error codes, SKU values, API paths, function names, legal
|
|
150
|
+
references, old product names, and user slang should be searchable without relying on embeddings.
|
|
151
|
+
13. For code corpora, preserve structure. Function, class, import, caller, callee, type, test, and
|
|
152
|
+
config-key boundaries should guide chunks; fixed line-count slicing that cuts through symbols is
|
|
153
|
+
retrieval damage, not neutral preprocessing.
|
|
154
|
+
14. For table, slide, and PDF corpora, preserve record shape. Row, column, unit, plan, page, and
|
|
155
|
+
figure context should be repeated in parsed/index text so a number is not retrieved without its
|
|
156
|
+
meaning.
|
|
157
|
+
15. Check rules beside exceptions. If prohibitions, limits, or jurisdiction exclusions live far away
|
|
158
|
+
from the rule they modify, context assembly may retrieve only the rule and miss the exception.
|
|
159
|
+
16. Check ACL before retrieval. Tenant, visibility, sensitivity, retention, and user or group access
|
|
160
|
+
must be inherited from documents to chunks and applied before candidate text reaches the model.
|
|
161
|
+
17. Compare source versions and deletes. Duplicates, obsolete documents, tombstones, and conflicting
|
|
121
162
|
effective dates must not be silently mixed into one answer.
|
|
122
|
-
|
|
163
|
+
Preserve conflicting sources with their priority, status, and effective date instead of
|
|
164
|
+
smoothing them into a synthesized rule.
|
|
165
|
+
18. Run the isolation comparison when evidence is available: no retrieval, current retrieved context,
|
|
123
166
|
and human-selected gold context. Gold-context failure points to generation or prompt; current
|
|
124
167
|
context failure with gold success points to retrieval or context assembly.
|
|
125
|
-
|
|
168
|
+
19. Compare keyword, vector, hybrid, and exact-id retrieval by data shape. IDs, error codes, SKUs,
|
|
126
169
|
names, dates, and numbers need exact or lexical safeguards; semantic questions may need vector or
|
|
127
170
|
hybrid retrieval.
|
|
128
|
-
|
|
171
|
+
20. Check filters before blaming embeddings. Record pre-filter candidate count, post-filter count,
|
|
129
172
|
tenant and permission filters, metadata types, time zones, empty arrays, case sensitivity, and
|
|
130
173
|
stale policy copies.
|
|
131
|
-
|
|
174
|
+
21. Check reranker candidate starvation. If the correct source never enters the candidate set, the
|
|
132
175
|
reranker cannot fix it. If it enters and then drops, inspect reranker inputs and scoring.
|
|
133
|
-
|
|
176
|
+
22. Check context assembly. Verify `top_k`, score thresholds, source order, truncation, deduping,
|
|
134
177
|
conflict handling, source authority, and whether important evidence is buried or cut off.
|
|
135
|
-
|
|
178
|
+
23. Check prompt construction. User input, retrieved text, examples, tool observations, and system or
|
|
136
179
|
developer instructions must remain separated. Retrieved text is data, not authority.
|
|
137
|
-
|
|
180
|
+
24. Check answerability and abstain behavior. Track no-evidence, low-confidence, conflicting-source,
|
|
138
181
|
stale-source, access-denied, tool-failed, and needs-human states separately.
|
|
139
|
-
|
|
182
|
+
25. Validate citations claim-by-claim. A citation id proves nothing unless the cited chunk supports
|
|
140
183
|
the specific generated claim.
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
184
|
+
26. Measure each layer separately. Track parsing success, metadata completeness, ACL inheritance,
|
|
185
|
+
index freshness, hit rate, Recall@k, MRR, precision, nDCG, rerank survival, context precision,
|
|
186
|
+
context recall, faithfulness, groundedness, answer relevance, context token budget, answer
|
|
187
|
+
accuracy, citation accuracy, abstain accuracy, access leaks, and retrieval/rerank/generation
|
|
188
|
+
latency and cost.
|
|
189
|
+
27. Check the document graph for multi-hop questions. PRDs, ADRs, issues, code modules, runbooks,
|
|
190
|
+
changelogs, incidents, and meeting notes should link decisions, implementation, ownership,
|
|
191
|
+
exceptions, and follow-up operations instead of forcing retrieval to infer relationships from
|
|
192
|
+
nearby words.
|
|
193
|
+
28. Use dirty eval cases from real failures. Include typos, abbreviations, multilingual questions,
|
|
145
194
|
unanswerable questions, date-sensitive questions, similar names, product codes, multi-hop
|
|
146
195
|
questions, unauthorized documents, stale documents, and conflicting documents.
|
|
147
|
-
|
|
196
|
+
29. Apply the smallest localized fix and switch to the narrower matching skill for retrieval,
|
|
148
197
|
hallucination control, prompt contract, token cost, latency, access control, or prompt-injection
|
|
149
198
|
defense once the boundary is known.
|
|
150
199
|
|
|
@@ -155,6 +204,11 @@ survive filtering and context assembly, and constrain the answer?"
|
|
|
155
204
|
reranking, context assembly, prompt construction, generation, citation validation, answerability,
|
|
156
205
|
access control, or a named evidence gap.
|
|
157
206
|
- Trace, source, comparison, eval, metric, and privacy ledgers are explicit where relevant.
|
|
207
|
+
- Document metadata, frontmatter schema, stable source/doc/chunk ids, document type, status,
|
|
208
|
+
authority, source-of-truth, effective dates, supersession links, heading paths, source maps, ACL
|
|
209
|
+
inheritance, original/index/prompt text separation, exact keywords, aliases, negative metadata,
|
|
210
|
+
routing summaries, summary layers, chunk adjacency, document graph links, and index freshness are
|
|
211
|
+
explicit where relevant.
|
|
158
212
|
- Model, prompt, chunk, top-k, reranker, or index changes are justified by layer evidence rather than
|
|
159
213
|
by general "RAG quality" claims.
|
|
160
214
|
|
package/templates/default/locales/en/.mustflow/skills/search-index-integrity-review/SKILL.md
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
mustflow_doc: skill.search-index-integrity-review
|
|
3
3
|
locale: en
|
|
4
4
|
canonical: true
|
|
5
|
-
revision:
|
|
5
|
+
revision: 3
|
|
6
6
|
lifecycle: mustflow-owned
|
|
7
7
|
authority: procedure
|
|
8
8
|
name: search-index-integrity-review
|
|
9
|
-
description: Apply this skill when keyword search, full-text search, Elasticsearch, OpenSearch, Lucene-style indexes, search APIs, indexing pipelines, aliases, bulk indexing, refresh visibility, analyzers, mappings, synonyms, autocomplete, pagination, shard failures, search quality, or search performance are created, changed, reviewed, or failing. Use vector-search-integrity-review first for vector-only or semantic retrieval mechanics, and use rag-pipeline-triage first when a RAG failure is not yet localized to search retrieval.
|
|
9
|
+
description: Apply this skill when keyword search, full-text search, Elasticsearch, OpenSearch, Lucene-style indexes, search APIs, indexing pipelines, source maps, metadata taxonomy, aliases, bulk indexing, refresh visibility, analyzers, mappings, synonyms, autocomplete, pagination, shard failures, search quality, or search performance are created, changed, reviewed, or failing. Use vector-search-integrity-review first for vector-only or semantic retrieval mechanics, and use rag-pipeline-triage first when a RAG failure is not yet localized to search retrieval.
|
|
10
10
|
metadata:
|
|
11
11
|
mustflow_schema: "1"
|
|
12
12
|
mustflow_kind: procedure
|
|
@@ -55,7 +55,13 @@ The core question is whether a source record can be changed, accepted by the ind
|
|
|
55
55
|
- Symptom classification: source not indexed, write not visible, wrong alias, partial shard result, wrong exact match, wrong full-text match, ranking drift, zero results, stale delete, tenant leak, autocomplete failure, deep-page failure, slow query, bulk rejection, mapping conflict, or UI/API mismatch.
|
|
56
56
|
- Source-to-search ledger: source id, tenant, category, status, update time, indexing request time, bulk item result, indexed document id, direct lookup result, first search-visible time, rank, delete or tombstone state, and visibility lag.
|
|
57
57
|
- Query contract ledger: user-facing API path, direct search request, API-transformed request, UI result shaping, index or alias, tenant and permission filters, analyzed fields, exact fields, sort, pagination mode, source fields, highlight fields, cache state, and expected result ids.
|
|
58
|
-
- Index contract ledger: read alias, write alias, index templates, mappings, analyzers, normalizers,
|
|
58
|
+
- Index contract ledger: read alias, write alias, index templates, mappings, analyzers, normalizers,
|
|
59
|
+
exact id fields, exact keyword fields, facet fields, filter-only metadata, embedding-header
|
|
60
|
+
metadata, citation metadata, negative metadata, taxonomy fields, controlled vocabulary, metadata
|
|
61
|
+
key budget, stable source id, document id, chunk id when applicable, alias or synonym tables,
|
|
62
|
+
source-map fields, published/effective/indexed/verified dates, version fields, content hash,
|
|
63
|
+
schema version, index version, dynamic mapping policy, refresh policy, shard and replica plan,
|
|
64
|
+
segment or merge state, disk watermark risk, and rollover or reindex status.
|
|
59
65
|
- Quality ledger: representative queries, expected results, acceptable alternatives, zero-result expectations, Precision@K, Recall@K, MRR or ranking metric, before/after comparison, click or behavior metric limitations, and golden-set fixture status.
|
|
60
66
|
- Performance ledger: cold and warm latency, p50, p95, p99, search server time, API time, UI time, query phase, fetch phase, response size, shard fan-out, thread-pool active/queue/rejected, slow-log or query-profile evidence, cache hit or miss, and retry behavior.
|
|
61
67
|
- Privacy ledger: raw query text, document text, tenant ids, user ids, behavior analytics, search logs, highlights, and whether evidence can be stored safely as synthetic fixtures, ids, hashes, summaries, or aggregate metrics.
|
|
@@ -71,7 +77,12 @@ The core question is whether a source record can be changed, accepted by the ind
|
|
|
71
77
|
<!-- mustflow-section: allowed-edits -->
|
|
72
78
|
## Allowed Edits
|
|
73
79
|
|
|
74
|
-
- Add or tighten search canaries, indexing ledgers, bulk item error handling, alias checks, mapping
|
|
80
|
+
- Add or tighten search canaries, indexing ledgers, bulk item error handling, alias checks, mapping
|
|
81
|
+
and analyzer fixtures, metadata taxonomy checks, frontmatter schema checks,
|
|
82
|
+
controlled-vocabulary fixtures, exact-keyword fixtures, negative-metadata filters,
|
|
83
|
+
exact-versus-full-text tests, tenant and permission filter tests, golden-set tests, synonym
|
|
84
|
+
regression tests, pagination guards, query and miss-log metrics, search latency metrics, docs,
|
|
85
|
+
and directly synchronized templates.
|
|
75
86
|
- Add focused synthetic fixtures that encode expected exact search, full-text search, analyzer behavior, synonym behavior, filtered search, tenant isolation, zero-result behavior, pagination stability, and ranking order.
|
|
76
87
|
- Do not change analyzer, synonym, refresh, alias, shard, cache, or ranking settings blindly. First preserve source-to-search, query-contract, quality, and performance evidence.
|
|
77
88
|
- Do not force every write to refresh immediately unless the product contract explicitly needs synchronous visibility and the indexing cost is accepted.
|
|
@@ -108,31 +119,64 @@ The core question is whether a source record can be changed, accepted by the ind
|
|
|
108
119
|
9. Inspect mappings and analyzers before changing queries.
|
|
109
120
|
- IDs, emails, status codes, tags, and exact filters usually need keyword-like fields.
|
|
110
121
|
- Human text usually needs text analysis. Use analyzer evidence or fixtures to prove tokenization for punctuation, case, hyphen, Korean spacing, product codes, and mixed alphanumeric text.
|
|
111
|
-
10. Review
|
|
122
|
+
10. Review metadata taxonomy and controlled vocabulary.
|
|
123
|
+
- Distinguish filter fields, facet fields, ranking fields, display fields, and source-map fields.
|
|
124
|
+
- Canonical keys, aliases, synonyms, old names, and related terms should be explicit so free-form tags do not become five spellings of the same concept.
|
|
125
|
+
- Treat tags as filter conditions, not vibes. Reject values such as important, misc, final, or
|
|
126
|
+
reference unless they have a controlled, queryable meaning.
|
|
127
|
+
- Keep the metadata key set small enough that writers can fill it consistently; separate a
|
|
128
|
+
core filter set from optional enrichment instead of accepting unbounded ad hoc keys.
|
|
129
|
+
11. Split metadata by job.
|
|
130
|
+
- Filter metadata should be typed and exact; context headers should help lexical and semantic
|
|
131
|
+
recall; citation metadata should point back to source spans.
|
|
132
|
+
- Do not put every metadata key into analyzed text. Select title, section, entity, date, type,
|
|
133
|
+
and other disambiguators; keep volatile, private, or filter-only fields out of recall text.
|
|
134
|
+
- Keep LLM-visible metadata separate from search/filter metadata when the index feeds RAG.
|
|
135
|
+
Operational paths, ACL fields, tenant IDs, and internal ids should not become answer text
|
|
136
|
+
unless they change citation, permission, or disambiguation.
|
|
137
|
+
12. Separate path hints from state fields.
|
|
138
|
+
- Paths may encode tenant, visibility, lifecycle, source, language, or date for operations, but
|
|
139
|
+
`status`, `is_current`, `effective_from`, `effective_to`, `published_at`, `indexed_at`,
|
|
140
|
+
`last_verified_at`, `version`, and `revision` should remain first-class filter fields.
|
|
141
|
+
- File names are human hints; stable ids are machine keys. Renames, storage moves, and reindex
|
|
142
|
+
jobs should not break citations, deletes, feedback logs, or eval sets.
|
|
143
|
+
13. Review negative metadata and lifecycle filters.
|
|
144
|
+
- Visibility, audience, jurisdiction exclusions, draft/deprecated state, retention, and security
|
|
145
|
+
class are search correctness gates, not decoration.
|
|
146
|
+
- A good search result that should not have been eligible is a security or product bug.
|
|
147
|
+
14. Preserve source maps and freshness fields.
|
|
148
|
+
- Store document id, chunk id when applicable, file or URL, section anchor, line or page span, content hash, schema or index version, and last indexed time so stale or unsupported results can be traced.
|
|
149
|
+
15. Review exact keyword fields separately from analyzed text.
|
|
150
|
+
- Error codes, API paths, legal references, ticket ids, SKU values, class or function names, and
|
|
151
|
+
deprecated names need exact or keyword search coverage even when semantic retrieval exists.
|
|
152
|
+
16. Review synonym and ranking changes against a golden set.
|
|
112
153
|
- Synonyms can improve one query and break many others.
|
|
113
154
|
- Compare representative queries before and after; include zero-result, typo, ambiguous, category, brand, long natural-language, and high-value queries.
|
|
114
|
-
|
|
155
|
+
17. Use query, miss, and click logs as improvement evidence without leaking raw private text.
|
|
156
|
+
- Track query family, normalized terms, filters, zero-result rate, clicked ids, used chunks, fallback reason, and answer success where safe.
|
|
157
|
+
- Do not turn private queries or highlights into fixtures unless they are redacted or synthetic.
|
|
158
|
+
18. Explain surprising ranks only for bounded cases.
|
|
115
159
|
- Inspect why one expected document ranked below another for a small failing sample.
|
|
116
160
|
- Do not enable expensive explain or profile behavior for broad production traffic.
|
|
117
|
-
|
|
161
|
+
19. Separate query, fetch, API, and UI latency.
|
|
118
162
|
- p50, p95, and p99 must be grouped by search type, index, route, role, tenant class, and query fingerprint where safe.
|
|
119
163
|
- Fetch time, source size, highlight fields, nested fields, and response shaping can dominate score calculation.
|
|
120
|
-
|
|
164
|
+
20. Fingerprint query shapes.
|
|
121
165
|
- Remove raw IDs, dates, user text, and tenant secrets before grouping.
|
|
122
166
|
- Store query family, index, role, shard count, cache state, source fields, sort, and filter shape so one feature cannot hide across millions of unique queries.
|
|
123
|
-
|
|
167
|
+
21. Check shard fan-out, thread pools, segments, cache, and disk.
|
|
124
168
|
- Search across hundreds of tiny shards, stale segments, merge backlog, cold caches, search queue rejections, hot shards, and disk watermarks can look like application bugs.
|
|
125
169
|
- Separate cold and warm measurements; cached benchmarks are not full search evidence.
|
|
126
|
-
|
|
170
|
+
22. Review refresh and visibility policy.
|
|
127
171
|
- Indexing success is not search visibility.
|
|
128
172
|
- Use synchronous visibility only for writes whose user contract needs it; otherwise define acceptable visibility lag and measure it.
|
|
129
|
-
|
|
173
|
+
23. Review pagination and result payloads.
|
|
130
174
|
- Avoid deep offset pagination as a default product contract.
|
|
131
175
|
- Use stable tie-breakers for cursor-like pagination, and limit source fields and highlights to what the UI needs.
|
|
132
|
-
|
|
176
|
+
24. Keep vector and hybrid boundaries explicit.
|
|
133
177
|
- If dense vectors, ANN, reranking, hybrid score fusion, or Recall@K drives the failure, switch to `vector-search-integrity-review` for that slice.
|
|
134
178
|
- If the bug is ordinary keyword indexing, alias, analyzer, source filtering, or shard partials, keep this skill as the primary route.
|
|
135
|
-
|
|
179
|
+
25. Define numeric SLOs and destructive drills when in scope.
|
|
136
180
|
- Useful examples include indexing-to-search-visible p95, search p99, zero-result rate, partial shard failure rate, top-result duplication, golden-set metric, bulk item failure rate, and reindex reconciliation lag.
|
|
137
181
|
- Live node kills, disk pressure, alias mistakes, mapping conflicts, and mass reindex drills are manual unless the command contract declares them.
|
|
138
182
|
|
|
@@ -140,6 +184,10 @@ The core question is whether a source record can be changed, accepted by the ind
|
|
|
140
184
|
## Postconditions
|
|
141
185
|
|
|
142
186
|
- The search symptom, source-to-search ledger, query contract, index contract, quality ledger, performance ledger, and privacy boundary are explicit.
|
|
187
|
+
- Metadata taxonomy, metadata key budget, schema versions, stable source/doc/chunk ids, canonical
|
|
188
|
+
keys, aliases, exact keyword fields, filter-only versus LLM-visible metadata, lifecycle and
|
|
189
|
+
effective-date fields, negative metadata, source maps, index version, content hash, query logs,
|
|
190
|
+
and miss logs are explicit where relevant.
|
|
143
191
|
- Bulk item errors, source/index reconciliation, direct lookup, exact search, full-text search, aliases, partial shards, API/UI transformation, mappings, analyzers, synonyms, ranking, pagination, source payload, shard fan-out, thread-pool pressure, cache state, refresh visibility, segments, disk, and SLO evidence are fixed or reported where relevant.
|
|
144
192
|
- Search claims are backed by configured tests, fixtures, golden-set evidence, static review, safe canary evidence, or labeled manual-only or missing.
|
|
145
193
|
|
|
@@ -173,7 +221,9 @@ Prefer the narrowest configured tests that cover search contract, tenant isolati
|
|
|
173
221
|
|
|
174
222
|
- Search index integrity reviewed
|
|
175
223
|
- Symptom, source-to-search ledger, query contract, index contract, quality ledger, performance ledger, and privacy boundary
|
|
176
|
-
- Bulk, reconciliation, lookup, exact/full-text, alias, shard, API/UI, mapping, analyzer,
|
|
224
|
+
- Bulk, reconciliation, lookup, exact/full-text, alias, shard, API/UI, mapping, analyzer, taxonomy,
|
|
225
|
+
source-map, synonym, ranking, pagination, payload, query-log, shard fan-out, thread-pool, cache,
|
|
226
|
+
refresh, segment, disk, and SLO findings
|
|
177
227
|
- Fix applied or recommended
|
|
178
228
|
- Evidence level: canary evidence, golden-set evidence, configured-test evidence, static review risk, manual-only, missing, or not applicable
|
|
179
229
|
- Command intents run
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
mustflow_doc: skill.security-privacy-review
|
|
3
3
|
locale: en
|
|
4
4
|
canonical: true
|
|
5
|
-
revision:
|
|
5
|
+
revision: 25
|
|
6
6
|
lifecycle: mustflow-owned
|
|
7
7
|
authority: procedure
|
|
8
8
|
name: security-privacy-review
|
|
@@ -200,6 +200,9 @@ Catch security, privacy, and disclosure risks introduced by ordinary code, docum
|
|
|
200
200
|
35. For pinned action references, distinguish tag objects from the commit that implements the tag. Verify pinned SHAs against the action repository so scanner tooling does not report an imposter or non-member commit.
|
|
201
201
|
36. For dependency scanner alerts, separate production dependency manifests from fixtures, examples, generated test repositories, and intentionally vulnerable samples. Narrow the scan scope before treating fixture-only alerts as product vulnerabilities.
|
|
202
202
|
- For lockfile CVEs, inspect the manifest and lockfile together. Identify the direct parent that keeps the vulnerable transitive package in the graph, update the narrowest direct dependency or override needed to reach the fixed range, and confirm the vulnerable package version no longer appears in the resolved graph before claiming the alert is fixed.
|
|
203
|
+
- For object merge, defaulting, or configuration merge advisories, trace whether parsed request bodies, database records, uploaded JSON, repository config, or provider payloads can become the first or highest-priority merge input. Treat `__proto__`, `constructor`, and `prototype` keys, inherited polluted values, and default-overwrite behavior as prototype-pollution sinks; prove the patched dependency is resolved or add a regression payload that cannot override trusted defaults.
|
|
204
|
+
- For ORM or SQL-builder advisories around identifiers, aliases, dynamic sorting, report columns, CTE names, or `.as()`-style APIs, remember that value parameter binding does not protect identifier positions. Runtime input must map through an allowlist of known columns or aliases, and dialect quote delimiters inside identifiers must be escaped by the library before the identifier is wrapped.
|
|
205
|
+
- For serializer or deserializer advisories, treat sparse arrays, giant indexes, deep objects, cyclic references, and attacker-controlled serialized payloads as allocation and CPU sinks. Bound serialized size, array length or highest index, nesting depth, and parse source trust before claiming a parser-only upgrade removes the availability risk.
|
|
203
206
|
- For advisories involving development tools such as Vite, Vitest UI, browser-mode test servers, Storybook, docs preview, asset servers, or framework dev servers, do not dismiss the issue merely because the package is a devDependency. Check whether scripts, docs, Docker, Codespaces, CI previews, tunnels, or config bind the server to a non-localhost host, widen file-serving roots, disable deny lists, or expose privileged read, write, rerun, snapshot, attachment, or execute APIs.
|
|
204
207
|
37. For deployment settings, check debug mode, sample admin accounts, default credentials, public admin panels, open metrics endpoints, public storage, root container users, HTTPS enforcement, and exposed GraphQL or development consoles.
|
|
205
208
|
38. For runtime and framework security updates, check that supported versions are documented, end-of-life versions are rejected, dependency locks exist where appropriate, security patches can be tested and deployed quickly, and rollback or redeploy can happen without manual dashboard memory. Do not treat a fashionable or high-performance runtime as safe unless the patch path is operationally credible.
|