Skip to content

Commit a854499

Browse files
committed
Bundle GeneCluster skill references
1 parent 21f7edc commit a854499

82 files changed

Lines changed: 7279 additions & 75 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

skills/biosymphony/SKILL.md

Lines changed: 46 additions & 46 deletions
Large diffs are not rendered by default.
Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
# BioSymphony: campaign preflight runbook
2+
3+
**Date:** 2026-05-12
4+
**Status:** authoritative for all new campaigns
5+
**Scope:** the mandatory Stage 0 step that every BioSymphony campaign must complete before any compute is spent.
6+
7+
This runbook tells you (a) why Stage 0 exists, (b) how to run it, (c) what to do when it complains, and (d) how to feed the catalog after the campaign so the next campaign starts richer.
8+
9+
## Why Stage 0 exists
10+
11+
Before Stage 0 was wired in, every campaign re-derived "what do we know about this target species + what related species share the pathway?" by hand. Prior campaigns each spent meaningful operator time on this question. The answers were good but lived only in campaign-local docs, so the next campaign re-derived them from scratch. The public catalog at `data/pathway-species-catalog.tsv` now persists those answers across campaigns.
12+
13+
Stage 0 fixes this. It:
14+
15+
1. **Forces** every campaign to start with a structured 5-pillar evaluation (Data / Inputs / Relevance / Novelty / Importance) before any pipeline launch is allowed.
16+
2. Pulls known producers of the target pathway from `data/pathway-species-catalog.tsv` instead of re-deriving them.
17+
3. Auto-discovers additional candidates via NCBI taxonomy walk + NCBI Datasets v2 + SRA esearch + NGDC GWH fallback.
18+
4. Produces a downstream contract (`campaign-launch-readiness.json`) that every other `genecluster_*` stage must honor.
19+
20+
If the operator forgets to provide a comparator list, the system asks NCBI + the catalog itself rather than launching against the target in isolation.
21+
22+
## Stage 0 contract (what downstream stages depend on)
23+
24+
After a successful preflight, the campaign directory MUST contain these artifacts:
25+
26+
| File | Purpose |
27+
|---|---|
28+
| `campaign-launch-readiness.json` | Downstream contract. `preflight_status == "ready"` is required for any L0→L1 stage to proceed. |
29+
| `campaign-preflight-summary.md` | Top-level Markdown report of the 5 pillars. |
30+
| `species_scout.tsv` | One row per candidate species, with assembly, SRA, scoring. |
31+
| `species_scout.json` | Full structured findings. |
32+
| `relevance-novelty-summary.md` | Human-friendly 5-section narrative. |
33+
| `seed-query-candidates.tsv` | KEGG-derived placeholder enzymes (when pathway resolves) or operator-supplied set. |
34+
35+
If `preflight_status` is `blocked` or `needs_audit`, every `genecluster_*` script will refuse to advance the maturity ladder past `L0_control_plane_ready`.
36+
37+
## How to run it
38+
39+
### Quick start: operator does NOT know the comparator list
40+
41+
```bash
42+
python3 skills/biosymphony/scripts/genecluster_campaign_preflight.py \
43+
--target "Coptis chinensis" \
44+
--pathway BIA \
45+
--campaign-id coptis-bia-example \
46+
--out-dir .runtime/coptis-bia-example-preflight \
47+
--max-candidates 10 \
48+
--ncbi-api-key "$NCBI_API_KEY"
49+
```
50+
51+
The preflight invokes the species scout, which:
52+
53+
1. Pulls every catalog row tagged with `pathway_id=BIA` (or pathway-name match).
54+
2. Resolves *Coptis chinensis* taxonomy via NCBI E-utilities, gets `genus=Coptis, family=Ranunculaceae, order=Ranunculales`.
55+
3. Walks the genus, family, and order for related species (e.g., *Coptis teeta*, *Hydrastis canadensis*, *Berberis vulgaris*).
56+
4. For each candidate (target + ≤9 relatives), queries NCBI Datasets v2 for best assembly, esearch SRA for tissue breadth, and probes NGDC GWH plants for fallback assemblies when NCBI is empty.
57+
5. Resolves `BIA` → KEGG `map00950` and pulls the enzyme list as seed-query placeholders.
58+
6. Composes the 5-section relevance/novelty summary.
59+
60+
### Quick start: operator KNOWS comparators (skip auto-discover)
61+
62+
```bash
63+
python3 skills/biosymphony/scripts/genecluster_campaign_preflight.py \
64+
--target "Coptis chinensis" \
65+
--pathway BIA \
66+
--campaign-id coptis-bia-example \
67+
--out-dir .runtime/coptis-bia-example-preflight \
68+
--comparative-species "Berberis vulgaris,Eschscholzia californica,Argemone mexicana" \
69+
--seed-queries-tsv .runtime/coptis-bia-example-preflight/operator-seeds.tsv
70+
```
71+
72+
The preflight validates the comparator list against the catalog (flagging unknown / cross-pathway species) and validates the seed-queries TSV shape (required columns, controls, duplicate `query_id`, missing UniProt anchors).
73+
74+
### Dry run (no NCBI fetches)
75+
76+
```bash
77+
python3 skills/biosymphony/scripts/genecluster_campaign_preflight.py \
78+
--target "Coptis chinensis" \
79+
--pathway BIA \
80+
--campaign-id coptis-bia-example \
81+
--out-dir .runtime/coptis-bia-example-preflight \
82+
--dry-run
83+
```
84+
85+
Dry run produces the catalog-derived report without hitting any REST endpoint. Useful for offline scaffolding.
86+
87+
## The five-pillar report: what each section tells you
88+
89+
### 1. Data
90+
91+
Per candidate species:
92+
93+
- Best NCBI assembly (accession, level chromosome/scaffold/contig, year)
94+
- NGDC GWH fallback accession when NCBI is empty
95+
- Annotation presence flag (yes / partial / unknown / no)
96+
- SRA RNA-Seq breadth: total run count + per-tissue counts (root / leaf / stem / flower / fruit / rhizome / latex / etc.)
97+
- Top 1, 3 BioProjects
98+
- Most recent submission year
99+
100+
This is the answer to "is there anything to run on?" before you launch.
101+
102+
### 2. Inputs
103+
104+
If the pathway resolves to a KEGG map (`BIA→map00950`, `MIA→map00901`, etc.), the scout emits a placeholder query set (`PROPQ001…PROPQNN`) from KEGG enzymes. **These are placeholders.** Each row's `uniprot` column shows `(needs_anchor_resolution)`; the operator (or a Codex dispatch agent) must replace these with canonical SwissProt accessions before launch.
105+
106+
Standard controls are always appended:
107+
- `POSCTRL_ACTIN` (ACT2, Arabidopsis P0CJ47)
108+
- `POSCTRL_GAPDH` (Arabidopsis P25856)
109+
- `NEGCTRL_RANDOM` (shuffled 150 aa)
110+
111+
When the operator passes `--seed-queries-tsv path/to/seeds.tsv`, the scout uses that file directly and validates: required columns (`query_id`, `enzyme_name`, `uniprot`), presence of all three control types, no duplicate `query_id`, no missing anchors.
112+
113+
### 3. Relevance
114+
115+
Candidates are bucketed by taxonomy relationship to the target:
116+
117+
- **Same family**, direct sister species (highest synteny; near-1:1 ortholog mapping expected)
118+
- **Same order, different family**, broader convergence baseline
119+
- **Different order (convergent producers)**, independent-origin signal
120+
121+
This is the answer to "how much pathway overlap is the candidate likely to give us?"
122+
123+
### 4. Novelty
124+
125+
Candidates with a tracked `key_publication_pmid` in `data/pathway-species-catalog.tsv` are listed with their existing publication and the `novelty_window` field. Candidates without a tracked publication are flagged for a multi-pass literature audit.
126+
127+
**Operator action when novelty is unclear:** trigger the lit-audit agent fan-out before committing the campaign. The audit writes back into the catalog's `key_publication_pmid` + `novelty_window` columns so the next campaign benefits.
128+
129+
### 5. Importance
130+
131+
Composite ranking via deterministic score:
132+
133+
| Signal | Weight |
134+
|---|---|
135+
| Chromosome-scale assembly | +30 |
136+
| Scaffold assembly | +15 |
137+
| NGDC-GWH fallback assembly | +18 |
138+
| Annotation present | +20 |
139+
| ≥3 tissues in SRA | +15 |
140+
| 1, 2 tissues in SRA | +7 |
141+
| Year ≥ 2024 | +10 |
142+
| Year ≥ 2020 | +5 |
143+
| Catalog `comparative_value=HIGH` | +15 |
144+
| Catalog `comparative_value=BASELINE` (canonical target) | +12 |
145+
| Catalog `comparative_value=MED` | +7 |
146+
147+
Top 3 by score are reported as "recommended comparators" plus a sequencing-priority order (NCBI fastest path first, then NGDC GWH, then de novo RNA-Seq).
148+
149+
## What blocks a preflight
150+
151+
| Status | Trigger | Operator action |
152+
|---|---|---|
153+
| `ready` | All checks pass | Proceed to L1 |
154+
| `blocked` | Scout produced 0 candidates OR seed-queries TSV failed validation | Inspect `status_reasons` in the readiness JSON; fix and re-run |
155+
| `needs_audit` | `--require-novelty-audit` set and `novelty-audit.md` not present | Run the literature audit, save output as `<out-dir>/novelty-audit.md`, re-run preflight |
156+
157+
The `genecluster_*` downstream scripts grep `preflight_status` from the readiness JSON before doing anything else. If `ready` is missing, they exit non-zero with a pointer back to this runbook.
158+
159+
## Adding to the catalog (post-campaign)
160+
161+
After a campaign ships, enrich `data/pathway-species-catalog.tsv` with what you learned. Edit the TSV directly (it is tab-separated, 21 columns; trailing empty cells are fine):
162+
163+
```
164+
pathway_id pathway_name species common_name genus family plant_order
165+
best_genome_accession genome_source genome_level annotation_present
166+
rna_seq_bioprojects tissues_covered year_latest key_publication_pmid
167+
key_publication_doi comparative_value novelty_window campaign_used_in
168+
last_audit_date notes
169+
```
170+
171+
Recommended per-campaign updates:
172+
173+
1. **Update `last_audit_date`** for every catalog row you touched.
174+
2. **Set `comparative_value`** from MEDIUM (predicted) to HIGH (proven) when the campaign confirmed strong synteny / cluster signal. or down to LOW when it disappointed.
175+
3. **Fill in `key_publication_pmid` / `novelty_window`** if the literature audit produced new citations.
176+
4. **Add new species rows** for any tax-walk candidate the scout surfaced that wasn't already there.
177+
5. **Reference the campaign in `campaign_used_in`** (e.g., `campaign-sp2`).
178+
179+
## Operator quality bar
180+
181+
- **Never bypass Stage 0.** If `preflight_status` is anything but `ready`, the campaign is not ready. The 5-pillar report is not optional paperwork. It is the difference between "we ran a campaign" and "we ran a defensible campaign."
182+
- **Catalog rows are evidence, not opinion.** When you update `comparative_value`, cite the specific cluster/anchor evidence. When you fill `key_publication_pmid`, the publication must actually mention the species + pathway pair.
183+
- **Treat KEGG placeholder queries as TODOs.** They never go to a launch bundle as-is. Either an operator or a Codex agent fan-out resolves UniProt anchors first.
184+
- **Always include controls.** Positive (ACTIN, GAPDH) and negative (shuffled). Stage 0 enforces this on user-supplied TSVs but does not enforce it on the placeholder set. You do.
185+
186+
## Cross-references
187+
188+
- `skills/biosymphony/SKILL.md`, Stage 0 section, mandatory contract
189+
- `skills/biosymphony/scripts/genecluster_campaign_preflight.py`, wrapper script
190+
- `skills/biosymphony/scripts/genecluster_species_scout.py`, fan-out scout
191+
- `data/pathway-species-catalog.tsv`, public pathway × species catalog used as institutional memory
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
# BioSymphony Real-Run Lessons For Skill Authors
2+
3+
Status: generalized lessons from early provider-backed runs
4+
Last reviewed: 2026-04-30
5+
6+
This note is for authors building related BioSymphony skills. It generalizes
7+
lessons from real remote campaigns where the primary science lane produced
8+
useful results, but a later context lane exceeded the runtime budget.
9+
10+
## 1. Separate Primary Evidence From Context Lanes
11+
12+
Do not package every desirable downstream analysis as one definition of
13+
success. Define a minimum scientific deliverable and then list optional context
14+
lanes separately.
15+
16+
Good milestone split:
17+
18+
- `primary_evidence`: target data materialized, primary search/model/inference
19+
completed, normalized output table exists.
20+
- `context_evidence`: neighborhoods, coexpression, maps, local refinements,
21+
sensitivity analyses, or other enrichments.
22+
- `dossier`: synthesis, claim audit, provenance, caveats, and next steps.
23+
24+
This prevents a late expensive stage from making a real primary result look
25+
like total failure.
26+
27+
## 2. Add A Cardinality Gate Before Expensive Fanout
28+
29+
Every skill should estimate fanout before launching context lanes. The estimator
30+
does not need to be perfect; it needs to catch obvious multiplication errors.
31+
32+
Examples:
33+
34+
- GeneCluster: `queries x candidate_hits x windows x domain_profiles`
35+
- Cryo-EM: `movies x particles x classes x refinement branches`
36+
- DOE: `factors x levels x replicates x response models`
37+
- BioProspector: `organisms x datasets x query families x reference DBs`
38+
39+
If the estimated work exceeds the budget, the worker should switch to a bounded
40+
plan: top-N candidates, deduplicated anchors, smaller reference set, stratified
41+
sample, or a declared `deferred_by_budget` row. It should not silently launch
42+
an exhaustive lane and hope.
43+
44+
## 3. Annotate Once, Join Many
45+
46+
Avoid repeated all-vs-all annotation inside loops. Build reusable ledgers once,
47+
then join them into windows, candidates, maps, or dossiers.
48+
49+
Bad pattern:
50+
51+
- For every candidate window, scan every protein against the full domain DB.
52+
53+
Better pattern:
54+
55+
- Scan the target proteome once against the domain DB.
56+
- Create `protein_id -> domain_calls` and `protein_id -> coordinates` ledgers.
57+
- For each window, join coordinates to precomputed domain calls.
58+
59+
Equivalent patterns apply outside GeneCluster: compute per-particle, per-model,
60+
per-sample, or per-factor annotations once, then reuse them in downstream
61+
views.
62+
63+
## 4. Raw Tool Output Is Not A Deliverable
64+
65+
Raw BLAST, HMMER, RELION, AlphaFold, docking, or optimization output can be a
66+
source artifact, but downstream workers need normalized ledgers with headers,
67+
stable IDs, provenance, and review fields.
68+
69+
Every primary output table should have:
70+
71+
- explicit column names
72+
- input/source IDs that join back to the campaign ledgers
73+
- tool/version/provenance
74+
- confidence or review status
75+
- a distinction between controls, known positives, broad-family hits, and new
76+
candidate evidence
77+
78+
## 5. Controls Are Not Discoveries
79+
80+
Positive controls passing is important, but it should be reported as control
81+
evidence, not mixed with novel discoveries. Separate:
82+
83+
- known/native positive controls
84+
- cross-species homologs
85+
- broad-family/domain-only hits
86+
- negative controls or decoys
87+
- new candidate hypotheses
88+
89+
This prevents a top-hit table from looking stronger than it is.
90+
91+
## 6. Partial Success Needs A First-Class Summary
92+
93+
Every long run should write a summary even if a late stage fails. The summary
94+
should be produced by an exit trap, watcher, or closeout helper and include:
95+
96+
- stages completed
97+
- stages incomplete
98+
- reason for incompletion
99+
- validated artifacts produced
100+
- artifacts missing
101+
- resume command or next bounded lane
102+
- claim downgrades
103+
104+
Do not rely on a final `summary` stage that runs only after all earlier stages
105+
succeed.
106+
107+
## 7. Cost Models Must Include Agent Tokens
108+
109+
For remote scientific campaigns, cloud compute may be cheaper than agent time.
110+
Polling, diagnosing, waiting, and rereading context with large models can
111+
dominate the actual provider bill.
112+
113+
Skill authors should:
114+
115+
- use deterministic watchers for polling
116+
- reserve high-reasoning agents for design, interpretation, and review
117+
- enforce max-turn or max-cost limits on workers doing operational monitoring
118+
- record provider cost and model-token cost separately
119+
120+
## 8. Volume Persistence Is A Feature And A Risk
121+
122+
Persistent provider volumes make resumed runs cheap and save partial results.
123+
They also create false-complete risk when stale markers survive across retries.
124+
125+
Each provider-backed skill should maintain:
126+
127+
- a volume/run manifest
128+
- stage done markers written only after output validation
129+
- input hashes for resume decisions
130+
- cleanup and backup policy
131+
- stale-output detection when code or inputs changed
132+
133+
## 9. Use Small Real Tests, Not Only Mocks
134+
135+
Mocks validate contracts. They do not validate SRA layout, image pull, tool
136+
paths, file naming, provider volume behavior, or real output sizes. Before a
137+
full run, execute a small real route through the same provider, same image,
138+
same storage, same summary retrieval, and same closeout path.
139+
140+
## 10. Make Claim Levels Explicit
141+
142+
Every skill should define claim levels and force the final report to stay within
143+
them. Suggested generic levels:
144+
145+
- `planned`: lane exists but did not run
146+
- `observed`: artifact exists and validates
147+
- `candidate`: evidence supports a hypothesis
148+
- `context_supported`: independent context supports the hypothesis
149+
- `review_required`: ambiguity or broad-family risk remains
150+
- `validated`: external or stronger validation supports the claim
151+
- `unsupported`: requested claim exceeds evidence
152+
153+
The output should say which level was reached, not just pass/fail.
154+
155+
## Translation To Related Skills
156+
157+
For Cryo-EM:
158+
159+
- Separate import/motion/CTF, particle stack, 2D/3D classification, refinement,
160+
validation, and figure/dossier lanes.
161+
- Estimate particle/class/refinement fanout before launching exhaustive
162+
branches.
163+
- Treat a map/model output as primary evidence; local resolution, model quality,
164+
ligand density, and figure panels are context/review lanes.
165+
166+
For BioProspector:
167+
168+
- Separate literature/reference evidence from target-organism evidence.
169+
- Do not let reference DB hits stand in for target dataset hits.
170+
- Normalize hit ledgers before synthesis; split known positives from new
171+
hypotheses.
172+
173+
For DOE:
174+
175+
- Estimate design size before generating exhaustive designs.
176+
- Separate feasible design generation, simulation/measurement ingestion,
177+
model fitting, optimization, and recommendation claims.
178+
- Record deferred factor/level combinations explicitly when budget limits the
179+
design.
180+
181+
For any provider-backed skill:
182+
183+
- Prove actual container/workload activity, not provider intent.
184+
- Prove exact executables, not package names.
185+
- Write partial summaries on failure.
186+
- Treat open action items as follow-up work items, not as passive notes.

0 commit comments

Comments
 (0)