Synthesize

From kbaseincubator/BERIL-research-observatory · View interactive version

Synthesize is an AI agent skill from the GitHub repository kbaseincubator/BERIL-research-observatory. Read analysis outputs, compare against literature, and draft findings for a project REPORT.md. Use when notebooks have been run and the user wants to interpret results and write up findings.

How to use this skill

Skill file

Synthesis Skill

After notebooks have been run, read the outputs, compare against literature, and draft the findings/interpretation sections in the project's REPORT.md. Also update ## Status in README.md to reflect completion.

Usage

/synthesize <project_id>

If no <project_id> argument is provided, detect from the current working directory (if inside projects/{id}/).

Workflow (Two-Pass Approach)

Pass 1: Read Data and Draft Findings

Step 0: Precondition check

Read projects/{project_id}/beril.yaml and validate status. If beril.yaml is missing (pre-manifest project), skip this check and rely on the file-existence checks below.

> "This project is still in exploration — there's no RESEARCH_PLAN.md to synthesize against yet. Write the plan first (use /berdl_start to resume the workflow), then re-run /synthesize."

> "This project has a research plan but no analysis yet. Run the analysis notebooks first (Phase C of the workflow) so /synthesize has results to interpret. Resume via /berdl_start."

> "This project is currently complete (approved {approval.at} by {approval.by}). Running /synthesize will overwrite REPORT.md and demote the project to analysis. The previous approval will be archived under previous_approvals. Continue? (y/n)"

Synthesizing without analysis outputs (the exploration and proposed cases) produces empty or fabricated findings, which is exactly what the new lifecycle is designed to prevent. The reviewed/complete demotes are how the iteration loop and reopen-and-resubmit flow stay honest.

Step 1: Gather Project Context

Read these project files:

  1. projects/{project_id}/RESEARCH_PLAN.md — the hypothesis, expected outcomes, analysis plan (or research_plan.md for legacy projects)
  2. projects/{project_id}/README.md — current state of the project (preserve Research Question, Authors)
  3. projects/{project_id}/references.md — existing literature references

If RESEARCH_PLAN.md doesn't exist, check for research_plan.md (legacy). If neither exists, read the README for research question and hypothesis context.

Step 2: Read Analysis Outputs

Scan the project for results:

  1. CSV files in projects/{project_id}/data/:
  1. Figures in projects/{project_id}/figures/:
  1. Notebook outputs in projects/{project_id}/notebooks/:
Step 3: Draft Initial Findings

Based on the data, draft findings that address:

  1. Key results: What did the data show? (specific numbers, correlations, counts)
  2. Adjudication: for each hypothesis (H1, H2, H3, …), state whether its own decision criterion was met, unmet, or unreachable, quoting the observed value and its locator (SCOREBOARD.md or the notebook cell); then apply the Pre-registered Decision Rule (H0 is adjudicated by rejection) and say whether the plan's Confidence Prior moved up, down, or not at all.
  3. Statistical significance: Report p-values, effect sizes, confidence intervals if available
  4. Unexpected patterns: Note any surprising results or anomalies
Step 4: Present Draft to User

Show the initial findings interpretation and ask:

Wait for user feedback and revise if needed.

Pass 2: Literature Cross-Reference and Synthesis

Step 5: Search Literature for Context

Invoke /literature-review to search for papers that:

Focus searches on:

Step 6: Compare Findings Against Literature

For each key finding, assess:

| Question | Assessment |

|---|---|

| Does this agree with published work? | Cite supporting papers |

| Does this contradict published work? | Note methodology differences that could explain discrepancies |

| Is this novel? | Identify what BERDL data adds that wasn't known before |

| Are there caveats? | Data coverage, confounders, methodological limitations |

Also compare against prior observatory work, not just published literature: query the knowledge layer for related findings to agree with, extend, or contrast — see knowledge-context. Seed: beril context find "<finding's key concept>" (or beril context discoveries "<concept>" for approved findings), then read related projects' REPORT/FINDINGS and cite them alongside the papers. If beril context is unavailable, say so and compare against this checkout's projects only.

Step 7: Produce Synthesis

Create or update projects/{project_id}/REPORT.md with the following sections:

# Report: {Title}

## Key Findings

### {Finding 1 Title}

![Description of figure](figures/relevant_figure.png)

{Statistical result with specific numbers}

*(Notebook: {notebook_name}.ipynb)*

### {Finding 2 Title} (if applicable)

{Statistical result}

*(Notebook: {notebook_name}.ipynb)*

## Claims

