Skip to content
This repository was archived by the owner on Sep 5, 2026. It is now read-only.

Commit 40addfd

Browse files
BearsCLOUDclaude
andcommitted
docs: add CLAUDE.md guidance for Claude Code sessions
Records the non-obvious operating knowledge for this repo: unittest-only test commands, the single-file two-server MCP runtime layout, SQLite integrity invariants, dual-runtime packaging map, version-bump and CD constraints, and the test-enforced repository budgets. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 0526654 commit 40addfd

1 file changed

Lines changed: 84 additions & 0 deletions

File tree

‎CLAUDE.md‎

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## What this is
6+
7+
A seven-phase app workflow plugin that ships to two runtimes (Claude Code and Codex) from one repository. Canonical workflow state lives in a registered per-project SQLite database exposed through two stdio MCP servers, both started from the same single-file runtime:
8+
9+
- `app-workflow` - 12 read-only tools (`serve --mode reader`)
10+
- `app-workflow-maintainer` - 13 registration/mutation tools (`serve --mode maintainer`)
11+
12+
The runtime is stdlib-only Python 3.10+; `git` must be on PATH for project registration. README.md is the authoritative spec for tool surfaces, limits, and phase semantics; contracts/ holds the DB schema and MCP tool contract.
13+
14+
## Commands
15+
16+
```bash
17+
# Full test suite (36 tests, stdlib unittest, ~10s)
18+
python3 -m unittest discover -s tests
19+
20+
# One file / one test
21+
python3 tests/test_app_workflow.py
22+
python3 tests/test_app_workflow.py StateDirEnvTests.test_state_dir_override_ignores_codex_home
23+
24+
# Run an MCP server by hand
25+
python3 scripts/app_workflow.py serve --mode reader # app-workflow
26+
python3 scripts/app_workflow.py serve --mode maintainer # app-workflow-maintainer
27+
28+
# Read-only workflow validation
29+
python3 scripts/app_workflow.py validate --project-ref <ref> --wave-id <id>
30+
python3 skills/app-analyze/scripts/validate_workflow.py --project-ref <ref> --wave-id <id>
31+
32+
# Codex-side installer (writes a managed [agents.*] block into $CODEX_HOME/config.toml)
33+
./install --codex-home /tmp/bears-app-workflow-codex --dry-run
34+
35+
# CD runner regression check (what the CD workflow runs)
36+
python3 -B .github/runner/test_graph_instruction_retirement.py --verbose
37+
```
38+
39+
Run tests with unittest, not pytest: `test_repository_limits_and_artifact_language` in tests/test_plugin_shape.py counts every working-tree file (gitignored ones included) against an 80-file / 1 MiB budget, and a stray `.pytest_cache/` directory is enough to fail it locally.
40+
41+
## Architecture
42+
43+
### Single-file runtime: scripts/app_workflow.py (~2.2k lines)
44+
45+
Layered top to bottom: validation/hashing/path helpers -> registry and project SQLite access -> mutation backends -> read/validation/migration backends -> MCP tool schemas and reader/maintainer dispatch -> JSON-RPC-over-stdio loop and CLI. The project DB schema is not embedded in the script: it is loaded at runtime from contracts/app-workflow-db-v1.sql. The MCP tool contract mirror is contracts/app-workflow-mcp-tools.v1.json.
46+
47+
### State model
48+
49+
- `registry.sqlite3` maps stable `project_ref` values to absolute git roots. It lives in `$BEARS_APP_WORKFLOW_STATE_DIR`, otherwise `$CODEX_HOME/state/bears-app-based-workflow/`.
50+
- Per-project state is `<project>/.bears/app-workflow.sqlite3`; it never stores the absolute project path. Markdown phase artifacts live under `waves/<wave_id>/` in the target project.
51+
- JSON workflow-state fallbacks are forbidden; `project_migrate_json` imports the two legacy JSON formats only into an empty database.
52+
53+
### Integrity invariants (do not weaken)
54+
55+
- Every mutation is CAS-guarded: unique `request_id` plus expected revision plus expected logical digest; batch graph/plan changes commit or roll back atomically. A `request_id` replay is idempotent only for an identical payload digest.
56+
- Logical digest = SHA-256 over sorted canonical rows, excluding `request_log`, `audit_attestations`, and the metadata revision.
57+
- `workflow_mark_audited` revalidates at the same revision inside its own transaction; any later mutation stales the attestation.
58+
- SQLite discipline: foreign keys ON, DELETE journal (WAL is rejected), FULL synchronous, 5s busy timeout.
59+
- Graph records are never physically deleted: lifecycle is active/retired with optional replacement refs, and the relation set is closed.
60+
- Response limits: pages default 50 / max 200, traversal depth default 4 / max 16, requests 1 MiB, responses 512 KiB.
61+
62+
### Dual-runtime packaging
63+
64+
| | Claude Code | Codex |
65+
|-------------|------------------------------------------------|----------------------------------------------------|
66+
| Manifest | .claude-plugin/plugin.json (+ marketplace.json) | .codex-plugin/plugin.json (+ .agents/plugins/marketplace.json) |
67+
| MCP wiring | claude/mcp.json via ${CLAUDE_PLUGIN_ROOT} | .mcp.json (cwd-relative) |
68+
| Roles | claude/agents/*.md (three L3 agents) | agents/*.toml (five profiles) installed by ./install |
69+
70+
skills/ (eight skills: one per phase plus subagents) is shared by both runtimes; skills/*/agents/openai.yaml files are Codex UI metadata only. The five Codex profiles: app-worker (no MCP), app-reviewer and app-analyst (read-only tool subsets), repo-orchestrator (both servers, owns a delegated repository lane), workflow-orchestrator (no MCP, opens lanes). claude/agents/*.md mirror the three L3 profiles with Claude tool names - keep the allowlists in sync; tests/test_plugin_shape.py and tests/test_claude_plugin_shape.py enforce both sides.
71+
72+
Ownership: the DIRECT primary (main session) or one persistent repo-orchestrator owns a wave and both servers; only the wave owner records mutations. Delegated orchestrator lanes are Codex-only; in Claude Code the main session is the DIRECT primary, one session per repository.
73+
74+
### Releases and CD
75+
76+
- The version (currently 0.6.0) appears in .codex-plugin/plugin.json, .claude-plugin/plugin.json, both marketplace.json files, and the dist/ filenames, and is asserted by tests - bump all of them together.
77+
- dist/ holds a committed, pre-built release bundle; a test verifies the archive SHA-256 against the .bundle.json manifest, so changing either means regenerating both. CD does not build dist/.
78+
- Pushing to main triggers .github/workflows/plugin-marketplace-cd.yml on a self-hosted runner: a recovery check, then a root-owned exact-SHA promotion gateway updates the Codex marketplace checkout and installs roles, writing receipts. Keep exact-SHA ancestry, monotonic SemVer, and the receipt/transaction invariants in .github/runner/bears_deploy/ intact.
79+
80+
## Repository rules (from AGENTS.md)
81+
82+
- All plugin instructions and documentation are English-only; README.md, CHANGELOG.md, THIRD_PARTY_NOTICES, and every skills/*/SKILL.md must be pure ASCII (test-enforced).
83+
- Budgets are test-enforced: at most 80 working-tree files, 1 MiB total, 30 KiB per skill directory.
84+
- Procedures belong in skills/, unique role behavior in agents/; workspace-level rules stay outside this repository.

0 commit comments

Comments
 (0)