Skip to content
Merged
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/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
name: Bug report 🐛
about: Report a defect in the factory line (pipeline, prompts, CI)
title: "[BUG] "
labels: bug
assignees: ""
---

## Summary

A clear, one-paragraph description of the bug.

## Where did it fail?

- **Mode:** full / express
- **Phase:** 0 / 1 / 2 / 3 / 4 / 5 / 6 / 7
- **Run ID:** `run-YYYYMMDD-HHMMSS` (from the factory banner)
- **Checkpoint choice (if relevant):** approve / modify / skip-all / abort

## Steps to reproduce

1. Run: `dark factory "..."` (paste the exact goal)
2. Approve checkpoints: (list what you clicked)
3. Observe: (what happened)

## Expected behavior

What should have happened instead?

## Actual behavior

What happened? Include the most relevant output.

```text
(paste output here)
```

## Sealed-envelope integrity check (required)

- [ ] The Lead Engineer never saw sealed test code
- [ ] The user was never shown sealed test code before validation
- [ ] Hardening included only failure messages (no test source)

If any of the above are false, treat this as a potential security issue and also follow **SECURITY.md**.

## Environment

- OS:
- GitHub Copilot CLI version:
- Dark Factory version: 0.1.0

## Additional context

- Relevant `config.yml` changes (if any):
- Repo stack (Node/Python/Go/etc):
39 changes: 39 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Feature request 💡
about: Propose an improvement to the factory line
title: "[FEAT] "
labels: enhancement
assignees: ""
---

## Problem

What problem are you trying to solve? Who is affected?

## Proposal

Describe the change you want. Include a concrete example of the desired behavior.

## Acceptance criteria

- [ ] Criterion 1
- [ ] Criterion 2

## Pipeline impact

Which part of the line changes?

- [ ] Orchestrator (`SKILL.md`)
- [ ] Agent prompt (`agents/*.md`)
- [ ] Templates (`templates/*.md`)
- [ ] Protocols (`protocols/*.md`)
- [ ] Config (`config.yml`)
- [ ] CI (`.github/workflows/validate.yml`)

## Safety / sealed-envelope considerations

Explain why this feature does not compromise sealed-envelope isolation.

## Alternatives considered

List alternatives and why you did not choose them.
41 changes: 41 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## Summary

What does this PR change? Link issues.

Fixes #

## Type

- [ ] Bug fix
- [ ] New feature
- [ ] Documentation
- [ ] CI / Infra

## Factory impact

- Affects phases: 0 / 1 / 2 / 3 / 4 / 5 / 6 / 7
- Agent prompts touched (if any):

## QA checklist (from docs/TESTING.md)

- [ ] 🏭 Factory banner displays on start (run ID, mode, agent lineup)
- [ ] 📋 PRD.md produced with user stories and acceptance criteria
- [ ] 🏗️ ARCH.md produced with components, file structure, tech choices
- [ ] 🔒 Sealed tests generated from PRD only (never from code/arch)
- [ ] 🔒 SHA-256 hash of sealed directory displayed at Phase 2
- [ ] 👩‍💻 Engineer never accesses `.factory/sealed/` during build
- [ ] ✅ Both test suites run in Phase 4
- [ ] 📊 GAP-REPORT.md produced with gap score
- [ ] 🔧 Hardening sends failure messages only (no test code)
- [ ] 🔧 Hardening caps at configured max cycles, then escalates
- [ ] 📋 Checkpoints use `ask_user` with exactly 4 choices
- [ ] ⏭️ Skip-all still shows final delivery checkpoint
- [ ] 💾 state.json written on every phase transition
- [ ] 🔄 Resume works from state.json
- [ ] 🛑 Abort cleans up worktree and branch
- [ ] ⚡ Express mode skips PRD/arch, one checkpoint at delivery
- [ ] 🗄️ SQL tables track runs and phase results

## Notes for reviewers

Anything risky, subtle, or worth double-checking?
55 changes: 33 additions & 22 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,39 @@
# Copilot Instructions — Dark Factory

