Activation Contract
Use at project entry or when Odoo tooling changes, before phases that consume
project context. Detect locally and persist the result; do not guess missing
values.
When to Use
Use when entering a new Odoo project, or when project tooling changes (new test runner, new dependencies). Persist to Engram under odf-init/{project} so all ODF phases reuse the config without re-detecting.
Hard Rules
| Rule | Requirement |
|------|-------------|
| Never ask what can be detected | Try all detection methods before asking the user |
| Never guess | If detection fails for a field, set it to null — don't invent |
| Never invent context | project_context.principles and project_context.glossary only contain detected or explicitly confirmed entries; leave them empty when absent |
| Partial is better than none | Persist even partial detection |
| Upsert | Running /odf-init again updates the existing config |
Decision Gates
| Condition | Action |
|-----------|--------|
| Version in prompt | Use it directly |
| No version in prompt | Try: manifest.py → odoo-bin --version → Dockerfile → ask user |
| Test runner found via detection | Use detected command template with {module} placeholder |
| Docker Compose present (docker-compose.yml / compose.yml / compose.yaml with an odoo service) | Build template docker compose run --rm <service> odoo -d {test_db} -i {module} --test-enable --stop-after-init; disposable {test_db} is preferred |
| Local odoo-bin found with a named database | Build template odoo-bin -d {test_db} -i {module} --test-enable --stop-after-init; a non-isolated development database is allowed only for this run when the current user-approved scope names that exact {test_db} and authorizes its use |
| No exact database or current authorization for a non-isolated database | Block and ask the user; never guess a database or use a developer/production database without current authorization |
| No test runner detected | Flag WARNING, set runner: none |
| Doodba odoo/custom/src/addons.yaml present | Parse sources (active/commented), classify declared-absent and undeclared repos, and resolve project module dependencies against active sources |
| CodeGraph CLI available and <repo>/.codegraph/ missing | Initialize the project index (default) or the active sources (--deep, opt-in, with a cost warning) |
Execution Steps
- Deterministic scan (preferred): run the CLI once instead of hand-scanning:
```
PACK="${ODF_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}"
node "$PACK/scripts/odf-project-scan.js" --root <doodba-workspace-root> --repo <repo-dir> --persist --format json
```
The pack path is deterministic: $ODF_CONFIG_DIR when set, else the pack the running module ships in, else ${XDG_CONFIG_HOME:-$HOME/.config}/opencode. Never search the filesystem for the script. If $PACK/scripts/odf-project-scan.js does not exist, reinstall the pack (install.sh from the repo or /odf-registry-refresh) or fall back to the manual steps below; for a project-local pack prefer the project launcher, which exports ODF_CONFIG_DIR. The CLI assembles the full config (sources, compose, linting, git, CodeGraph, dependency matrix), persists it to Engram under odf-init/{project}, verifies the readback with an explicit --project {project} scope (never the invocation cwd), and exits 0 (ok), 1 (warnings), or 2 (blocked). On verified persistence it prints artifact_ref: {"store":"engram","ref":"odf-init/{project}"}. Use --diff on re-detection to show changes vs the persisted config, --fresh to bypass the checksum cache, and flags for overrides (--odoo-version, --docker-container, --codegraph for CodeGraph init opt-in). The orchestrator relays the summary and interprets warnings only; it never re-derives the config. If the CLI cannot run (no node/script), fall back to the manual steps below — never guess.
- Detect version: manifest.py → odoo-bin → Dockerfile → ask
- Detect modules: Find all manifest.py, classify as custom/oca/core-override
- Environment Context (Doodba): When the workspace is a Doodba layout, detect the source manifest and resolve project module dependencies:
- Locate the workspace root (where
odoo/custom/src/addons.yamllives) and run:
```
PACK="${ODF_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}"
node "$PACK/scripts/odf-env-detect.js" --root <root> --repo <repo> --json
```
($PACK is deterministic — $ODF_CONFIG_DIR when set, else ${XDG_CONFIG_HOME:-$HOME/.config}/opencode; never search the filesystem.)
- Persist under the config:
environment: { type: doodba, addons_yaml, sources: { active, declared_absent, undeclared, active_repos } }anddependency_matrix. - Interpret
dependency_matrix.unresolved_in_sourcesdeps ascore-assumedwhen they are standard Odoo addons (web, stock, sale, base, etc.) — they come from the Docker image. When an unresolved dep looks like a custom/OCA module not present in any active source, flag it as a WARNING/risk (missing repo, wrong branch, or undeclared source).
- CodeGraph Index:
- Call
odf_community_tool_detect("codegraph"). If unavailable, warn and suggestodf_community_tool_install("codegraph", workspace_dir)— never install silently. - If
<repo>/.codegraph/is missing → runcodegraph initon the project repo. If present → runcodegraph status, and runcodegraph synconly when the watcher is disabled or the index is stale. - Default indexes ONLY the project repo (fast).
--deep(opt-in flag) additionally indexes each active repo from addons.yaml, bounded, with a cost warning. - Persist
codegraph: { indexed: boolean, root, paths: [], last_sync: <iso|null> }.
- Detect test runner: Priority: Docker Compose → local odoo-bin → pytest-odoo
- Docker Compose: if
docker-compose.yml/compose.yml/compose.yamlexists at the project root and defines anodooservice (orweb/odoo-<name>), the canonical run command is:
```
docker compose run --rm odoo odoo -d {test_db} -i {module} --test-enable --stop-after-init
```
Replace {module} with the module under test and odoo with the real service name if it differs. This is the test_command to persist — do NOT persist a bare odoo-bin invocation for a Docker Compose project.
- Local odoo-bin: if a local
odoo-binis on PATH (or in the repo) and a disposable or explicitly authorized named database is detected, persistodoo-bin -d {test_db} -i {module} --test-enable --stop-after-init. - Database safety: a test command without the exact
-d {test_db}is invalid for Odoo DB tests. Disposable databases remain preferred. A non-isolated development database is allowed only when the current user-approved scope names that exact database and authorizes its use. The phase result/evidence must statedatabase: {test_db},database_isolation: non-isolated,database_authorization: current-user-approved, and warn that tests may mutate module, schema, and test data. Consent to use the database does not authorizedropdb,createdb/reset/restore,DROP DATABASE,DROP TABLE,TRUNCATE,DROP SCHEMA, or destructive re-initialization; those require separate current consent for the exact operation and database and are not test setup. If the exact database or authorization is absent, returnblockedand ask the user. - pytest-odoo: only when a
pytest.ini/setup.cfgconfigures pytest-odoo.
- Detect linting: pre-commit config, pylint-odoo availability, OCA compliance flags
- Detect conventions + project context: Module prefix patterns, git workflow, CI platform, README conventions. Also detect project context when present: principles (engineering rules stated by the repo — CONTRIBUTING, README, pre-commit/OCA config; never invented) and glossary (existing
CONTEXT.mdor domain docs mapping business terms ↔ Odoo models/fields). Persist asproject_context: { principles: [], glossary: {} }; leave both empty when absent — never invent entries - Build config: Assemble YAML with project_name, odoo_version, modules[], environment{}, testing{}, linting{}, flags{}, conventions{}, project_context{}
- Persist the config to Engram under
odf-init/{project}(project context is Engram-canonical; the preflight-selected store applies to change artifacts) and returnartifact_ref: { store: engram, ref: odf-init/{project} }.
- Persist the resolved command under
testing.test_commandwith literal{test_db}and{module}placeholders so IMPLEMENT/VERIFY can substitute the exact authorized database and module under test.
Output Contract
Return the complete shared ODF Result envelope, including every required common field (especially strategy and skill_resolution), with executive_summary ("{project}: Odoo {ver}, {N} modules, {env}, {runner} tests"). Include risks for missing tooling warnings. For a non-isolated database, include its exact name, database_isolation: non-isolated, database_authorization: current-user-approved, and the warning that tests may mutate module, schema, and test data. Use blocked when the exact database or required current authorization is missing.
References
../_shared/result-contract.md— ODF Result envelope../_shared/persistence-contract.md— selected store and artifact references../_shared/odoo-sources.md— Local source paths