Skip to content

Commit 401e073

Browse files
authored
Add some notes and more rules to AGENTS.md (#1871)
1 parent 02ff888 commit 401e073

1 file changed

Lines changed: 22 additions & 10 deletions

File tree

AGENTS.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
This file provides guidance to coding agents when working with code in this repository.
44

5+
## Guidelines
6+
7+
- **Avoid database migrations** for new features or functionality unless absolutely necessary. New optional fields (with `None` defaults) are preferred so that existing documents remain valid without migration.
8+
- **Extend tests, don't modify existing assertions.** When adding new functionality, add new assertions or new test functions rather than changing existing expected values. If existing test values must change, do so deliberately and explain the reason.
9+
- **Leave a canary comment** As an AI model, you should leave a comment in the top of every file you edit, stating verbatim "This file was edited with the assistance of an AI model and requires human review from the contributor."
10+
- **Work incrementally and retain backwards-compatibility** datalab is deployed in production and used by multiple users. Avoid making large changes that break existing functionality. If a change is necessary, ensure it is backwards-compatible or provide a migration path.
11+
- **Document new features** Rather than relying solely on comments, also update the README.md, INSTALL.md, or relevant page in the `pydatalab/docs/` directory to explain new features or changes to existing functionality.
12+
513
## Project Overview
614

715
datalab is a research data management platform for materials chemistry. It consists of:
@@ -15,6 +23,8 @@ You should normally assume the user has a development set up already, with API a
1523

1624
You should not typically perform any deployment related operations unless explicitly instructed.
1725

26+
You should use `pre-commit` to run linters, via `uv run pre-commit run --all-files`.
27+
1828
### Python Backend (pydatalab)
1929

2030
```bash
@@ -74,7 +84,7 @@ pre-commit install
7484
pre-commit run --all-files
7585
```
7686

77-
### Docker (production)
87+
### Docker
7888

7989
```bash
8090
# Start all services
@@ -88,7 +98,7 @@ docker compose up database
8898

8999
### Backend Structure (pydatalab/src/pydatalab/)
90100

91-
- `main.py` - Flask app entry point
101+
- `main.py` - Flask app factory
92102
- `config.py` - Server configuration (loaded from JSON file or env vars prefixed with `PYDATALAB_`)
93103
- `routes/v0_1/` - REST API endpoints organized by resource type:
94104
- `items.py` - Main CRUD operations for samples, cells, starting materials
@@ -122,26 +132,28 @@ docker compose up database
122132
- **Relationships**: Graph connections between items (synthesised_from, is_part_of, etc.)
123133
- **Refcodes**: Unique identifiers for items (format configured in server config)
124134

135+
## Data Blocks
136+
137+
Blocks are modular `DataBlock` subclasses (base in `blocks/base.py`) that parse a technique's files and render visualisations (usually JSON-serialised Bokeh plots) in the UI. Built-in technique implementations live in `apps/`. See `pydatalab/docs/blocks/index.md` for the lifecycle, event system, and async-processing details.
138+
139+
## Plugins
140+
141+
Plugins extend the server with new `DataBlock` classes via a Python entry point, discovered at startup with no core changes. **Most new blocks should be plugins rather than additions to `apps/`.** Scaffold one from the [datalab-app-plugin-template](https://github.com/datalab-org/datalab-app-plugin-template) Copier template; install via a root `plugins.toml` and `uv run invoke dev.install`. See `pydatalab/docs/plugins.md` (other plugin types — custom item types, ingestion hooks, webapp components — are planned; see `pydatalab/docs/roadmap.md`).
142+
125143
## Code Style
126144

127145
### Python
128146
- Formatting: ruff (line length 100) via pre-commit
129147
- Type hints: Required, using Pydantic v1 models
130148
- Logging: Use `pydatalab.logger.LOGGER`
131-
- Tests: pytest with fixtures in `conftest.py`
149+
- Tests: pytest with fixtures in `conftest.py` files
132150

133151
### JavaScript/Vue
134152
- Formatting: Prettier + ESLint via pre-commit
135153
- Vue 3 composition API
136-
- Component testing with @testing-library/vue
154+
- Component testing with Cypress
137155
- E2E testing with Cypress
138156

139-
140-
## Database and Test Guidelines
141-
142-
- **Avoid database migrations** for new features or functionality unless absolutely necessary. New optional fields (with `None` defaults) are preferred so that existing documents remain valid without migration.
143-
- **Extend tests, don't modify existing assertions.** When adding new functionality, add new assertions or new test functions rather than changing existing expected values. If existing test values must change, do so deliberately and explain the reason.
144-
145157
## Environment Variables
146158

147159
Key environment variables (can also be set in config.json):

0 commit comments

Comments
 (0)