-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
180 lines (139 loc) · 6.71 KB
/
Copy pathMakefile
File metadata and controls
180 lines (139 loc) · 6.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# --- AUTOMATIC CONFIGURATION ---
# Detects '26.4.0' from 'feature/26.4.0/QWS-0301'
CURRENT_BRANCH := $(shell git symbolic-ref --short HEAD)
REL_VER := $(shell echo $(CURRENT_BRANCH) | cut -d'/' -f2)
RELEASE_BRANCH = release/$(REL_VER)
MASTER_BRANCH = main
.PHONY: to-release to-main check-clean done-with-feature test test-unit test-integration test-all lint typecheck check verify check-story show-discovery commit-impl commit-test commit-push-qa commit-close-story prime-agent prime-lint-mechanic feature-branch arm-verify-gate arm-qa-gate arm-close-epic-gate neo4j-up neo4j-down neo4j-restart neo4j-logs neo4j-status seed
COMPOSE_FILE := infra/docker-compose.neo4j.yml
NEO4J_SERVICE := qws-neo4j
# --- QUALITY ---
test:
source .venv/bin/activate && pytest tests/unit/ -v --tb=long
test-unit: test
test-integration:
source .venv/bin/activate && pytest tests/integration/ -v --tb=long
test-all: test test-integration
lint:
source .venv/bin/activate && ruff check . --fix && ruff format
typecheck:
source .venv/bin/activate && mypy --strict .
check: lint typecheck test
verify: lint typecheck test
# --- NEO4J LIFECYCLE ---
neo4j-up:
docker compose -f $(COMPOSE_FILE) up -d --wait $(NEO4J_SERVICE)
neo4j-down:
docker compose -f $(COMPOSE_FILE) down
neo4j-restart: neo4j-down neo4j-up
neo4j-logs:
docker compose -f $(COMPOSE_FILE) logs --tail=200 $(NEO4J_SERVICE)
neo4j-status:
docker compose -f $(COMPOSE_FILE) ps $(NEO4J_SERVICE)
seed: neo4j-up
source .venv/bin/activate && qw seed --demo && qw seed --targets
# Show how many discovery MCP calls the current/last agent run consumed
show-discovery:
@echo "Discovery budget (cap=10):"
@cat /tmp/agent-discovery-tracker/discovery_total_count 2>/dev/null | xargs -I{} echo " used: {}/10" || echo " no active run (counter not found)"
# For use by lead-engineer during story implementation: typecheck + tests, output teed.
# Read results from /tmp/check-story-output.txt — do NOT re-run to filter output.
check-story:
source .venv/bin/activate && \
mypy --strict data/ research/ strategies/ execution/ 2>&1 | tee /tmp/check-story-output.txt | tail -5; \
pytest tests/unit/ -v --tb=short 2>&1 | tee -a /tmp/check-story-output.txt | tail -5
# --- GIT WORKFLOW ---
# Internal helper to check for uncommitted changes
check-clean:
@if [ -n "$$(git status --porcelain)" ]; then \
echo "ERROR: Your working directory is dirty. Commit or stash changes."; \
exit 1; \
fi
# 1. Sync feature, merge to release, and return
to-release: check-clean
@echo "Syncing $(CURRENT_BRANCH) with remote..."
git push origin $(CURRENT_BRANCH)
@echo "Merging into $(RELEASE_BRANCH)..."
git checkout $(RELEASE_BRANCH)
git pull origin $(RELEASE_BRANCH)
git merge $(CURRENT_BRANCH)
git push origin $(RELEASE_BRANCH)
@echo "Done! Returning to $(CURRENT_BRANCH)..."
git checkout $(CURRENT_BRANCH)
# 2. Merge Release into Main
to-main: check-clean
@echo "Finalizing Release $(REL_VER) into Main..."
git checkout $(MASTER_BRANCH)
git pull origin $(MASTER_BRANCH)
git merge $(RELEASE_BRANCH)
git push origin $(MASTER_BRANCH)
git checkout $(RELEASE_BRANCH)
# 3b. Create feature branch from release branch
# Usage: make feature-branch STORY=QWS-0804
feature-branch:
@[ -n "$(STORY)" ] || (echo "ERROR: STORY required. Usage: make feature-branch STORY=QWS-0804"; exit 1)
git checkout $(RELEASE_BRANCH)
git pull origin $(RELEASE_BRANCH)
git checkout -b feature/$(REL_VER)/$(STORY)
# 3c. Prime agent guards before spawning lead-engineer (arms sentinel + trackers from call #1)
# Usage: make prime-agent
prime-agent:
@mkdir -p /tmp/agent-read-tracker /tmp/agent-discovery-tracker /tmp/circuit-breaker
@echo "implement-story" > /tmp/agent-current-command.txt
@rm -f /tmp/agent-step8-committed.txt /tmp/agent-*-done.txt /tmp/agent-step0-complete.txt
@rm -f /tmp/agent-trace-lead-engineer-*.jsonl 2>/dev/null || true
@echo "Agent guards primed. Safe to spawn lead-engineer."
# Phase gate arm targets — called at terminal step before report output
# Each writes a sentinel that blocks ALL subsequent tool calls via agent-phase-gate.sh
arm-verify-gate:
@touch /tmp/agent-verify-story-done.txt
@echo "Verify-story phase gate armed. Report and stop."
arm-qa-gate:
@touch /tmp/agent-qa-epic-done.txt
@echo "QA-epic phase gate armed. Report and stop."
arm-close-epic-gate:
@touch /tmp/agent-close-epic-done.txt
@echo "Close-epic phase gate armed. Report and stop."
prime-lint-mechanic:
@mkdir -p /tmp/agent-read-tracker /tmp/agent-discovery-tracker /tmp/circuit-breaker
@echo "lint-mechanic" > /tmp/agent-current-command.txt
@echo "Lint-mechanic guards primed."
# 4. Commit story status update + arm agent phase gate (atomic — sentinel cannot be skipped)
# Usage: make commit-story-status STORY=QWS-0801
# make commit-story-status STORY=QWS-0801 MSG="custom commit message"
commit-story-status:
@[ -n "$(STORY)" ] || (echo "ERROR: STORY required. Usage: make commit-story-status STORY=QWS-0801"; exit 1)
@echo "done" > /tmp/agent-step8-committed.txt
git add -u
git commit -m "$(if $(MSG),$(MSG),status($(STORY)): READY → TESTING)" || echo "WARN: nothing to commit (already committed?)"
@echo "Phase gate armed. Agent hard stop active."
# 4b. Commit implementation (agent stages files first with git add <files>)
# Usage: make commit-impl STORY=QWS-0801 MSG="add signal normalization"
commit-impl:
@[ -n "$(STORY)" ] || (echo "ERROR: STORY required. Usage: make commit-impl STORY=QWS-0801 MSG='summary'"; exit 1)
git commit -m "$(if $(MSG),$(MSG),impl($(STORY)): implementation)"
# 4c. Commit verification sweep (agent stages files first with git add <files>)
# Usage: make commit-test STORY=QWS-0801
commit-test:
@[ -n "$(STORY)" ] || (echo "ERROR: STORY required. Usage: make commit-test STORY=QWS-0801"; exit 1)
git commit -m "$(if $(MSG),$(MSG),test($(STORY)): verification sweep — fixtures, demo seed, DoD)"
# 4d. Commit post-epic QA fixes + push to release branch (agent stages files first)
# Usage: make commit-push-qa EPIC=6
commit-push-qa:
@[ -n "$(EPIC)" ] || (echo "ERROR: EPIC required. Usage: make commit-push-qa EPIC=6"; exit 1)
git commit -m "$(if $(MSG),$(MSG),qa(epic-$(EPIC)): post-epic QA fixes — fixtures/seed)"
git push origin $(RELEASE_BRANCH)
# 4e. Commit story closure
# Usage: make commit-close-story STORY=QWS-0801
commit-close-story:
@[ -n "$(STORY)" ] || (echo "ERROR: STORY required. Usage: make commit-close-story STORY=QWS-0801"; exit 1)
git add -u
git commit -m "$(if $(MSG),$(MSG),close($(STORY)): story closed)"
# 5. Optional: Delete feature branch after successful merge
done-with-feature:
@read -p "Delete branch $(CURRENT_BRANCH)? (y/n): " confirm; \
if [ "$$confirm" = "y" ]; then \
git checkout $(RELEASE_BRANCH); \
git branch -d $(CURRENT_BRANCH); \
git push origin --delete $(CURRENT_BRANCH); \
fi