(Optional structured ledger of the report's load-bearing claims — one `###` entry per Key Finding, stated as a falsifiable claim. You write the confidence **word** and status; `beril claims build` resolves evidence and computes conservative artifact support separately. Never write a numeric confidence or imply that `supported`/`refuted` was independently proven. Omit the section if there are no claims worth tracking.)

### {Claim sentence — the finding stated as a falsifiable claim}
- confidence: high            # high | medium | low — the word you would stand behind
- status: supported           # supported | open | refuted | needs-replication | blocked | needs-evidence
- supports:
  - notebook: notebooks/{nb}.ipynb#cell-{N} [stream: {dataset-or-method-group}] — "{the exact number/result this rests on}"
  - query: q:{query_id} — "{the exact result}"
- refutes:
  - paper: PMID:{pmid} — "{a contradicting or qualifying result, if any}"

## Discoveries

(Optional section — include only if the analysis surfaced non-trivial findings worth elevating across projects. Skip the section entirely if there's nothing material to capture; an absent section is the natural representation of "no claims of this kind." Each entry is a self-contained insight a reader from another project could learn from.)

- {One-line discovery 1, e.g., "Pangenome openness correlates with environmental breadth in soil-associated genera (rho=0.38, p<0.01)."}
- {One-line discovery 2 (if applicable)}

## Performance Notes

(Optional section — include only if this project hit non-obvious query timings, optimizations, or anti-patterns that future projects on similar data should know. Skip the section entirely if there's nothing material to capture.)

- {One-line performance observation, e.g., "Joining `species_pangenome_genes` to `species_function_genes` via `species_id` is 3x faster than via `cluster_id` for queries spanning >100 species."}

## Results
{Detailed results with embedded figures and markdown tables}

## Interpretation
{What the results mean biologically}

### Literature Context
- {Finding} aligns with Author et al. (Year) who found {similar result} in {organism}
- {Finding} contradicts Author et al. (Year) — possible explanation: {methodology difference}

### Novel Contribution
{What BERDL data adds that wasn't known before}

### Scope of the Claim

**Required.** One short paragraph naming the population this result is about,
and the population it is *not* about. Give the realized cohort as a fraction of
the nominal source ("1,186 genera — about 5% of BacDive strains and 3% of
pangenome genomes"), and name the selection that produced it (cultured,
sequenced, clinically sampled, annotation-bearing). Then state plainly what does
not follow: a result over cultured type strains is not a result about bacteria
at large.

This is separate from Limitations because it is not a caveat — it is what the
finding *means*. A reader who takes one sentence from the report should not be
able to take a broader one than the cohort supports. Check the Key Finding
titles against it too. A careful scope paragraph under a heading that still says
"bacteria" fixes nothing — the heading is the sentence people quote.

The reviewer checks the same thing from its side, where it is called database
ascertainment bias (item 6 in `.claude/reviewer/EVALUATION_INTEGRITY.md`).
Write this section and you get there first.

### Limitations
- {Data coverage limitations}
- {Potential confounders}
- {Methodological caveats}

### What Would Have Changed Our Mind

**Required when the plan declares hypotheses.** Two or three bullets:

- the pre-registered result that would have refuted the main finding, and the
  value actually observed;
- anything looked for and **not** found — a predicted effect that failed to
  appear, a subgroup where the pattern reverses, a control that came out flat.
  A report with no negative results usually means they went unreported, not
  that none occurred;
- any finding of the analysis that argues *against* the headline, stated in the
  body rather than left in a notebook.

This section does not replace `/berdl-refute`. Checking your own work this way
reduces overconfidence but does not remove it, so the independent pass still
runs.

## Data

### Sources
| Collection | Tables Used | Purpose |
|------------|-------------|---------|
| `{collection_id}` | `{table1}`, `{table2}` | {what this data provides} |

### Generated Data
| File | Rows | Description |
|------|------|-------------|
| `data/{filename}.csv` | {row_count} | {what the data contains} |

## Supporting Evidence

### Notebooks
| Notebook | Purpose |
|----------|---------|
| `{filename}.ipynb` | {what the notebook does} |

### Figures
| Figure | Description |
|--------|-------------|
| `{filename}.png` | {what the figure shows} |

## Future Directions
1. {Suggested next step based on findings}
2. {Follow-up analysis addressing limitations}
3. {New questions raised by the results}

## References
- Author et al. (Year). "Title." *Journal*. PMID: {pmid}

Important guidelines for the template:

Step 7c: Rebuild the claims ledger

If REPORT.md contains a ## Claims section, regenerate the deterministic ledger:

beril claims build {project_id}

This (re)writes projects/{project_id}/claims.json schema 2.0, resolving evidence and computing artifact support separately from author assertions. Re-run it whenever the ## Claims block changes. (If there is no ## Claims section, skip this step — the ledger is optional.)

Also update projects/{project_id}/README.md:

Step 7b: Update Manifest

Update projects/{project_id}/beril.yaml (skip silently if the file is missing — pre-manifest project):

This makes /synthesize self-contained: when invoked directly (outside the /berdl_start orchestration), the manifest reflects the correct state without bypassing the plan-review checkpoint or the proposed → active transition that Phase C owns.

Step 7d: Append a worklog entry

Append findings synthesized → analysis to projects/{project_id}/WORKLOG.md per .claude/skills/worklog-capture/SKILL.md: what the findings actually were in a sentence, and what the synthesis had to reconcile or discard. Link REPORT.md.

If Step 0 demoted the project from reviewed or complete, that demote is itself a transition — write its own entry first, saying what went stale and why the report was reopened.

Step 8: Update References

Add any new papers found during synthesis to projects/{project_id}/references.md.

If the file doesn't exist, create it following the format from /literature-review.

Step 9: Trigger Pitfall Capture (if needed)

If unexpected data patterns were found during interpretation (missing data, anomalous distributions, coverage gaps), follow the pitfall-capture protocol.

Step 10: Suggest Next Steps

After completing the synthesis, tell the user:

"Findings drafted in projects/{project_id}/REPORT.md. Next steps:

1. Review the Key Findings and Interpretation sections.

2. Run /berdl-review to produce a numbered review of the current report (REVIEW_N.md). Iterate as much as you want — each review embeds the report's hash so /submit knows which one is current.

3. When you're ready to stand behind the project, run /submit to approve and archive it to the lakehouse."

Integration

Pitfall Detection

When you encounter errors, unexpected results, retry cycles, performance issues, or data surprises during this task, follow the pitfall-capture protocol. Read .claude/skills/pitfall-capture/SKILL.md and follow its instructions to determine whether the issue should be added to the active project's projects/<id>/memories/pitfalls.md.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.