This repository contains the **Dark Factory** Copilot CLI skill — an agentic build system that orchestrates specialist AI agents through a sealed-envelope testing pipeline.
This repository contains **Dark Factory**, a GitHub Copilot CLI skill that orchestrates an agent pipeline with **sealed-envelope testing**.

## Key Concepts
## File map

- **Sealed-envelope testing**: QA agent generates tests from the PRD *before* code is written. Building agents never see these tests. The gap between builder tests and sealed tests measures build quality.
- **Checkpoint-gated pipeline**: Each phase runs autonomously, pausing for human approval at phase boundaries.
- **Git worktree isolation**: All building happens in an isolated worktree. Nothing touches the user's working directory until they approve.
| File/Dir | Purpose |
|---|---|
| `SKILL.md` | Factory Manager orchestrator prompt (the brain) |
| `agents/*.md` | Specialist agent prompts |
| `templates/*.md` | Artifact output formats |
| `protocols/*.md` | Protocol invariants (sealed envelope, checkpoints) |
| `config.yml` | Tunables (models, thresholds, timeouts) |
| `catalog.yml` | Skill metadata + file references |
| `docs/TESTING.md` | Playbooks + QA checklist |
| `docs/ADR.md` | Why these decisions |

## File Map
## Non-negotiables

| File | Purpose |
|------|---------|
| `SKILL.md` | Factory Manager orchestrator prompt (the brain) |
| `catalog.yml` | Skill metadata for Copilot CLI registration |
| `config.yml` | Tunable settings (models, thresholds, checkpoints) |
| `agents/*.md` | Specialist agent prompts (product, arch, qa, eng) |
| `templates/*.md` | Structured output templates for agent artifacts |
| `protocols/*.md` | Reusable protocol definitions |

## Rules

1. **Never modify sealed test isolation** — the sealed directory must remain invisible to building agents
2. **Agents are stateless** — each `task()` call gets a clean context. Pass EXACTLY what the agent needs via the handoff manifest.
3. **State must survive crashes** — every phase transition writes to `state.json`
4. **Express mode must work** — quick tasks should complete in ~60 seconds with one checkpoint
5. **Keep agent prompts under 200 lines** — focused, not bloated
1. **Sealed envelope is sacred.** The Lead Engineer must never see sealed tests; the QA Sealed agent must never see code.
2. **Config is the source of truth.** Never hardcode model names or tunables inside prompts.
3. **Agent prompts <= 200 lines.** If a prompt grows, split responsibilities instead.
4. **Just a skill.** Do not add runtime code, package managers, telemetry, dashboards, or plugin systems.
5. **Worktree isolation.** All build work happens under `.factory/` until delivery approval.

## Prohibited actions

- Exposing sealed test contents to the user before Phase 4.
- Passing sealed test source code into any builder/hardening prompt.
- Editing user files outside the factory worktree.

## PR requirements

Before opening a PR:

- Run Playbook 1 (Full) and Playbook 2 (Express) from `docs/TESTING.md`.
- Ensure `catalog.yml` references are valid.
- Ensure YAML parses (`config.yml`, `catalog.yml`).
- Ensure CI validate workflow passes.
129 changes: 129 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: Validate Dark Factory

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
validate:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install YAML parser
run: |
python -m pip install --upgrade pip
python -m pip install pyyaml

- name: Validate YAML syntax
run: |
python - <<'PY'
import yaml
for path in ("config.yml", "catalog.yml"):
with open(path, "r", encoding="utf-8") as f:
yaml.safe_load(f)
print("✅ YAML valid")
PY

- name: Verify catalog references exist
run: |
python - <<'PY'
import pathlib, sys
import yaml

root = pathlib.Path(".")
catalog = yaml.safe_load(root.joinpath("catalog.yml").read_text(encoding="utf-8"))
links = catalog.get("links", {}) or {}

referenced = []
if links.get("skill_file"):
referenced.append(links["skill_file"])
referenced.extend(list(links.get("agents", []) or []))

missing = [p for p in referenced if not root.joinpath(p).is_file()]
if missing:
print("::error::catalog.yml references missing files")
for p in missing:
print(f"- {p}")
sys.exit(1)

print("✅ Catalog references valid")
PY

