[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EN1G2RZCHRCVM5BTPTYGB6":3,"skill-same:01M7EN1G2RZCHRCVM5BTPTYGB6":63},{"skillNo":4,"name":5,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":23,"commitSha":24,"skillDirectory":25,"forksCount":26,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":29,"updatedAt":30,"install":31,"resources":44},"01M7EN1G2RZCHRCVM5BTPTYGB6","intelligence-engineer",null,"lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fintelligence-engineer\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: intelligence-engineer\ndescription: VNX-specific domain expertise for the intelligence system, central state databases, and dispatch lifecycle. Use when working on quality_intelligence.db \u002F runtime_coordination.db, code_snippets FTS5, snippet_metadata linkage, success_patterns \u002F antipatterns, T0 state projection (t0_state.json), intelligence_injections lifecycle, dispatch → receipt → events → archive flow, central state architecture, project_id propagation across VNX, or any code that reads\u002Fwrites VNX governance state. Triggers include: editing intelligence injection code, querying central DB for cross-project insights, debugging \"intelligence not appearing in T0 state\", modifying schema in `schemas\u002Fquality_intelligence.sql` or `schemas\u002Fruntime_coordination_v*.sql`, working with `scripts\u002Fquality_db_init.py` or `scripts\u002Flib\u002Fcoordination_db.py`.\nallowed-tools: [Read, Write, Edit, MultiEdit, Bash, Grep, Glob]\npaths: [\"schemas\u002F**\", \"scripts\u002F**\", \"tests\u002F**\"]\n---\n\n# Intelligence Engineer\n\nVNX-specific domain expert for the intelligence system, central state, and dispatch lifecycle.\n\n## Core Mission\n\nVNX has a sprawling but specific data model: dispatches flow through a runtime coordination DB, generate receipts and events, get archived, and feed back into a quality intelligence DB that informs future dispatch decisions. Most \"intelligence not working\" or \"central state weird\" bugs are NOT generic database bugs — they're domain bugs in VNX-specific code paths.\n\nThis skill exists alongside `database-engineer` (which covers SQLite mechanics generically). Use `database-engineer` for migration\u002Fschema\u002FUPSERT work; use this skill when the question requires knowing **which VNX table holds what, and why**.\n\n## When to Use\n\n- Editing or designing schemas in `schemas\u002Fquality_intelligence.sql`, `schemas\u002Fruntime_coordination_v*.sql`, or any `0010_…` \u002F `0015_…` migration\n- Touching `scripts\u002Fquality_db_init.py`, `scripts\u002Flib\u002Fcoordination_db.py`, or any module that initializes \u002F queries central state\n- Working with intelligence injection: `scripts\u002Flib\u002Fintelligence_*`, `scripts\u002Fbuild_t0_state.py`, `scripts\u002Flib\u002Fintelligence_injection.py`\n- Debugging \"code_snippets show wrong project\", \"dispatches missing from T0 state\", \"success_patterns not retrieved\", \"central DB query returns nothing\"\n- Querying central DB for cross-project insights (federation, aggregation, analytics)\n- Designing a new intelligence-feeding mechanism (e.g. new event type → injection rule)\n- Modifying any code that touches the project_id flow (registry → import → query → injection)\n\n## STEP 0 — Foundational Check (Mandatory)\n\nBEFORE proposing any design, fix, or implementation:\n\n1. **Consult relevant ADRs** in `docs\u002Fgovernance\u002Fdecisions\u002F`. Special attention to:\n   - ADR-005 (NDJSON audit ledger as primary observability)\n   - ADR-007 (multi-tenant project_id stamping; composite keys for central state DBs)\n   - ADR-010 (subprocess adapter as canonical Claude routing)\n   List any ADR that applies to the task and how it constrains your solution.\n\n2. **Consult relevant memory** in `~\u002F.claude\u002Fprojects\u002F\u003Cyour-project>\u002Fmemory\u002FMEMORY.md` — particularly entries about past architectural incidents.\n\n3. **Check P4-style incident docs** in `claudedocs\u002F` for analogous failures (e.g., `2026-05-09-p4-migration-architecture-lessons.md` for multi-tenant migration patterns).\n\n4. **State your foundational read aloud** at the start of your response. Example: \"ADR-007 applies: new tabel X needs composite PK over project_id. Per P4 §4.2, single-column UNIQUE is a smell. Memory [[adr-007-multitenant-composite-keys]] confirms.\"\n\nSkipping STEP 0 is a process violation, not a shortcut. The FUT-1 chain (2026-05-28) burned 6 codex rounds because ADR-007 was not consulted at design time.\n\n## Decision Protocol\n\nWhen asked a \"where does X live in VNX?\" question, FIRST consult `references\u002Fquality-intelligence-schema.md` and `references\u002Fruntime-coordination-schema.md` for table-by-table content. Don't guess; the schemas have evolved and the canonical answer is in the schema files + their accompanying `quality_db_init.py` imperative additions.\n\nWhen asked to write code that produces or consumes intelligence, walk through `references\u002Fdispatch-lifecycle.md` first to understand which lifecycle stage produces the data you need.\n\n## 1. The Two Central DBs\n\nVNX has two physical SQLite databases that together hold the central state:\n\n### `~\u002F.vnx-data\u002Fstate\u002Fquality_intelligence.db` (QI)\n\nHolds learned patterns, code snippets, and quality signals. Read primarily by intelligence injection at SessionStart and by analytics queries.\n\nKey tables (full reference: `references\u002Fquality-intelligence-schema.md`):\n- **`code_snippets`** (FTS5 vtab) — extracted code patterns with `project_id` column. Indexed for full-text search.\n- **`snippet_metadata`** — companion table linking `snippet_rowid → code_snippets.rowid`. Holds `pattern_hash`, `quality_score`, `source_commit_hash`, `usage_count`.\n- **`success_patterns`**, **`antipatterns`**, **`prevention_rules`** — learned governance rules with provenance.\n- **`pattern_usage`** — cross-references of which dispatch used which pattern.\n- **`tag_combinations`** — pre-computed tag tuples for fast filtering.\n- **`vnx_code_quality`** — quality scoring per code area.\n\nSchema source files: `schemas\u002Fquality_intelligence.sql` (base) + imperative additions in `scripts\u002Fquality_db_init.py:84-..`.\n\n### `~\u002F.vnx-data\u002Fstate\u002Fruntime_coordination.db` (RC)\n\nHolds dispatch lifecycle state. Read by dispatcher, T0 status, terminal coordination.\n\nKey tables (full reference: `references\u002Fruntime-coordination-schema.md`):\n- **`dispatches`** — every dispatch ever created. `dispatch_id` is the primary identifier across VNX.\n- **`dispatch_attempts`** — retry attempts per dispatch.\n- **`terminal_leases`** — which terminal owns which dispatch right now.\n- **`coordination_events`** — append-only event log: state transitions, receipts, escalations.\n- **`incident_log`** — flagged incidents (cooldowns, errors).\n- **`intelligence_injections`** — record of which intelligence was injected where.\n- **`retry_budgets`**, **`retry_state`**, **`escalation_log`** — retry\u002Fescalation bookkeeping.\n\nSchema source: `schemas\u002Fruntime_coordination.sql` (v1 base) + delta migrations `runtime_coordination_v2.sql` through `runtime_coordination_v9.sql`. Apply order matters.\n\n### Why two DBs?\n\nQI is mostly read (intelligence injection); RC is mostly written (dispatch flow). Separating them:\n- Reduces lock contention (RC has lots of small writes, QI mostly batch reads)\n- Isolates retention (QI snippets last forever, RC events archive after N days)\n- Allows separate backup cadence\n\nWhen you query \"the central state\", you usually need to ATTACH both:\n```python\ncon = sqlite3.connect(qi_path)\ncon.execute(\"ATTACH DATABASE ? AS rc\", (f\"file:{rc_path}?mode=ro\",))\n# Now can JOIN dispatches (rc.dispatches) with intelligence_injections\n```\n\n## 2. The Dispatch Lifecycle\n\nThe canonical flow that VNX governance is built on:\n\n```\n1. CREATE   T0 writes a dispatch file → .vnx-data\u002Fdispatches\u002Fpending\u002F\u003Cid>\u002Fdispatch.json\n2. PROMOTE  operator approval → moves to active\u002F  → row in rc.dispatches (state='queued')\n3. DELIVER  dispatcher delivers to terminal pane → state='dispatched', terminal_leases row inserted\n4. EXECUTE  worker runs; events streamed to .vnx-data\u002Fevents\u002FT\u003Cn>.ndjson\n5. RECEIPT  worker writes receipt → t0_receipts.ndjson (with append_receipt() helper)\n6. ARCHIVE  T0 reviews receipt → moves dispatch to archive\u002F, terminal_leases released\n7. INJECT   subsequent SessionStart pulls intelligence from rc.dispatches + qi.success_patterns into t0_state.json\n```\n\nEach step has an associated table or file. See `references\u002Fdispatch-lifecycle.md` for the full diagram + which step writes which row + retention rules.\n\n**Critical invariants:**\n- Every persistent record has `project_id` stamped at write time\n- `dispatch_id` is unique within a project, NOT globally — use prefix-rewrite (`\u003Cproject_id>:\u003Cdispatch_id>`) for cross-project federation\n- Receipts are NDJSON (one row per receipt), atomically appended via `fcntl.flock`\n- Events files are ring-buffered: `T\u003Cn>.ndjson` is the live file (truncated post-dispatch), durable record in `events\u002Farchive\u002F\u003Cterminal>\u002F\u003Cdispatch_id>.ndjson`\n\n## 3. Intelligence Injection Flow\n\nIntelligence injection is how VNX \"learns\": insights from past dispatches get pulled into the current T0 session. Without this, T0 starts every conversation cold.\n\nFlow:\n```\nSessionStart hook → build_t0_state.py\n  ├─ Reads central QI (success_patterns, antipatterns) for this project_id\n  ├─ Reads central RC (recent dispatches, open items, escalations)\n  ├─ Filters by scope match (project_id, recency, relevance)\n  └─ Writes t0_state.json with `strategic_state` + `intelligence` blocks\nT0 reads t0_state.json on every SessionStart automatically\n```\n\nCode paths:\n- `scripts\u002Fbuild_t0_state.py` — main projection driver\n- `scripts\u002Flib\u002Fintelligence_injection.py` — scope match + filter logic\n- `scripts\u002Faggregator\u002Fbuild_central_view.py` — cross-project queries (federation aggregator, P1 work)\n\nKey concept: **scope match**. An injected pattern must be relevant to the current dispatch. Scope keys include: `project_id`, `track`, `tags`, `risk_class`. The match logic re-evaluates after canonical project_id remap (per `feedback_dispatcher_role_alias` memory).\n\nCommon bug: intelligence injection writes to `runtime_coordination.intelligence_injections` table but the scope match was wrong → injected pattern was irrelevant → operator had to manually filter. Fix: tighten scope match logic, add tests for edge cases.\n\n## 4. Schema Evolution\n\nVNX schemas have evolved through 9+ versions for RC and 16+ migrations for QI. Key checkpoints:\n\n- **`schemas\u002Fruntime_coordination.sql`** is v1. Each `runtime_coordination_v\u003CN>.sql` is a DELTA, not a full schema. Apply v1 → v2 → … → v9 in order.\n- **`schemas\u002Fquality_intelligence.sql`** is the base. `scripts\u002Fquality_db_init.py:84-` adds tables imperatively (e.g. `confidence_events`, `dispatch_pattern_offered`). Don't bypass `bootstrap_qi_db()` — it knows the full set.\n- **`schemas\u002Fmigrations\u002F0010_add_project_id.sql`** — adds project_id to \"hot\" RC tables (dispatches, dispatch_attempts, terminal_leases, etc).\n- **`schemas\u002Fmigrations\u002F0015_complete_project_id.sql`** — extends to remaining tables (vnx_code_quality, snippet_metadata, etc).\n- **`schemas\u002Fmigrations\u002F0016_rebuild_fts5.sql`** — rebuilds `code_snippets` FTS5 vtab to include `project_id` column.\n\nFor new migrations: number sequentially, document in the file header what it does and why, include `CREATE INDEX` for any JOIN columns. See `database-engineer\u002FSKILL.md` for general migration patterns.\n\n## 5. The project_id Flow\n\nWhere `project_id` comes from and how it propagates:\n\n1. **Registry**: `~\u002F.vnx\u002Fprojects.json` — operator-curated list of projects. Each entry has `name` and `path`.\n2. **Synthesis**: `scripts\u002Faggregator\u002Fbuild_central_view.py:synthesize_project_id(name)` slugifies the name into a `project_id` token (lowercase, alphanumeric+dash, max 32 chars).\n3. **Per-project state**: each project's `.vnx-data\u002Fstate\u002F{quality_intelligence,runtime_coordination}.db` — rows MAY have `project_id` column (legacy `vnx-dev` default for autopilot's pre-existing rows; absent for newer source DBs).\n4. **Migration import**: P4 migration script reads source rows, OVERRIDES any source `project_id` value with the project's actual id from registry. Stamping happens in `_import_table` line ~1010.\n5. **Central DB**: every row has `project_id` set to the registry-derived value. Cross-project queries always filter or aggregate by this column.\n6. **Intelligence injection**: scope match uses project_id. Cross-project federation (P1) uses project_id as discriminator.\n\nPitfall: if `~\u002F.vnx\u002Fprojects.json` has a project under name `vnx-roadmap-autopilot` and migration imports it, the central rows are stamped `vnx-roadmap-autopilot`. Renaming the entry to `vnx-orchestration` later doesn't update existing central rows — they keep the old slug. P4 round-5 caught a flavor of this. Test rename scenarios explicitly.\n\n## 6. VNX Intelligence Cookbook\n\nCommon queries you'll need:\n\n### List all dispatches per project (last 7 days)\n```sql\nATTACH DATABASE ? AS rc;\nSELECT project_id, COUNT(*) AS dispatches, MAX(created_at) AS most_recent\nFROM rc.dispatches\nWHERE created_at > datetime('now', '-7 days')\nGROUP BY project_id\nORDER BY dispatches DESC;\n```\n\n### Find code_snippets matching a pattern, scoped to project\n```sql\nSELECT title, file_path, line_range\nFROM code_snippets\nWHERE project_id = ?\n  AND code_snippets MATCH ?  -- FTS5 query\nORDER BY rank\nLIMIT 20;\n```\nNote: FTS5 MATCH is project-naive — must explicitly filter `project_id = ?` or you'll get cross-project results.\n\n### Intelligence injection scope match\n```sql\nSELECT sp.pattern_id, sp.title, sp.body, sp.confidence\nFROM success_patterns sp\nWHERE sp.project_id = ?\n  AND sp.tags GLOB '*' || ? || '*'  -- substring tag match\n  AND sp.valid_until IS NULL\n  AND sp.confidence >= 0.7\nORDER BY sp.confidence DESC\nLIMIT 5;\n```\n\n### Cross-project federation (read-only, P1 work)\n```sql\nATTACH DATABASE ? AS qi_central;\nSELECT project_id, COUNT(*) AS snippet_count\nFROM qi_central.code_snippets\nGROUP BY project_id\nORDER BY snippet_count DESC;\n```\n\n### Dispatch chain reconstruction (parent → child)\n```sql\nWITH RECURSIVE chain AS (\n  SELECT dispatch_id, parent_dispatch, 0 AS depth\n  FROM dispatches WHERE dispatch_id = ?\n  UNION ALL\n  SELECT d.dispatch_id, d.parent_dispatch, c.depth + 1\n  FROM dispatches d JOIN chain c ON d.parent_dispatch = c.dispatch_id\n)\nSELECT * FROM chain ORDER BY depth;\n```\n\nMore queries in `references\u002Fintelligence-injection.md`.\n\n## Reference Files\n\n- `references\u002Fquality-intelligence-schema.md` — table-by-table reference for QI DB\n- `references\u002Fruntime-coordination-schema.md` — table-by-table reference for RC DB (v1 base + v2-v9 deltas)\n- `references\u002Fdispatch-lifecycle.md` — lifecycle diagram + which step writes which row\n- `references\u002Fintelligence-injection.md` — scope match logic, federation queries, cookbook\n\n## Companion Skills\n\n- For SQLite mechanics, multi-tenant patterns, migration safety: `database-engineer` covers the generic side. This skill is the VNX-specific layer on top.\n- For dispatcher \u002F receipt processor \u002F smart-tap operational work: `vnx-manager` is the right specialist.\n- For T0 orchestration and dispatch routing decisions: `t0-orchestrator` (this skill is consulted by T0 when the work is intelligence\u002Fstate DB heavy).\n\n## Inheritance from backend-developer\n\nAll `backend-developer` patterns apply: atomic writes, fcntl locking on shared NDJSON, null guards, schema version checks. Treat that as baseline. This skill adds VNX-domain knowledge on top.\n","# Intelligence Engineer\n\nVNX-specific domain expert for the intelligence system, central state, and dispatch lifecycle.\n\n## Core Mission\n\nVNX has a sprawling but specific data model: dispatches flow through a runtime coordination DB, generate receipts and events, get archived, and feed back into a quality intelligence DB that informs future dispatch decisions. Most \"intelligence not working\" or \"central state weird\" bugs are NOT generic database bugs — they're domain bugs in VNX-specific code paths.\n\nThis skill exists alongside `database-engineer` (which covers SQLite mechanics generically). Use `database-engineer` for migration\u002Fschema\u002FUPSERT work; use this skill when the question requires knowing **which VNX table holds what, and why**.\n\n## When to Use\n\n- Editing or designing schemas in `schemas\u002Fquality_intelligence.sql`, `schemas\u002Fruntime_coordination_v*.sql`, or any `0010_…` \u002F `0015_…` migration\n- Touching `scripts\u002Fquality_db_init.py`, `scripts\u002Flib\u002Fcoordination_db.py`, or any module that initializes \u002F queries central state\n- Working with intelligence injection: `scripts\u002Flib\u002Fintelligence_*`, `scripts\u002Fbuild_t0_state.py`, `scripts\u002Flib\u002Fintelligence_injection.py`\n- Debugging \"code_snippets show wrong project\", \"dispatches missing from T0 state\", \"success_patterns not retrieved\", \"central DB query returns nothing\"\n- Querying central DB for cross-project insights (federation, aggregation, analytics)\n- Designing a new intelligence-feeding mechanism (e.g. new event type → injection rule)\n- Modifying any code that touches the project_id flow (registry → import → query → injection)\n\n## STEP 0 — Foundational Check (Mandatory)\n\nBEFORE proposing any design, fix, or implementation:\n\n1. **Consult relevant ADRs** in `docs\u002Fgovernance\u002Fdecisions\u002F`. Special attention to:\n   - ADR-005 (NDJSON audit ledger as primary observability)\n   - ADR-007 (multi-tenant project_id stamping; composite keys for central state DBs)\n   - ADR-010 (subprocess adapter as canonical Claude routing)\n   List any ADR that applies to the task and how it constrains your solution.\n\n2. **Consult relevant memory** in `~\u002F.claude\u002Fprojects\u002F\u003Cyour-project>\u002Fmemory\u002FMEMORY.md` — particularly entries about past architectural incidents.\n\n3. **Check P4-style incident docs** in `claudedocs\u002F` for analogous failures (e.g., `2026-05-09-p4-migration-architecture-lessons.md` for multi-tenant migration patterns).\n\n4. **State your foundational read aloud** at the start of your response. Example: \"ADR-007 applies: new tabel X needs composite PK over project_id. Per P4 §4.2, single-column UNIQUE is a smell. Memory [[adr-007-multitenant-composite-keys]] confirms.\"\n\nSkipping STEP 0 is a process violation, not a shortcut. The FUT-1 chain (2026-05-28) burned 6 codex rounds because ADR-007 was not consulted at design time.\n\n## Decision Protocol\n\nWhen asked a \"where does X live in VNX?\" question, FIRST consult `references\u002Fquality-intelligence-schema.md` and `references\u002Fruntime-coordination-schema.md` for table-by-table content. Don't guess; the schemas have evolved and the canonical answer is in the schema files + their accompanying `quality_db_init.py` imperative additions.\n\nWhen asked to write code that produces or consumes intelligence, walk through `references\u002Fdispatch-lifecycle.md` first to understand which lifecycle stage produces the data you need.\n\n## 1. The Two Central DBs\n\nVNX has two physical SQLite databases that together hold the central state:\n\n### `~\u002F.vnx-data\u002Fstate\u002Fquality_intelligence.db` (QI)\n\nHolds learned patterns, code snippets, and quality signals. Read primarily by intelligence injection at SessionStart and by analytics queries.\n\nKey tables (full reference: `references\u002Fquality-intelligence-schema.md`):\n- **`code_snippets`** (FTS5 vtab) — extracted code patterns with `project_id` column. Indexed for full-text search.\n- **`snippet_metadata`** — companion table linking `snippet_rowid → code_snippets.rowid`. Holds `pattern_hash`, `quality_score`, `source_commit_hash`, `usage_count`.\n- **`success_patterns`**, **`antipatterns`**, **`prevention_rules`** — learned governance rules with provenance.\n- **`pattern_usage`** — cross-references of which dispatch used which pattern.\n- **`tag_combinations`** — pre-computed tag tuples for fast filtering.\n- **`vnx_code_quality`** — quality scoring per code area.\n\nSchema source files: `schemas\u002Fquality_intelligence.sql` (base) + imperative additions in `scripts\u002Fquality_db_init.py:84-..`.\n\n### `~\u002F.vnx-data\u002Fstate\u002Fruntime_coordination.db` (RC)\n\nHolds dispatch lifecycle state. Read by dispatcher, T0 status, terminal coordination.\n\nKey tables (full reference: `references\u002Fruntime-coordination-schema.md`):\n- **`dispatches`** — every dispatch ever created. `dispatch_id` is the primary identifier across VNX.\n- **`dispatch_attempts`** — retry attempts per dispatch.\n- **`terminal_leases`** — which terminal owns which dispatch right now.\n- **`coordination_events`** — append-only event log: state transitions, receipts, escalations.\n- **`incident_log`** — flagged incidents (cooldowns, errors).\n- **`intelligence_injections`** — record of which intelligence was injected where.\n- **`retry_budgets`**, **`retry_state`**, **`escalation_log`** — retry\u002Fescalation bookkeeping.\n\nSchema source: `schemas\u002Fruntime_coordination.sql` (v1 base) + delta migrations `runtime_coordination_v2.sql` through `runtime_coordination_v9.sql`. Apply order matters.\n\n### Why two DBs?\n\nQI is mostly read (intelligence injection); RC is mostly written (dispatch flow). Separating them:\n- Reduces lock contention (RC has lots of small writes, QI mostly batch reads)\n- Isolates retention (QI snippets last forever, RC events archive after N days)\n- Allows separate backup cadence\n\nWhen you query \"the central state\", you usually need to ATTACH both:\n```python\ncon = sqlite3.connect(qi_path)\ncon.execute(\"ATTACH DATABASE ? AS rc\", (f\"file:{rc_path}?mode=ro\",))\n# Now can JOIN dispatches (rc.dispatches) with intelligence_injections\n```\n\n## 2. The Dispatch Lifecycle\n\nThe canonical flow that VNX governance is built on:\n\n```\n1. CREATE   T0 writes a dispatch file → .vnx-data\u002Fdispatches\u002Fpending\u002F\u003Cid>\u002Fdispatch.json\n2. PROMOTE  operator approval → moves to active\u002F  → row in rc.dispatches (state='queued')\n3. DELIVER  dispatcher delivers to terminal pane → state='dispatched', terminal_leases row inserted\n4. EXECUTE  worker runs; events streamed to .vnx-data\u002Fevents\u002FT\u003Cn>.ndjson\n5. RECEIPT  worker writes receipt → t0_receipts.ndjson (with append_receipt() helper)\n6. ARCHIVE  T0 reviews receipt → moves dispatch to archive\u002F, terminal_leases released\n7. INJECT   subsequent SessionStart pulls intelligence from rc.dispatches + qi.success_patterns into t0_state.json\n```\n\nEach step has an associated table or file. See `references\u002Fdispatch-lifecycle.md` for the full diagram + which step writes which row + retention rules.\n\n**Critical invariants:**\n- Every persistent record has `project_id` stamped at write time\n- `dispatch_id` is unique within a project, NOT globally — use prefix-rewrite (`\u003Cproject_id>:\u003Cdispatch_id>`) for cross-project federation\n- Receipts are NDJSON (one row per receipt), atomically appended via `fcntl.flock`\n- Events files are ring-buffered: `T\u003Cn>.ndjson` is the live file (truncated post-dispatch), durable record in `events\u002Farchive\u002F\u003Cterminal>\u002F\u003Cdispatch_id>.ndjson`\n\n## 3. Intelligence Injection Flow\n\nIntelligence injection is how VNX \"learns\": insights from past dispatches get pulled into the current T0 session. Without this, T0 starts every conversation cold.\n\nFlow:\n```\nSessionStart hook → build_t0_state.py\n  ├─ Reads central QI (success_patterns, antipatterns) for this project_id\n  ├─ Reads central RC (recent dispatches, open items, escalations)\n  ├─ Filters by scope match (project_id, recency, relevance)\n  └─ Writes t0_state.json with `strategic_state` + `intelligence` blocks\nT0 reads t0_state.json on every SessionStart automatically\n```\n\nCode paths:\n- `scripts\u002Fbuild_t0_state.py` — main projection driver\n- `scripts\u002Flib\u002Fintelligence_injection.py` — scope match + filter logic\n- `scripts\u002Faggregator\u002Fbuild_central_view.py` — cross-project queries (federation aggregator, P1 work)\n\nKey concept: **scope match**. An injected pattern must be relevant to the current dispatch. Scope keys include: `project_id`, `track`, `tags`, `risk_class`. The match logic re-evaluates after canonical project_id remap (per `feedback_dispatcher_role_alias` memory).\n\nCommon bug: intelligence injection writes to `runtime_coordination.intelligence_injections` table but the scope match was wrong → injected pattern was irrelevant → operator had to manually filter. Fix: tighten scope match logic, add tests for edge cases.\n\n## 4. Schema Evolution\n\nVNX schemas have evolved through 9+ versions for RC and 16+ migrations for QI. Key checkpoints:\n\n- **`schemas\u002Fruntime_coordination.sql`** is v1. Each `runtime_coordination_v\u003CN>.sql` is a DELTA, not a full schema. Apply v1 → v2 → … → v9 in order.\n- **`schemas\u002Fquality_intelligence.sql`** is the base. `scripts\u002Fquality_db_init.py:84-` adds tables imperatively (e.g. `confidence_events`, `dispatch_pattern_offered`). Don't bypass `bootstrap_qi_db()` — it knows the full set.\n- **`schemas\u002Fmigrations\u002F0010_add_project_id.sql`** — adds project_id to \"hot\" RC tables (dispatches, dispatch_attempts, terminal_leases, etc).\n- **`schemas\u002Fmigrations\u002F0015_complete_project_id.sql`** — extends to remaining tables (vnx_code_quality, snippet_metadata, etc).\n- **`schemas\u002Fmigrations\u002F0016_rebuild_fts5.sql`** — rebuilds `code_snippets` FTS5 vtab to include `project_id` column.\n\nFor new migrations: number sequentially, document in the file header what it does and why, include `CREATE INDEX` for any JOIN columns. See `database-engineer\u002FSKILL.md` for general migration patterns.\n\n## 5. The project_id Flow\n\nWhere `project_id` comes from and how it propagates:\n\n1. **Registry**: `~\u002F.vnx\u002Fprojects.json` — operator-curated list of projects. Each entry has `name` and `path`.\n2. **Synthesis**: `scripts\u002Faggregator\u002Fbuild_central_view.py:synthesize_project_id(name)` slugifies the name into a `project_id` token (lowercase, alphanumeric+dash, max 32 chars).\n3. **Per-project state**: each project's `.vnx-data\u002Fstate\u002F{quality_intelligence,runtime_coordination}.db` — rows MAY have `project_id` column (legacy `vnx-dev` default for autopilot's pre-existing rows; absent for newer source DBs).\n4. **Migration import**: P4 migration script reads source rows, OVERRIDES any source `project_id` value with the project's actual id from registry. Stamping happens in `_import_table` line ~1010.\n5. **Central DB**: every row has `project_id` set to the registry-derived value. Cross-project queries always filter or aggregate by this column.\n6. **Intelligence injection**: scope match uses project_id. Cross-project federation (P1) uses project_id as discriminator.\n\nPitfall: if `~\u002F.vnx\u002Fprojects.json` has a project under name `vnx-roadmap-autopilot` and migration imports it, the central rows are stamped `vnx-roadmap-autopilot`. Renaming the entry to `vnx-orchestration` later doesn't update existing central rows — they keep the old slug. P4 round-5 caught a flavor of this. Test rename scenarios explicitly.\n\n## 6. VNX Intelligence Cookbook\n\nCommon queries you'll need:\n\n### List all dispatches per project (last 7 days)\n```sql\nATTACH DATABASE ? AS rc;\nSELECT project_id, COUNT(*) AS dispatches, MAX(created_at) AS most_recent\nFROM rc.dispatches\nWHERE created_at > datetime('now', '-7 days')\nGROUP BY project_id\nORDER BY dispatches DESC;\n```\n\n### Find code_snippets matching a pattern, scoped to project\n```sql\nSELECT title, file_path, line_range\nFROM code_snippets\nWHERE project_id = ?\n  AND code_snippets MATCH ?  -- FTS5 query\nORDER BY rank\nLIMIT 20;\n```\nNote: FTS5 MATCH is project-naive — must explicitly filter `project_id = ?` or you'll get cross-project results.\n\n### Intelligence injection scope match\n```sql\nSELECT sp.pattern_id, sp.title, sp.body, sp.confidence\nFROM success_patterns sp\nWHERE sp.project_id = ?\n  AND sp.tags GLOB '*' || ? || '*'  -- substring tag match\n  AND sp.valid_until IS NULL\n  AND sp.confidence >= 0.7\nORDER BY sp.confidence DESC\nLIMIT 5;\n```\n\n### Cross-project federation (read-only, P1 work)\n```sql\nATTACH DATABASE ? AS qi_central;\nSELECT project_id, COUNT(*) AS snippet_count\nFROM qi_central.code_snippets\nGROUP BY project_id\nORDER BY snippet_count DESC;\n```\n\n### Dispatch chain reconstruction (parent → child)\n```sql\nWITH RECURSIVE chain AS (\n  SELECT dispatch_id, parent_dispatch, 0 AS depth\n  FROM dispatches WHERE dispatch_id = ?\n  UNION ALL\n  SELECT d.dispatch_id, d.parent_dispatch, c.depth + 1\n  FROM dispatches d JOIN chain c ON d.parent_dispatch = c.dispatch_id\n)\nSELECT * FROM chain ORDER BY depth;\n```\n\nMore queries in `references\u002Fintelligence-injection.md`.\n\n## Reference Files\n\n- `references\u002Fquality-intelligence-schema.md` — table-by-table reference for QI DB\n- `references\u002Fruntime-coordination-schema.md` — table-by-table reference for RC DB (v1 base + v2-v9 deltas)\n- `references\u002Fdispatch-lifecycle.md` — lifecycle diagram + which step writes which row\n- `references\u002Fintelligence-injection.md` — scope match logic, federation queries, cookbook\n\n## Companion Skills\n\n- For SQLite mechanics, multi-tenant patterns, migration safety: `database-engineer` covers the generic side. This skill is the VNX-specific layer on top.\n- For dispatcher \u002F receipt processor \u002F smart-tap operational work: `vnx-manager` is the right specialist.\n- For T0 orchestration and dispatch routing decisions: `t0-orchestrator` (this skill is consulted by T0 when the work is intelligence\u002Fstate DB heavy).\n\n## Inheritance from backend-developer\n\nAll `backend-developer` patterns apply: atomic writes, fcntl locking on shared NDJSON, null guards, schema version checks. Treat that as baseline. This skill adds VNX-domain knowledge on top.\n",{},"main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","04-安全渗透\u002Fintelligence-engineer",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":7,"skillName":5,"commands":32,"prompt":42,"zipAvailable":43},[33,36,39],{"tool":34,"command":35},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill intelligence-engineer",{"tool":37,"command":38},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill intelligence-engineer",{"tool":40,"command":41},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill intelligence-engineer","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fintelligence-engineer\u002FSKILL.md",true,[45,51,55,59],{"path":46,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":49,"sourceHtmlUrl":50},"references\u002Fdispatch-lifecycle.md","REFERENCE","参考文档",6944,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fintelligence-engineer\u002Freferences\u002Fdispatch-lifecycle.md",{"path":52,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":53,"sourceHtmlUrl":54},"references\u002Fintelligence-injection.md",6718,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fintelligence-engineer\u002Freferences\u002Fintelligence-injection.md",{"path":56,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":57,"sourceHtmlUrl":58},"references\u002Fquality-intelligence-schema.md",8628,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fintelligence-engineer\u002Freferences\u002Fquality-intelligence-schema.md",{"path":60,"resourceType":47,"resourceTypeDesc":48,"sizeBytes":61,"sourceHtmlUrl":62},"references\u002Fruntime-coordination-schema.md",7482,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fintelligence-engineer\u002Freferences\u002Fruntime-coordination-schema.md",[64,72,77,84,91,98],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":71},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":73,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":71},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":71},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":71},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":71},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":7,"ownerLogin":8,"ownerAvatarUrl":9,"ownerAccountNo":10,"ownerDisplayName":11,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":71},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]