Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copilot Instructions — constraint-workshop

## Repo identity

This repository holds small, deterministic control primitives.
Every primitive is a single file + a test file. No frameworks. No runtime dependencies. No hidden state.

## Invariant files — DO NOT MODIFY

The following files are **frozen**. Never edit, refactor, rename, or delete them:

- `authority_gate.py`
- `stop_machine.py`
- `invariant_litmus.py`
- `commit_gate/` (entire directory)

If any suggestion would touch these paths, stop and say so instead of making the change.

## Bounded intake rule

**No implementation code may be generated until all of the following are true:**

1. A schema (data shape + field constraints) for the new primitive exists in a `.py` or `.md` file.
2. Golden tests exist that assert specific, pinned expected values (not just "it doesn't crash").
3. All golden tests are collected by `pytest` and initially fail with `NotImplementedError` or an import error — proving the tests are real and the implementation does not yet exist.

Refusing to proceed past this gate is correct behaviour, not a bug.

## Test-first order

When asked to build a new primitive, always do work in this order:

1. **Schema** — define data types, enumerations, and field constraints only. No logic.
2. **Golden tests** — write `pytest` tests that pin exact expected outputs for known inputs. Tests must fail until step 3.
3. **Implementation** — only after the user confirms the tests fail as expected.

Do not collapse these steps. Do not combine schema + implementation in one pass.

## Style rules

- Stdlib only. Do not add third-party imports unless the user explicitly approves.
- No global mutable state.
- No `random`, `uuid`, `time.time()`, `datetime.now()`, or `os.getpid()` in any primitive.
- All public functions must be pure (same input → same output, always).
- Test files are named `test_<module>.py` and live in the repo root (or `<subpackage>/tests/`).

## CI contract

CI runs `pytest -q` across Python 3.10, 3.11, 3.12.
A PR is not ready to merge until `pytest -q` passes with zero failures.

## Out of scope

Do not generate: orchestration layers, policy engines, selection logic, ML models, HTTP clients, database connections, or logging frameworks.
`/prometheus` is the observability-only sub-package (`prometheus/src/prometheus/`). It aggregates diagnostic events and reports health posture. It must not be imported by any gate, primitive, or pipeline code.
93 changes: 93 additions & 0 deletions .github/prompts/commitboundary_spec_intake.prompt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# CommitBoundary Spec Intake

Use this prompt file to introduce a new primitive or spec change in a bounded, test-first way.
Run it from VS Code: **Command Palette → "Chat: Run Prompt"**, then select this file.

---

## Step 0 — Gate check

Before generating anything, confirm:

- [ ] The request does **not** touch `authority_gate.py`, `stop_machine.py`, `invariant_litmus.py`, or `commit_gate/`.

If it does, **stop here** and tell the user which protected file would be affected. Do not proceed.

---

## Step 1 — Schema only

Generate a schema file named `<primitive_name>_schema.py` containing:

- Enumerations or `TypedDict`/`NamedTuple` definitions for every data type the primitive will use.
- Field-level constraints as inline docstrings (e.g., "must be non-negative", "immutable after construction").
- A `SCHEMA_VERSION` string constant (start at `"0.1"` for new primitives; increment the minor version when updating an existing schema).
- **No logic. No methods beyond `__repr__`. No `__init__` that does computation.**

Do **not** generate an implementation file yet.

---

## Step 2 — Golden tests (fail-first)

Generate a test file named `test_<primitive_name>.py` containing:

- At least three test functions that assert **exact, pinned expected values** for known inputs.
- One test that asserts a `TypeError` or `ValueError` is raised for invalid inputs.
- One test that asserts the function/class raises `NotImplementedError` when called (proving the stub is not yet implemented).
- Import the module as if it exists: `from <primitive_name> import ...`

**All tests must fail** until the implementation exists. Confirm this by noting at the bottom of the file:

```python
# FAIL-FIRST: these tests must fail until the implementation is complete.
```

Do **not** generate an implementation file yet.

---

## Step 3 — User confirmation gate

At this point, output a summary checklist:

```
Schema file: <primitive_name>_schema.py ✓ generated
Golden tests: test_<primitive_name>.py ✓ generated (expect failures)

Next step: run `pytest test_<primitive_name>.py -v` and confirm all tests fail.
Reply "tests fail as expected" to unlock Step 4.
```

**Do not proceed to Step 4 without the user's confirmation.**

---

## Step 4 — Implementation

Only after the user confirms the tests fail:

1. Generate `<primitive_name>.py` with the minimal implementation that makes all golden tests pass.
2. Do not add features not covered by the golden tests.
3. Stdlib only — no third-party imports unless the user explicitly approved them in this session.
4. After generating, output the command to verify:

```
pytest test_<primitive_name>.py -v
```

---

## Step 5 — Final checklist

After implementation:

```
Schema: <primitive_name>_schema.py ✓
Golden tests: test_<primitive_name>.py ✓ (all passing)
Implementation: <primitive_name>.py ✓
CI command: pytest -q (run to confirm nothing regressed)
Protected files: authority_gate.py / stop_machine.py / invariant_litmus.py / commit_gate/ ✓ untouched
```

Do not open a PR until this checklist is complete.