- name: Check agent line counts (<= 200)
run: |
for file in agents/*.md; do
lines=$(wc -l < "$file")
if [ "$lines" -gt 200 ]; then
echo "::error file=$file::Agent prompt exceeds 200 lines ($lines lines)"
exit 1
fi
done
echo "✅ Agent prompts within limit"

- name: Verify SKILL.md frontmatter
run: |
python - <<'PY'
import pathlib, sys

lines = pathlib.Path("SKILL.md").read_text(encoding="utf-8").splitlines()
if not lines or lines[0].strip() != "---":
print("::error file=SKILL.md::Missing frontmatter start (---)")
sys.exit(1)

try:
end = lines[1:200].index("---") + 1
except ValueError:
print("::error file=SKILL.md::Missing frontmatter end (---)")
sys.exit(1)

if end < 3:
print("::error file=SKILL.md::Frontmatter too short")
sys.exit(1)

print("✅ Frontmatter present")
PY

- name: Set up Node (markdown lint)
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install markdownlint
run: npm install -g markdownlint-cli2

- name: Markdown lint
run: |
cat > .markdownlint-cli2.jsonc <<'JSON'
{
"config": {
"default": true,
"MD013": false,
"MD022": false,
"MD024": false,
"MD025": false,
"MD029": false,
"MD031": false,
"MD032": false,
"MD033": false,
"MD036": false,
"MD040": false,
"MD041": false,
"MD056": false,
"MD058": false,
"MD060": false
},
"globs": ["**/*.md"],
"ignores": ["**/.factory/**", "**/node_modules/**"]
}
JSON
markdownlint-cli2
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Dark Factory runtime artifacts
.factory/

# Environment
.env
.env.local

# Python
__pycache__/
*.pyc
*.pyo
*.pyd
.Python
env/
venv/

# Node
node_modules/
npm-debug.log
yarn-error.log

# OS / IDE
.DS_Store
Thumbs.db
.vscode/
.idea/
*.swp
*.swo
14 changes: 8 additions & 6 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ This file tells any AI agent how to work effectively on the Dark Factory codebas

## Architecture

Dark Factory is a **Copilot CLI skill** that orchestrates 5 specialist agents through a checkpoint-gated pipeline with sealed-envelope testing.
Dark Factory is a **Copilot CLI skill** that orchestrates 6 specialist agents through a checkpoint-gated pipeline with sealed-envelope testing.

```
SKILL.md (Factory Manager / Orchestrator)
├── agents/product-mgr.md → Phase 1: writes PRD.md
├── agents/architect.md → Phase 2b: writes ARCH.md
├── agents/qa-sealed.md → Phase 2a: writes sealed tests (parallel with arch)
├── agents/lead-eng.md → Phase 3: writes code + open tests
└── agents/qa-validator.md → Phase 4: runs sealed tests, gap analysis
├── agents/product-mgr.md → Phase 1: writes PRD.md
├── agents/architect.md → Phase 2b: writes ARCH.md
├── agents/qa-sealed.md → Phase 2a: writes sealed tests (parallel with arch)
├── agents/lead-eng.md → Phase 3: writes code + open tests
├── agents/qa-validator.md → Phase 4: runs sealed tests, gap analysis
└── agents/outcome-evaluator.md → Phase 7: evaluates post-ship outcomes
```

Each agent is called via `task()` with explicit inputs. Agents are stateless — they receive ONLY what the handoff manifest specifies.
Expand All @@ -27,6 +28,7 @@ Each agent is called via `task()` with explicit inputs. Agents are stateless —
|----------|-------|-------------|
| `SKILL.md` | Orchestrator logic | Most critical file. Changes affect all phases. |
| `agents/*.md` | Individual agent prompts | Change one agent at a time. Test with a factory run. |
| `agents/outcome-evaluator.md` | Post-ship analysis prompt | Keep KPI math aligned with PRD template + config `outcome_evaluation` settings. |
| `config.yml` | User-tunable settings | Never hardcode values that belong here. |
| `templates/*.md` | Output format templates | Keep in sync with agent prompts that reference them. |
| `protocols/*.md` | Reusable protocol defs | Referenced by SKILL.md and agent prompts. |
Expand Down
Loading