From 0821352dd7f24edde1d8ad9c5b467b6d97a3c212 Mon Sep 17 00:00:00 2001 From: Marius1311 Date: Tue, 17 Nov 2026 15:19:48 +0100 Subject: [PATCH 1/7] Conventions for data lineage: `writes` blocks and `inputs.yaml` Follows analysis-workflow 0.8: every write into `processed/` sits in a `writes` block, which records in the store which task wrote what, and each task's `inputs.yaml` lists what its code consumed. - CONVENTIONS: the `%%writes` form of a write-back; stores only grow; a changed key gets a new name in a dated copy; plain files under `data/` carry no record; `inputs.yaml`, how to get it written, and `analysis-workflow trace`. - REVIEW_GUIDE: flag writes outside a block and keys changed under their old name; compare a task's `inputs.yaml` with what its code consumes, replacing "every key appears in the README". - Starter notebook and demo: the write cell starts with `%%writes`; the demo task gets its `inputs.yaml`. Co-Authored-By: Claude Fable 5.2 --- {{cookiecutter.project_name}}/CONVENTIONS.md | 38 ++++++++++++++++--- {{cookiecutter.project_name}}/REVIEW_GUIDE.md | 24 ++++++++---- .../demo/human_scrna_workflow_v1/README.md | 7 ++-- .../demo/human_scrna_workflow_v1/inputs.yaml | 5 +++ .../notebooks/01_scrna_workflow.ipynb | 14 ++++++- .../templates/notebook.ipynb | 9 ++++- 6 files changed, 78 insertions(+), 19 deletions(-) create mode 100644 {{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/inputs.yaml diff --git a/{{cookiecutter.project_name}}/CONVENTIONS.md b/{{cookiecutter.project_name}}/CONVENTIONS.md index f347a01..8f0f41a 100644 --- a/{{cookiecutter.project_name}}/CONVENTIONS.md +++ b/{{cookiecutter.project_name}}/CONVENTIONS.md @@ -31,6 +31,7 @@ All analysis lives in task directories, `analysis///_.ipynb`, numbered in run order; outputs committed, so keep them small | | `scripts/` | yes | `NN_.py`, numbered in run order; `_common.py` holds the task's paths | | `results/` | yes | small evidence tables; past ~1 MB they belong in `outputs/` | @@ -59,8 +60,14 @@ fig.savefig(PATHS.figures / "umap.pdf") | `resources/` | curated inputs that are not data: gene lists, marker tables | | `processed/` | objects other tasks load: working objects in `working/`, others in descriptively named subdirectories | -A task writes into its own directory. An object other tasks will load goes to `processed/` (for an agent, after -sign-off), and the task README records its path. +A task writes into its own directory, and so do the external tools and shell scripts it runs. An object other +tasks will load goes to `processed/` (for an agent, after sign-off), and the task README records its path. + +Every write into `processed/` sits in a `writes` block: a notebook cell that starts `%%writes `, or +`with writes():` in a script, where `` is the store. It records in the store which task wrote what +(`adata.uns["provenance"]`, `sdata.attrs["provenance"]`). That goes for a write-back, a new object, a new +SpatialData element and a copy out of a task's `outputs/`. Stores only grow: nothing in one is replaced or removed +in place. A plain file under `data/` carries no such record. ## Working objects @@ -75,18 +82,37 @@ tasks accumulate. from analysis_workflow import commit_adata commit_adata(adata, path, keys={"obs": ["leiden_fine"]}) # dry run: shows what it would write + ``` + + ```python + %%writes path commit_adata(adata, path, keys={"obs": ["leiden_fine"]}, yes=True) # writes ``` - Never write an in-memory object over a working object: it erases what others added since you read it. Changing - or removing a key means a new dated copy. -- Create one with `adata.write_zarr(path, consolidate_metadata=False)`, at a path that doesn't exist yet. Readers of - a consolidated store never see keys added later, so `commit_adata` refuses one. -- Give keys descriptive names, and list each in the task README's Write-back section. + or removing a key means a new dated copy. In it a key may be dropped; one whose values change gets a new name, + so a name stands for the same values in every copy. +- Create one with `adata.write_zarr(path, consolidate_metadata=False)` in a `writes` block, at a path that doesn't + exist yet. Readers of a consolidated store never see keys added later, so `commit_adata` refuses one. +- Give keys descriptive names, and say what each holds in the task README's Write-back section. - Labels: one categorical `obs` column, colours in `uns["_colors"]`. - A result that would grow the object materially (`analyze_anndata_size`) becomes a standalone AnnData on the same `obs_names`, never a bare `.npy`. +## What an artifact rests on + +Two records answer it. A store records which task wrote each of its keys (Data, above). A task's `inputs.yaml` +lists what its code consumed: stores with the keys used, other tasks' files, data files. The +[analysis-workflow](https://github.com/quadbio/analysis-workflow) plugin's `declare-inputs` skill writes that list +from the task's scripts and notebooks: when a task is finished, ask an agent in this repo to declare its inputs. + +```bash +pixi run analysis-workflow trace # or: trace +``` + +then shows the tasks and artifacts a key or a file rests on, back to the raw data, and fails on a task whose +inputs are not declared. The plugin's `trace-lineage` skill writes it up as a graph and a summary. + ## Git You work in the main checkout. A pull request is optional and encouraged for anything others build on: diff --git a/{{cookiecutter.project_name}}/REVIEW_GUIDE.md b/{{cookiecutter.project_name}}/REVIEW_GUIDE.md index 6e9f7a2..2da2b21 100644 --- a/{{cookiecutter.project_name}}/REVIEW_GUIDE.md +++ b/{{cookiecutter.project_name}}/REVIEW_GUIDE.md @@ -19,6 +19,7 @@ code loads): - **Accumulate by addition.** Adding keys to freshly re-read state is commutative, so concurrent sessions can't lose each other's work. Removal isn't: that means a new dated copy. - **Writing back to a shared object needs sign-off on that specific diff.** +- **Every write is recorded.** It sits in a `writes` block, which notes in the store which task wrote what. ## Priorities @@ -28,25 +29,34 @@ A write to a working object goes through `commit_adata`, gated behind a dry run. - an in-memory AnnData written back over a working object (`write_zarr`/`write_h5ad` onto its path): it erases whatever other sessions added since it was read; -- a replaced SpatialData image, labels, points or shapes element, where a new element name would do. +- a replaced SpatialData image, labels, points or shapes element, where a new element name would do; +- a write into `data//processed/` outside a `writes` block, a shell `cp` or `mv` among them: the store + then has no record of the task; +- in a new dated copy, a key whose values changed under its old name. ### 2. Promotions, which leave no diff -`data/` is gitignored, so an object written into `data//processed/` appears nowhere in the diff; the task -README's `Write-back` section is the only trace. The right subdirectory is not guessable. Check that the README +`data/` is gitignored, so an object written into `data//processed/` appears nowhere in the diff. The +store records which task wrote it; where it went is in the task README's `Write-back` section. The right +subdirectory is not guessable. Check that the README *says* where it went and, for an agent's PR, that the PR body flags it for sign-off and that it was agreed, while moving it is still cheap. ### 3. The task contract Work belongs in a task directory `analysis///.../__vN/`. Check that its README's -content is real: the actual input files, the deliverables, a short summary of each PR. An edit to a frozen task's -directory (one written back from, or merged) is a finding: analysis moves forward, and a new version names the one -it follows. A task is one branch merged through one or more PRs, so a directory whose earlier PRs (its README lists +content is real: the deliverables, a short summary of each PR. An edit to a frozen task's directory (one written +back from, or merged) is a finding, other than to its `inputs.yaml`: analysis moves forward, and a new version +names the one it follows. A task is one branch merged through one or more PRs, so a directory whose earlier PRs (its README lists them) came from this PR's branch is this task's own, not an earlier one. Outputs written outside the task directory, other than to a shared object, are a finding. -Every key committed to a shared object appears in that README: an unrecorded key can't be traced back. +**Declared inputs.** Each task directory holds `inputs.yaml`: the stores, with the keys used, and the files its +code consumes. Extract a task's inputs from its scripts and notebooks yourself, before reading its `inputs.yaml`: +the keys of a shared store the code uses (not merely loads), including keys used through the defaults of functions +it calls; files of other tasks; data files. Leave out what the task writes itself. Then compare. Report each input +the code uses that the file lacks, and each entry the code does not use. A finished task without the list is a +finding. ### 4. Scientific correctness diff --git a/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/README.md b/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/README.md index 01dac55..6cf144f 100644 --- a/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/README.md +++ b/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/README.md @@ -21,15 +21,16 @@ otherwise; a later change is recorded here too. --> ## Inputs - + - scanpy's PBMC 3k dataset, downloaded to `data/example_dataset/raw/` - CellTypist's `Immune_All_High.pkl` model ## Write-back - + - `data/example_dataset/processed/working/pbmc3k_2026-01-27.zarr`, a new working object, holding: - `obsm["X_scVI"]`, `obsm["X_umap"]`: scVI latent space and its UMAP diff --git a/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/inputs.yaml b/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/inputs.yaml new file mode 100644 index 0000000..fd222b5 --- /dev/null +++ b/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/inputs.yaml @@ -0,0 +1,5 @@ +task: 5c1d9e42 +# This task's id, set by `analysis-workflow new`, and what its code consumed, written by the `declare-inputs` +# skill once the task is finished. Not edited by hand. +inputs: + - path: data/example_dataset/raw/pbmc3k_raw.h5ad diff --git a/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/notebooks/01_scrna_workflow.ipynb b/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/notebooks/01_scrna_workflow.ipynb index b2cd190..c3e913e 100644 --- a/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/notebooks/01_scrna_workflow.ipynb +++ b/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/notebooks/01_scrna_workflow.ipynb @@ -478,7 +478,7 @@ "source": [ "### 💾 Save Results — 💻 Local\n", "\n", - "This notebook starts a new working object: a dated zarr store in `processed/working/` that other tasks load and add keys to with `commit_adata`. It is written without consolidated metadata, so those additions stay visible." + "This notebook starts a new working object: a dated zarr store in `processed/working/` that other tasks load and add keys to with `commit_adata`. It is written without consolidated metadata, so those additions stay visible. The cell that writes it starts with `%%writes`, so the store records which task wrote its keys." ] }, { @@ -490,7 +490,17 @@ "source": [ "output_path = FilePaths.EXAMPLE_DATASET / \"processed\" / \"working\" / \"pbmc3k_2026-01-27.zarr\"\n", "if output_path.exists(): # other tasks may have added to it since: never write over it\n", - " raise FileExistsError(f\"{output_path} exists; write a new dated copy instead.\")\n", + " raise FileExistsError(f\"{output_path} exists; write a new dated copy instead.\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "37a", + "metadata": {}, + "outputs": [], + "source": [ + "%%writes output_path\n", "adata.write_zarr(output_path, consolidate_metadata=False)\n", "print(f\"Saved to: {output_path}\")" ] diff --git a/{{cookiecutter.project_name}}/templates/notebook.ipynb b/{{cookiecutter.project_name}}/templates/notebook.ipynb index 39b2d3c..e703118 100644 --- a/{{cookiecutter.project_name}}/templates/notebook.ipynb +++ b/{{cookiecutter.project_name}}/templates/notebook.ipynb @@ -127,12 +127,19 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Results for other tasks go into the working object, under keys you name; list them in the README. Run the dry run, check it, then pass `yes=True`:\n", + "Results for other tasks go into the working object, under keys you name; say what each holds in the README. Run the dry run and check it:\n", "\n", "```python\n", "from analysis_workflow import commit_adata\n", "\n", "commit_adata(adata, WORKING_OBJECT, keys={\"obs\": [\"\"]})\n", + "```\n", + "\n", + "Then write, in a cell that starts with `%%writes`, so the store records which task wrote the keys:\n", + "\n", + "```python\n", + "%%writes WORKING_OBJECT\n", + "commit_adata(adata, WORKING_OBJECT, keys={\"obs\": [\"\"]}, yes=True)\n", "```" ] } From 63a810dbbc61cff22c3832eb7997aced77637cfb Mon Sep 17 00:00:00 2001 From: Marius1311 Date: Tue, 17 Nov 2026 15:29:49 +0100 Subject: [PATCH 2/7] Demo: declare the CellTypist model as an input Co-Authored-By: Claude Fable 5.2 --- .../example_dataset/demo/human_scrna_workflow_v1/inputs.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/inputs.yaml b/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/inputs.yaml index fd222b5..e7852f9 100644 --- a/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/inputs.yaml +++ b/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/inputs.yaml @@ -1,5 +1,6 @@ -task: 5c1d9e42 +task: "5c1d9e42" # This task's id, set by `analysis-workflow new`, and what its code consumed, written by the `declare-inputs` # skill once the task is finished. Not edited by hand. inputs: - path: data/example_dataset/raw/pbmc3k_raw.h5ad + - path: ~/.celltypist/data/models/Immune_All_High.pkl From 6441255aa64bc77d7370fd744c39ec6df34e8ee1 Mon Sep 17 00:00:00 2001 From: Marius1311 Date: Tue, 17 Nov 2026 16:41:29 +0100 Subject: [PATCH 3/7] Task README: no Inputs section What a task consumed is in its `inputs.yaml`, so the README section held nothing of its own. The demo's two entries are already in its `inputs.yaml`. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01WtTJWVCHDBr1Lcg8K1Gaft --- {{cookiecutter.project_name}}/CONVENTIONS.md | 4 ++-- .../demo/human_scrna_workflow_v1/README.md | 8 -------- {{cookiecutter.project_name}}/templates/notebook.ipynb | 2 +- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/{{cookiecutter.project_name}}/CONVENTIONS.md b/{{cookiecutter.project_name}}/CONVENTIONS.md index 8f0f41a..5c2b561 100644 --- a/{{cookiecutter.project_name}}/CONVENTIONS.md +++ b/{{cookiecutter.project_name}}/CONVENTIONS.md @@ -13,7 +13,7 @@ pixi run analysis-workflow new analysis///human__v1 --auth ``` This creates the task directory with its `README.md` and a starter notebook in `notebooks/`. Open the notebook, -fill in the README's question and inputs, and work. +fill in the README's question, and work. ## Tasks @@ -30,7 +30,7 @@ All analysis lives in task directories, `analysis///_.ipynb`, numbered in run order; outputs committed, so keep them small | | `scripts/` | yes | `NN_.py`, numbered in run order; `_common.py` holds the task's paths | diff --git a/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/README.md b/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/README.md index 6cf144f..1aadae4 100644 --- a/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/README.md +++ b/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/README.md @@ -19,14 +19,6 @@ otherwise; a later change is recorded here too. --> | UMAP overviews | `figures/` (gitignored) | | a new working object | Write-back, below | -## Inputs - - - -- scanpy's PBMC 3k dataset, downloaded to `data/example_dataset/raw/` -- CellTypist's `Immune_All_High.pkl` model - ## Write-back diff --git a/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/inputs.yaml b/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/inputs.yaml index e7852f9..2ccb292 100644 --- a/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/inputs.yaml +++ b/{{cookiecutter.project_name}}/analysis/example_dataset/demo/human_scrna_workflow_v1/inputs.yaml @@ -1,6 +1,2 @@ -task: "5c1d9e42" -# This task's id, set by `analysis-workflow new`, and what its code consumed, written by the `declare-inputs` -# skill once the task is finished. Not edited by hand. -inputs: - - path: data/example_dataset/raw/pbmc3k_raw.h5ad - - path: ~/.celltypist/data/models/Immune_All_High.pkl +- path: data/example_dataset/raw/pbmc3k_raw.h5ad +- path: ~/.celltypist/data/models/Immune_All_High.pkl From 75c038da7cb2abe24567b01bfa31554e81f82483 Mon Sep 17 00:00:00 2001 From: Marius1311 Date: Wed, 18 Nov 2026 10:44:46 +0100 Subject: [PATCH 5/7] Only stores go to `processed/`; any other file other tasks load stays with its task A file of another format cannot hold a record of which task made it. In the task's `results/` or `outputs/`, its location says so. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01WtTJWVCHDBr1Lcg8K1Gaft --- {{cookiecutter.project_name}}/CONVENTIONS.md | 12 +++++++----- {{cookiecutter.project_name}}/REVIEW_GUIDE.md | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/{{cookiecutter.project_name}}/CONVENTIONS.md b/{{cookiecutter.project_name}}/CONVENTIONS.md index a25b8e2..abae7dd 100644 --- a/{{cookiecutter.project_name}}/CONVENTIONS.md +++ b/{{cookiecutter.project_name}}/CONVENTIONS.md @@ -57,17 +57,19 @@ fig.savefig(PATHS.figures / "umap.pdf") | `data//` | holds | | --- | --- | | `raw/` | bytes as they arrived, never changed | -| `resources/` | curated inputs that are not data: gene lists, marker tables | -| `processed/` | objects other tasks load: working objects in `working/`, others in descriptively named subdirectories | +| `resources/` | curated inputs from outside the repo that are not data: gene lists, marker tables | +| `processed/` | AnnData and SpatialData stores other tasks load: working objects in `working/`, others in descriptively named subdirectories | -A task writes into its own directory, and so do the external tools and shell scripts it runs. An object other -tasks will load goes to `processed/` (for an agent, after sign-off), and the task README records its path. +A task writes into its own directory, and so do the external tools and shell scripts it runs. An AnnData or +SpatialData store other tasks will load goes to `processed/` (for an agent, after sign-off), and the task README +records its path. Any other file they will load stays in the task that made it, in `results/` or `outputs/`, and +is read from there: it cannot hold a record of its own, and there its location says which task made it. Every write into `processed/` sits in a `writes` block: a notebook cell that starts `%%writes `, or `with writes():` in a script, where `` is the store. It records in the store which task wrote what (`adata.uns["provenance"]`, `sdata.attrs["provenance"]`). That goes for a write-back, a new object, a new SpatialData element and a copy out of a task's `outputs/`. Stores only grow: nothing in one is replaced or removed -in place. A plain file under `data/` carries no such record. +in place. ## Working objects diff --git a/{{cookiecutter.project_name}}/REVIEW_GUIDE.md b/{{cookiecutter.project_name}}/REVIEW_GUIDE.md index 2da2b21..d31f0d7 100644 --- a/{{cookiecutter.project_name}}/REVIEW_GUIDE.md +++ b/{{cookiecutter.project_name}}/REVIEW_GUIDE.md @@ -32,6 +32,7 @@ A write to a working object goes through `commit_adata`, gated behind a dry run. - a replaced SpatialData image, labels, points or shapes element, where a new element name would do; - a write into `data//processed/` outside a `writes` block, a shell `cp` or `mv` among them: the store then has no record of the task; +- a file of another format that other tasks load, placed under `data/`: nothing says which task made it; - in a new dated copy, a key whose values changed under its old name. ### 2. Promotions, which leave no diff From 3a81339c05a4e992aec471ff90a0455a81cf00cb Mon Sep 17 00:00:00 2001 From: Marius1311 Date: Wed, 18 Nov 2026 11:11:00 +0100 Subject: [PATCH 6/7] Any object other tasks load goes to `processed/` again; the limitation for plain files is stated Only AnnData and SpatialData stores hold a record of the task that wrote them. Another file under `data/` has none: a trace stops at it, and the task's README is the only link. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01WtTJWVCHDBr1Lcg8K1Gaft --- {{cookiecutter.project_name}}/CONVENTIONS.md | 13 +++++++------ {{cookiecutter.project_name}}/REVIEW_GUIDE.md | 1 - 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/{{cookiecutter.project_name}}/CONVENTIONS.md b/{{cookiecutter.project_name}}/CONVENTIONS.md index abae7dd..b8e27d8 100644 --- a/{{cookiecutter.project_name}}/CONVENTIONS.md +++ b/{{cookiecutter.project_name}}/CONVENTIONS.md @@ -57,13 +57,11 @@ fig.savefig(PATHS.figures / "umap.pdf") | `data//` | holds | | --- | --- | | `raw/` | bytes as they arrived, never changed | -| `resources/` | curated inputs from outside the repo that are not data: gene lists, marker tables | -| `processed/` | AnnData and SpatialData stores other tasks load: working objects in `working/`, others in descriptively named subdirectories | +| `resources/` | curated inputs that are not data: gene lists, marker tables | +| `processed/` | objects other tasks load: working objects in `working/`, others in descriptively named subdirectories | -A task writes into its own directory, and so do the external tools and shell scripts it runs. An AnnData or -SpatialData store other tasks will load goes to `processed/` (for an agent, after sign-off), and the task README -records its path. Any other file they will load stays in the task that made it, in `results/` or `outputs/`, and -is read from there: it cannot hold a record of its own, and there its location says which task made it. +A task writes into its own directory, and so do the external tools and shell scripts it runs. An object other +tasks will load goes to `processed/` (for an agent, after sign-off), and the task README records its path. Every write into `processed/` sits in a `writes` block: a notebook cell that starts `%%writes `, or `with writes():` in a script, where `` is the store. It records in the store which task wrote what @@ -71,6 +69,9 @@ Every write into `processed/` sits in a `writes` block: a notebook cell that sta SpatialData element and a copy out of a task's `outputs/`. Stores only grow: nothing in one is replaced or removed in place. +**Limitation.** Only AnnData and SpatialData stores hold such a record. Any other file under `data/` has none: a +trace stops at it, and the only link to the task that made it is that task's README. + ## Working objects A working object is an AnnData zarr store, `processed/working/_.zarr`, in which results from many diff --git a/{{cookiecutter.project_name}}/REVIEW_GUIDE.md b/{{cookiecutter.project_name}}/REVIEW_GUIDE.md index d31f0d7..2da2b21 100644 --- a/{{cookiecutter.project_name}}/REVIEW_GUIDE.md +++ b/{{cookiecutter.project_name}}/REVIEW_GUIDE.md @@ -32,7 +32,6 @@ A write to a working object goes through `commit_adata`, gated behind a dry run. - a replaced SpatialData image, labels, points or shapes element, where a new element name would do; - a write into `data//processed/` outside a `writes` block, a shell `cp` or `mv` among them: the store then has no record of the task; -- a file of another format that other tasks load, placed under `data/`: nothing says which task made it; - in a new dated copy, a key whose values changed under its old name. ### 2. Promotions, which leave no diff From 34f2be768a7360a99cddf027ff0925db34beb9c8 Mon Sep 17 00:00:00 2001 From: Marius1311 Date: Wed, 18 Nov 2026 12:11:10 +0100 Subject: [PATCH 7/7] Review: the conventions say what humans do, without "you"; the README points to them first - CONVENTIONS.md opens by saying it is written for humans and applies to their work throughout; agents are mentioned only where a human needs to know what they do. Sentences that addressed the reader as "you" now name who acts. - `analysis-workflow new` no longer needs `--author` for a human's task: the author line takes the git user name. - README: a pointer to the conventions at the top. Co-Authored-By: Claude Fable 5.2 Claude-Session: https://claude.ai/code/session_01WtTJWVCHDBr1Lcg8K1Gaft --- {{cookiecutter.project_name}}/CONVENTIONS.md | 38 +++++++++++--------- {{cookiecutter.project_name}}/README.md | 5 ++- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/{{cookiecutter.project_name}}/CONVENTIONS.md b/{{cookiecutter.project_name}}/CONVENTIONS.md index b8e27d8..c0c8d74 100644 --- a/{{cookiecutter.project_name}}/CONVENTIONS.md +++ b/{{cookiecutter.project_name}}/CONVENTIONS.md @@ -1,19 +1,23 @@ # Conventions -How analysis is organized in this repo. Humans and coding agents follow the same rules; agents add their own on top -(a worktree, a session and a PR per task, sign-off on every write-back), from the -[analysis-workflow](https://github.com/quadbio/analysis-workflow) plugin. +How analysis is organized in this repo, written for the humans working in it: everything here applies to a human's +work. Coding agents follow the same rules and add their own on top (a worktree, a session and a PR per task, a +human's sign-off on every write-back), from the [analysis-workflow](https://github.com/quadbio/analysis-workflow) +plugin. Agents are mentioned here only where a human needs to know what they do. > Everything here comes from the analysis template; change it there and pull it with `cruft update`. ## Start a task +A human starts a task with + ```bash -pixi run analysis-workflow new analysis///human__v1 --author --notebook 01_ +pixi run analysis-workflow new analysis///human__v1 --notebook 01_ ``` -This creates the task directory with its `README.md` and a starter notebook in `notebooks/`. Open the notebook, -fill in the README's question, and work. +which creates the task directory with its `README.md` and a starter notebook in `notebooks/`, then opens the +notebook, fills in the README's question, and works. The README's author line takes the git user name; +`--author ` sets another. ## Tasks @@ -21,7 +25,7 @@ All analysis lives in task directories, `analysis///_` is there even when the repo has one dataset. Topics, such as `preprocessing/`, `annotation/` or `spatial/`, can mostly be worked on in any order. -- `` is `human` or `agent`; the README's author line says who: initials, or the model. +- `` is `human` or `agent`; the README's author line says who: a name, or the model. - `vN` counts the answers to one question across both lanes: `human_markers_v1` may be followed by `agent_markers_v2`. `analysis-workflow new` refuses any other version than the next. - A task is edited freely until its first write-back to a shared object or until other tasks read its outputs (for @@ -61,7 +65,8 @@ fig.savefig(PATHS.figures / "umap.pdf") | `processed/` | objects other tasks load: working objects in `working/`, others in descriptively named subdirectories | A task writes into its own directory, and so do the external tools and shell scripts it runs. An object other -tasks will load goes to `processed/` (for an agent, after sign-off), and the task README records its path. +tasks will load goes to `processed/` (an agent puts it there only after a human's sign-off), and the task README +records its path. Every write into `processed/` sits in a `writes` block: a notebook cell that starts `%%writes `, or `with writes():` in a script, where `` is the store. It records in the store which task wrote what @@ -77,8 +82,8 @@ trace stops at it, and the only link to the task that made it is that task's REA A working object is an AnnData zarr store, `processed/working/_.zarr`, in which results from many tasks accumulate. -- Read only what you need: `ad.io.read_elem(zarr.open_group(path)["obs"])`, or `ad.experimental.read_lazy`. -- Write back only through `commit_adata`, naming the keys you add. It refuses a key that is already there, so +- Read only what is needed: `ad.io.read_elem(zarr.open_group(path)["obs"])`, or `ad.experimental.read_lazy`. +- Write back only through `commit_adata`, naming the keys to add. It refuses a key that is already there, so nobody's results get overwritten: ```python @@ -92,7 +97,7 @@ tasks accumulate. commit_adata(adata, path, keys={"obs": ["leiden_fine"]}, yes=True) # writes ``` -- Never write an in-memory object over a working object: it erases what others added since you read it. Changing +- Never write an in-memory object over a working object: it erases what others added since it was read. Changing or removing a key means a new dated copy. In it a key may be dropped; one whose values change gets a new name, so a name stands for the same values in every copy. - Create one with `adata.write_zarr(path, consolidate_metadata=False)` in a `writes` block, at a path that doesn't @@ -107,7 +112,8 @@ tasks accumulate. Two records answer it. A store records which task wrote each of its keys (Data, above). A task's `inputs.yaml` lists what its code consumed: stores with the keys used, other tasks' files, data files. The [analysis-workflow](https://github.com/quadbio/analysis-workflow) plugin's `declare-inputs` skill writes that list -from the task's scripts and notebooks: when a task is finished, ask an agent in this repo to declare its inputs. +from the task's scripts and notebooks. For a human's task, the human asks an agent in this repo to declare its +inputs once the task is finished. ```bash pixi run analysis-workflow trace # or: trace @@ -118,7 +124,8 @@ inputs are not declared. The plugin's `trace-lineage` skill writes it up as a gr ## Git -You work in the main checkout. A pull request is optional and encouraged for anything others build on: +Humans work in the main checkout. For a human's task a pull request is optional, and encouraged for anything +others build on: ```bash git switch -c @@ -127,6 +134,5 @@ git push -u origin gh pr create # its body starts from the PR template ``` -It is reviewed against `REVIEW_GUIDE.md`. Switching -branches changes the main checkout that agents' sessions read, `pixi.toml` included: switch back to `main` when you -are done. +It is reviewed against `REVIEW_GUIDE.md`. Switching branches changes the main checkout that agents' sessions read, +`pixi.toml` included, so a human switches back to `main` when done. diff --git a/{{cookiecutter.project_name}}/README.md b/{{cookiecutter.project_name}}/README.md index 3fbc56a..e625fa0 100644 --- a/{{cookiecutter.project_name}}/README.md +++ b/{{cookiecutter.project_name}}/README.md @@ -4,6 +4,9 @@ +**Working in this repo?** Read [`CONVENTIONS.md`](CONVENTIONS.md) before the first task: it says how analysis is +organized here, for humans and coding agents alike. + --- ## 🚀 Getting Started @@ -80,7 +83,7 @@ In Jupyter Lab, check that your kernel appears (look for `{{ cookiecutter.projec Each piece of analysis gets its own task directory. Start one with a notebook in it: ```bash -pixi run analysis-workflow new analysis///human__v1 --author --notebook 01_ +pixi run analysis-workflow new analysis///human__v1 --notebook 01_ ``` - **How it fits together**: [`CONVENTIONS.md`](CONVENTIONS.md): task directories, where outputs go, `data/`, and