docs(.squad): Phase 0 closure — merge Leela's CI architecture decision, update agent history files

- Merged leela-ci-architecture-decision.md into decisions.md - Added comprehensive CI analysis interface architecture (Copilot CLI + GitHub Models fallback) - Documented pipeline contracts, reviewer gate, MCP strategy, and reskill interface - Notified all agents: Phase 0 complete, architecture published, COPILOT_GH_TOKEN secret configured - Updated agent history files with Phase 0 completion status Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

jmservera committed May 18, 2026 at 10:32 UTC 5c7550fdfddd743891bc7695850758e1290bfac5
10 files changed +254
.gitmodules new
+3
@@ -0,0 +1,3 @@
1 +[submodule "themes/PaperMod"]
2 + path = themes/PaperMod
3 + url = https://github.com/adityatelange/hugo-PaperMod.git
.squad/agents/amy/history.md
+2
@@ -10,6 +10,8 @@
10
11 **2026-05-18:** PRD now available at `docs/PRD.md`. Review for design requirements and site generation framework (Hugo recommended, Astro alternative).
12
13 +**2026-05-18T10:27:35Z:** Phase 0 is complete. Architecture decision published in `.squad/decisions.md`. `COPILOT_GH_TOKEN` secret configured. Ready for Phase 1 work (site foundation and crawler implementation).
14 +
15 ## Learnings
16
17 _No learnings recorded yet._
.squad/agents/bender/history.md
+2
@@ -10,6 +10,8 @@
10
11 **2026-05-18:** PRD now available at `docs/PRD.md`. Review for requirements and constraints on crawler implementation.
12
13 +**2026-05-18T10:27:35Z:** Phase 0 is complete. Architecture decision published in `.squad/decisions.md`. `COPILOT_GH_TOKEN` secret configured. Phase 1 crawler work can proceed with finalized CI analysis interface and fallback strategies.
14 +
15 ## Learnings
16
17 - **2026-05-18T10:06:38.734+02:00:** GitHub Actions can run the standalone `copilot` CLI (`@github/copilot`) in programmatic mode with `copilot -p ...`. The safest documented CI auth flow is a fine-grained PAT with the **Copilot Requests** account permission passed as `COPILOT_GITHUB_TOKEN`; `gh auth token` only exposes an existing `gh` token and `gh-copilot` is deprecated in favor of the standalone CLI. GitHub Models (`models: read`) is the clean fallback if direct Copilot CLI automation proves brittle.
.squad/agents/farnsworth/history.md
+2
@@ -10,6 +10,8 @@
10
11 **2026-05-18:** PRD now available at `docs/PRD.md`. Review for analysis requirements and success criteria.
12
13 +**2026-05-18T10:27:35Z:** Phase 0 is complete. Architecture decision published in `.squad/decisions.md`. CI analysis pipeline uses Copilot CLI (primary) with GitHub Models fallback. Reviewer gate requires quality_score ≥ 60. Phase 2 analyzer work is unblocked.
14 +
15 ## Learnings
16
17 _No learnings recorded yet._
.squad/agents/fry/history.md
+2
@@ -10,6 +10,8 @@
10
11 **2026-05-18:** PRD now available at `docs/PRD.md`. Review for testing strategy and pipeline validation requirements.
12
13 +**2026-05-18T10:27:35Z:** Phase 0 is complete. Architecture decision published in `.squad/decisions.md`. CI analysis interface, pipeline contracts, reviewer gate, and reskill cycle are all finalized. Ready for Phase 1 validation planning.
14 +
15 ## Learnings
16
17 _No learnings recorded yet._
.squad/agents/leela/history.md
+23
@@ -42,3 +42,26 @@
42 - **MCP crawling:** Multi-site crawling authorized; remote calls require allowlist in GitHub Copilot agent settings.
43 - **Phase 0 gating:** OQ1/OQ3 investigation issues must close before Phase 2 analyzer work begins.
44 - **Next:** Issue creation from scripts/create-issues.sh is ready for execution.
45 +
46 +### 2026-05-18T10:25:12.565+02:00 — CI Analysis Interface & Fallback Architecture (Issue #2)
47 +
48 +- **Architecture decision published:** `.squad/decisions/inbox/leela-ci-architecture-decision.md`
49 +- **Primary path:** Standalone `copilot` CLI with fine-grained PAT (`COPILOT_GH_TOKEN` secret → `COPILOT_GITHUB_TOKEN` env var). Programmatic mode with `--no-ask-user`, explicit `--allow-tool` flags.
50 +- **Fallback path:** GitHub Models API (`models.github.ai`) with built-in `GITHUB_TOKEN` and `permissions: models: read`. Triggered on CLI auth failure, quota exhaustion, or repeated errors.
51 +- **Pipeline contracts formalized:**
52 + - Crawl → Analyze: `data/raw/YYYY-WNN.json` (repo objects array)
53 + - Analyze → Generate: `data/analyzed/YYYY-WNN-summary.md` (Markdown + YAML frontmatter with `quality_score`)
54 + - Generate → Deploy: `public/` (Hugo build output)
55 +- **Reviewer gate:** quality_score ≥ 60, three required sections (Signal/Noise/Gaps), word count ≥ 200. Blocks publish on failure.
56 +- **Token strategy:** Fine-grained PAT with Account → Copilot Requests permission. Classic PATs not supported. Future spike: `GITHUB_TOKEN` + `copilot-requests: write`.
57 +- **MCP strategy:** Allowlist-gated remote calls, tool definitions in `.github/copilot/mcp.json`, crawl-stage only for external HTTP.
58 +- **Nap & reskill interface:** Every 5th run, Copilot CLI reads squad state and writes improvement recommendations to `.squad/reskill/YYYY-WNN.md`.
59 +- **Resolves:** OQ1 and OQ3 from PRD. Unblocks Phase 2 analyzer work.
60 +
61 +### 2026-05-18T10:27:35Z — Phase 0 Completion (Scribe)
62 +
63 +- **Status:** Phase 0 is complete. Architecture decision merged into `.squad/decisions.md`.
64 +- **Secret configured:** `COPILOT_GH_TOKEN` repo secret established (coordinator action).
65 +- **Issues closed:** #1 (completed by Bender) and #2 (Leela architecture).
66 +- **Team notification:** All agents notified that Phase 0 is complete and architecture is published.
67 +- **Next phase:** Phase 1 (crawlers and generators) can proceed independently. Phase 2 (analyzer) is unblocked.
.squad/agents/ralph/history.md
+2
@@ -11,6 +11,8 @@ Agent Ralph initialized and ready for work.
11
12 📌 Team initialized on 2026-05-18
13
14 +📌 **2026-05-18T10:27:35Z:** Phase 0 is complete. Architecture decision published. All agents notified and ready for Phase 1 work.
15 +
16 ## Learnings
17
18 Initial setup complete.
.squad/agents/scribe/history.md
+2
@@ -11,6 +11,8 @@ Agent Scribe initialized and ready for work.
11
12 📌 Team initialized on 2026-05-18
13
14 +📌 **2026-05-18T10:27:35Z:** Phase 0 closure complete. Merged Leela's CI architecture decision, recorded orchestration/session logs, updated all agent history files, staged for commit.
15 +
16 ## Learnings
17
18 Initial setup complete.
.squad/decisions.md
+215
@@ -83,6 +83,221 @@
83
84 **Impact:** Affects crawler extensibility design (HackerNews, Reddit, etc.) and GitHub Actions Copilot token model.
85
86 +## Architecture Decision: CI Analysis Interface & Fallback Architecture
87 +
88 +**Date:** 2026-05-18T10:25:12.565+02:00
89 +**Author:** Leela (Lead/Architect)
90 +**Status:** Approved
91 +**Issue:** #2 — Decide CI analysis interface and fallback architecture
92 +**Depends on:** #1 (Copilot CLI investigation — completed by Bender)
93 +
94 +### Context
95 +
96 +SquadScope's pipeline requires AI-powered analysis of crawled GitHub data inside GitHub Actions. Bender's investigation (docs/investigation-copilot-cli.md) confirmed that the standalone `copilot` CLI can run in CI with a fine-grained PAT, and identified GitHub Models API as a credible fallback. This decision formalizes the approved architecture.
97 +
98 +### Decision 1: Primary Analysis Path — Standalone Copilot CLI
99 +
100 +**Approved.** The primary CI analysis engine is the standalone `copilot` CLI (`@github/copilot`).
101 +
102 +**Rationale:**
103 +- Officially documented by GitHub for Actions automation
104 +- Real-world precedent (microsoft/BCApps)
105 +- Repo-aware agent behavior: can read/write files, use tools (grep, glob, read, write)
106 +- Supports structured output (`--output-format=json`) and transcript export (`--share=PATH`)
107 +- Programmatic mode (`-p`, `--no-ask-user`) is CI-safe
108 +
109 +**Invocation Contract:**
110 +
111 +```bash
112 +copilot -p "<prompt>" \
113 + -s \
114 + --no-ask-user \
115 + --allow-tool=read \
116 + --allow-tool=write \
117 + --allow-tool=glob \
118 + --allow-tool=grep \
119 + --output-format=json \
120 + --share=./copilot-session.md
121 +```
122 +
123 +**Token Strategy:**
124 +
125 +| Item | Value |
126 +|------|-------|
127 +| Secret name | `COPILOT_GH_TOKEN` |
128 +| Token type | Fine-grained PAT (`github_pat_...`) |
129 +| Permission | Account → Copilot Requests |
130 +| Env variable | `COPILOT_GITHUB_TOKEN` |
131 +| Resource owner | Personal account (jmservera) |
132 +| Classic PAT | **Not supported** — do not use `ghp_` tokens |
133 +
134 +Wire in workflow:
135 +```yaml
136 +env:
137 + COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GH_TOKEN }}
138 +```
139 +
140 +### Decision 2: Fallback Path — GitHub Models API
141 +
142 +**Approved.** If Copilot CLI is unavailable, rate-limited, or proves too brittle in CI, the fallback is the GitHub Models API.
143 +
144 +**Rationale:**
145 +- Works with built-in `GITHUB_TOKEN` (no PAT needed)
146 +- Simple REST interface, easy to test and mock
147 +- Supports structured JSON responses
148 +- Less agentic, but sufficient for summarization tasks
149 +
150 +**Invocation Contract:**
151 +
152 +```yaml
153 +permissions:
154 + models: read
155 +
156 +steps:
157 + - name: Analyze via GitHub Models
158 + env:
159 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
160 + run: |
161 + curl "https://models.github.ai/inference/chat/completions" \
162 + -H "Content-Type: application/json" \
163 + -H "Authorization: Bearer $GITHUB_TOKEN" \
164 + -d @data/prompts/analyze-week.json
165 +```
166 +
167 +**Trigger conditions for fallback:**
168 +- Copilot CLI auth failure (token expired, permission revoked)
169 +- Copilot CLI rate-limit / quota exhaustion
170 +- Copilot CLI install failure (npm registry issue, Node version mismatch)
171 +- Repeated non-deterministic failures (3+ retries fail)
172 +
173 +### Decision 3: Pipeline Stage Contracts
174 +
175 +**Stage boundaries and data flow:**
176 +
177 +```
178 +┌─────────┐ JSON ┌──────────┐ Markdown ┌──────────┐ HTML ┌────────┐
179 +│ Crawl │ ──────────► │ Analyze │ ───────────► │ Generate │ ────────► │ Deploy │
180 +└─────────┘ data/raw/ └──────────┘ data/analyzed └──────────┘ public/ └────────┘
181 +```
182 +
183 +**Crawl → Analyze:**
184 +
185 +| Property | Specification |
186 +|----------|---------------|
187 +| Location | `data/raw/` |
188 +| Format | JSON (one file per crawl run) |
189 +| Naming | `YYYY-WNN.json` (e.g., `2026-W21.json`) |
190 +| Schema | Array of repo objects: `{name, url, description, stars, stars_gained, language, topics, created_at}` |
191 +| Contract | Analyzer MUST NOT modify files in `data/raw/` |
192 +
193 +**Analyze → Generate:**
194 +
195 +| Property | Specification |
196 +|----------|---------------|
197 +| Location | `data/analyzed/` |
198 +| Format | Markdown with YAML frontmatter |
199 +| Naming | `YYYY-WNN-summary.md` |
200 +| Frontmatter | `title`, `date`, `week`, `year`, `categories`, `quality_score` |
201 +| Sections | Signal (important), Noise (overhyped), Gaps (missing from conversation) |
202 +| Contract | Must include `quality_score` (0-100) for reviewer gate |
203 +
204 +**Generate → Deploy:**
205 +
206 +| Property | Specification |
207 +|----------|---------------|
208 +| Location | `public/` (Hugo build output) |
209 +| Format | Static HTML/CSS/JS |
210 +| Contract | Hugo builds from `content/` which is populated from `data/analyzed/` |
211 +
212 +### Decision 4: Reviewer Gate
213 +
214 +Analysis output in `data/analyzed/` MUST pass a quality check before the Generate stage runs.
215 +
216 +**Gate criteria:**
217 +- `quality_score` in frontmatter is ≥ 60
218 +- All three required sections present (Signal, Noise, Gaps)
219 +- Word count ≥ 200 (guards against empty/stub output)
220 +- No raw JSON or error messages in body
221 +
222 +**On failure:**
223 +- Block publish
224 +- Log failure reason to workflow summary
225 +- Open an issue tagged `quality-gate-failure` for human review
226 +- Do NOT retry analysis automatically (preserves Copilot request budget)
227 +
228 +### Decision 5: MCP Tools Strategy
229 +
230 +**Directive:** MCP tools are authorized for multi-site crawling extensibility.
231 +
232 +**Constraints:**
233 +- Remote MCP calls MUST be allowlisted in GitHub Copilot agent settings (repo-level)
234 +- MCP tool definitions live in `.github/copilot/mcp.json`
235 +- Only crawl-stage tools may make external HTTP calls
236 +- Analysis-stage tools are local-only (read, write, glob, grep)
237 +
238 +**Future extensibility:**
239 +- Each new data source (HN, Reddit, etc.) is an MCP tool with a `crawl()` method
240 +- Tools registered in allowlist before activation
241 +- Rate limits per-source defined in tool config
242 +
243 +### Decision 6: Nap & Reskill Interface
244 +
245 +Every 5th pipeline run triggers a reskill cycle. The reskill workflow invokes Copilot CLI to review squad state and propose improvements.
246 +
247 +**Mechanism:**
248 +
249 +```bash
250 +# Counter check
251 +COUNTER=$(cat .squad/run-counter.txt)
252 +if [ $((COUNTER % 5)) -eq 0 ]; then
253 + # Reskill invocation
254 + copilot -p "Read .squad/agents/*/history.md and .squad/decisions.md. \
255 + Assess: What patterns are working? What should change? \
256 + Write recommendations to .squad/reskill/YYYY-WNN.md" \
257 + --no-ask-user \
258 + --allow-tool=read \
259 + --allow-tool=write \
260 + --allow-tool=glob \
261 + --share=./reskill-session.md
262 +fi
263 +```
264 +
265 +**Input context for reskill:**
266 +- `.squad/agents/*/history.md` — all agent learnings
267 +- `.squad/decisions.md` — current decision log
268 +- `data/analyzed/` — recent analysis outputs (quality trend)
269 +- `.squad/run-counter.txt` — run history
270 +
271 +**Output:**
272 +- `.squad/reskill/YYYY-WNN.md` — improvement recommendations
273 +- Optional: PR with proposed changes to agent prompts or pipeline config
274 +
275 +### Decision 7: Future Validation Spike — GITHUB_TOKEN + copilot-requests: write
276 +
277 +**Status:** Noted for future spike (not yet approved for production use).
278 +
279 +The community action `austenstone/copilot-cli` demonstrates that `GITHUB_TOKEN` with `permissions: copilot-requests: write` may eliminate the PAT requirement entirely. GitHub's official docs do not yet confirm this path.
280 +
281 +**Spike criteria:**
282 +- Create a test workflow with `copilot-requests: write`
283 +- Validate auth succeeds without PAT
284 +- Confirm quota/billing behaves identically
285 +- If successful: migrate from PAT to workflow token (simpler, no secret rotation)
286 +
287 +### Risks & Mitigations
288 +
289 +| Risk | Probability | Impact | Mitigation |
290 +|------|------------|--------|------------|
291 +| Copilot CLI quota exhaustion | Medium | High | Coarse-grained prompts; fallback to Models API |
292 +| PAT expiration in CI | Medium | Medium | GitHub secret expiry alerts; spike on workflow token |
293 +| Analysis quality drift | Low | High | Reviewer gate + reskill cycle |
294 +| MCP allowlist misconfiguration | Low | Medium | CI test that validates mcp.json against live config |
295 +| Node 22 unavailability in runner | Very Low | Low | Pin `actions/setup-node@v4` with explicit version |
296 +
297 +### Summary
298 +
299 +The SquadScope CI analysis pipeline uses a two-tier approach: Copilot CLI (primary, agentic, repo-aware) with GitHub Models API (fallback, simpler, REST-based). Data flows through well-defined stage boundaries with JSON → Markdown → HTML transformations. A quality gate ensures no low-quality analysis reaches publication. The architecture is designed for extensibility via MCP tools and self-improvement via the reskill cycle.
300 +
301 ## Governance
302
303 - All meaningful changes require team consensus
themes/PaperMod new
+1
@@ -0,0 +1 @@
1 +Subproject commit 154d006e0182dfc7da38008323976b02e6bfab4a