pi-aia-asf 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/package.json +1 -1
- package/skills/aia-asf/SKILL.md +19 -0
- package/skills/aia-asf/references/04-adversarial.md +6 -0
- package/skills/aia-asf/references/05-plan.md +4 -1
- package/skills/aia-asf/references/06-implementation.md +6 -0
- package/skills/aia-asf/references/06c-code-quality.md +170 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.2] - 2026-08-14
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Mandatory modularity & maintainability standard** (`references/06c-code-quality.md`) — 8 rules distilled from Bruno's Tunnel-project philosophy (small well-readable modules plugged in where needed; one authoritative implementation for shared functionality with a single escalation path; no hardcoding — config-driven; fully testable outside the host then integrated verbatim, same modules in tests and production; refactor what is too complex to understand; layered with clear one-way boundaries and an architecture writeup; full I/O debug logging with replay of stored data; nothing may break existing functionality) and reinforced by external research (SSOT, testability as design property, ports-and-adapters seams).
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- **Phase 6** now requires reading `06c-code-quality.md` before structuring code; **Phase 7** verification includes the modularity DoD (no duplicated shared logic, no hardcoded config values, standalone-tested modules, architecture writeup, existing functionality green).
|
|
19
|
+
- **Phase 4** adversarial analysis gains a code-quality lens (duplication, single escalation path, standalone testability, hardcoded values); **Phase 5** PLAN.md architecture section now requires the SSOT map, layering rules, and standalone-testability notes.
|
|
20
|
+
- Anti-patterns extended: god-objects, copy-pasted shared logic, test copies of modules, hardcoding, per-caller escalation logic, untestable-standalone modules, behavior-breaking refactors.
|
|
21
|
+
|
|
22
|
+
|
|
10
23
|
## [0.2.1] - 2026-08-14
|
|
11
24
|
|
|
12
25
|
### Added
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-aia-asf",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Ai Applied Agentic Software Factory — codifies the full software development flow: intake, research, spec capture, adversarial analysis, planning with approval gates, test-first implementation, and release. Requires pi-vigilant, pi-smart-web-search, pi-smart-fetch, and pi-aia-browser.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
package/skills/aia-asf/SKILL.md
CHANGED
|
@@ -172,6 +172,14 @@ Keep the plan **implementation-ready**: any competent engineer (or agent) can ex
|
|
|
172
172
|
> **read the actual error before editing**; **verify clean-room** (caches serve stale
|
|
173
173
|
> builds); **add a regression test for every bug fixed**.
|
|
174
174
|
|
|
175
|
+
> **Read `references/06c-code-quality.md` before structuring code.** It is the mandatory
|
|
176
|
+
> modularity & maintainability standard: small well-readable modules plugged in where
|
|
177
|
+
> needed; **one implementation for shared functionality** (single escalation path,
|
|
178
|
+
> SSOT); no hardcoding (config-driven); **testable outside the host then integrated
|
|
179
|
+
> verbatim** (same modules in tests and production); refactor what is too complex to
|
|
180
|
+
> understand; layered with clear boundaries and an architecture writeup; full I/O debug
|
|
181
|
+
> logging with replay; nothing breaks existing functionality.
|
|
182
|
+
|
|
175
183
|
Execute the task list milestone by milestone. Discipline rules:
|
|
176
184
|
|
|
177
185
|
1. **Test-first**: write/update tests before or with implementation; run them; only commit green.
|
|
@@ -190,6 +198,8 @@ Execute the task list milestone by milestone. Discipline rules:
|
|
|
190
198
|
|
|
191
199
|
Run the **Definition of Done checklist** in `references/06b-testing-qa.md` (Rule 10). Every box must hold.
|
|
192
200
|
|
|
201
|
+
Also check the **modularity DoD** from `references/06c-code-quality.md` (Phase 7 section): no duplicated shared logic, no hardcoded config values, every module tested standalone with the same calls it gets in the host, architecture writeup exists, existing functionality still green.
|
|
202
|
+
|
|
193
203
|
1. Run the full test suite (all of it, not a subset); fix failures; re-run until green.
|
|
194
204
|
2. **Verify the artifact a user would actually get**: inspect the packaged file list
|
|
195
205
|
(`npm pack` → `tar tzf`), install/load it clean-room in a fresh dir with caches
|
|
@@ -223,6 +233,14 @@ Run the **Definition of Done checklist** in `references/06b-testing-qa.md` (Rule
|
|
|
223
233
|
- ❌ Asking a barrage of intake questions for small work — small runs automatically
|
|
224
234
|
- ❌ Writing PLAN.md / demanding approval for small work — that's the large-work gate only
|
|
225
235
|
- ❌ Waiting for sign-off when the work is small; when in doubt, default to small and start
|
|
236
|
+
- ❌ One giant file / god-object that "does everything" — small well-readable modules, plugged in
|
|
237
|
+
- ❌ Copy-pasting shared logic instead of importing the one authoritative module (SSOT)
|
|
238
|
+
- ❌ A "test copy" of a module that differs from the production version — same modules everywhere
|
|
239
|
+
- ❌ Hardcoding values (model names, thresholds, URLs) that config should drive
|
|
240
|
+
- ❌ Escalation/fallback logic re-implemented per caller instead of one shared escalation path
|
|
241
|
+
- ❌ Shipping a module that cannot run/test standalone outside the host
|
|
242
|
+
- ❌ Refactoring without the architecture writeup (see `references/06c-code-quality.md`)
|
|
243
|
+
- ❌ Breaking existing functionality during a refactor — refactoring preserves behavior
|
|
226
244
|
|
|
227
245
|
## References
|
|
228
246
|
|
|
@@ -232,4 +250,5 @@ Run the **Definition of Done checklist** in `references/06b-testing-qa.md` (Rule
|
|
|
232
250
|
- `references/05-plan.md` — PLAN.md template with examples
|
|
233
251
|
- `references/06-implementation.md` — coding discipline details
|
|
234
252
|
- `references/06b-testing-qa.md` — **mandatory testing & QA standard** (11 rules + definition of done)
|
|
253
|
+
- `references/06c-code-quality.md` — **mandatory modularity & maintainability standard** (8 rules, SSOT, testable-standalone, single escalation path)
|
|
235
254
|
- `references/07-release.md` — release workflow (versioning, CHANGELOG, tags, npm, CI/CD)
|
|
@@ -8,6 +8,12 @@ Challenge every spec and design decision like a hostile reviewer. For each item,
|
|
|
8
8
|
|
|
9
9
|
## Per-spec questions
|
|
10
10
|
|
|
11
|
+
> **Code-quality lens (always applied):** for every module/design under review,
|
|
12
|
+
> also ask the `references/06c-code-quality.md` questions — is shared logic
|
|
13
|
+
> duplicated anywhere? Is the single escalation path identifiable? Is the module
|
|
14
|
+
> testable standalone with the same calls? Any hardcoded values that belong in
|
|
15
|
+
> config?
|
|
16
|
+
|
|
11
17
|
- **Edge cases**: empty input, zero data, max load, missing fields, concurrent access, duplicate input, unicode, huge payloads
|
|
12
18
|
- **Failure modes**: what breaks first? Is failure loud or silent? Can we recover automatically?
|
|
13
19
|
- **Security**: authentication, authorization, injection (SQL/XSS), data exposure, secrets, abuse/rate-limiting, supply chain
|
|
@@ -21,10 +21,13 @@ Existing system, repo layout, relevant prior work. Links to research sources.
|
|
|
21
21
|
Decided approach with rationale. Cite the research (package names, URLs).
|
|
22
22
|
|
|
23
23
|
## Architecture / Design
|
|
24
|
-
-
|
|
24
|
+
- Modules and their responsibilities (small, single-purpose — see `references/06c-code-quality.md`)
|
|
25
25
|
- Data model / schema (if any)
|
|
26
26
|
- Key flows (request lifecycle, event flow)
|
|
27
27
|
- Interfaces / contracts between components
|
|
28
|
+
- **Where shared truth lives** (single source of truth map: which module owns each shared capability)
|
|
29
|
+
- **Layering**: one-way dependency rules between layers; what each layer may/may not import
|
|
30
|
+
- **Standalone testability**: how each module is exercised outside the host with the same calls
|
|
28
31
|
|
|
29
32
|
## Milestones
|
|
30
33
|
| # | Milestone | Exit criteria |
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Phase 6 — Implementation Discipline
|
|
2
2
|
|
|
3
|
+
> **Also read `references/06c-code-quality.md`** — the modularity & maintainability
|
|
4
|
+
> standard. Structure code as small modules with one responsibility, keep shared
|
|
5
|
+
> functionality in exactly one implementation (SSOT, single escalation path),
|
|
6
|
+
> never hardcode what config should drive, and keep every module testable
|
|
7
|
+
> standalone outside the host.
|
|
8
|
+
|
|
3
9
|
## Test-first
|
|
4
10
|
|
|
5
11
|
1. Write the failing test for the next behavior
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Modularity & Maintainability Standard (MANDATORY)
|
|
2
|
+
|
|
3
|
+
Distilled from Bruno's own development philosophy — honed on the Tunnel project
|
|
4
|
+
and its modules (smart-router, autoroute, feature-extractor, heuristic-engine) —
|
|
5
|
+
and reinforced by established software-engineering research: **Single Source of
|
|
6
|
+
Truth (SSOT)**, **testability as a design property**, and **ports-and-adapters
|
|
7
|
+
(hexagonal) seams**.
|
|
8
|
+
|
|
9
|
+
These rules exist because violating them caused real pain in those sessions:
|
|
10
|
+
code "thrown on a heap", duplicated logic, hardcoded model attributes, modules
|
|
11
|
+
that could not be tested outside the server, and regressions that broke
|
|
12
|
+
existing functionality. Each rule below carries the lesson.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Rule 1 — Small, well-readable modules, plugged in where needed
|
|
17
|
+
|
|
18
|
+
> *"You throw a bunch of code and functionality on a heap, instead of making
|
|
19
|
+
> smaller, well-readable modules and plugging them in where needed."* — Tunnel sessions
|
|
20
|
+
|
|
21
|
+
- One module = one responsibility. If a file does two unrelated things, split it.
|
|
22
|
+
- A module must be **readable top to bottom** by someone new: clear names,
|
|
23
|
+
short functions, no 500-line god-files.
|
|
24
|
+
- **Plug in, don't embed**: the host system imports and wires modules; it does
|
|
25
|
+
not copy their logic inline.
|
|
26
|
+
- Extraction triggers (any of these → extract a module):
|
|
27
|
+
- a function/concern exceeds ~100 lines or 3 levels of nesting
|
|
28
|
+
- the same logic is needed by two call sites
|
|
29
|
+
- you cannot explain what the file does in one sentence
|
|
30
|
+
- you are about to debug the same area a second time
|
|
31
|
+
|
|
32
|
+
## Rule 2 — One implementation for shared functionality (single escalation path)
|
|
33
|
+
|
|
34
|
+
> *"Make a separate module for ... communication and use IT instead of having
|
|
35
|
+
> that function integrated in there."* — Tunnel sessions
|
|
36
|
+
|
|
37
|
+
- **Every shared capability lives in exactly one authoritative module.**
|
|
38
|
+
Everything else imports it. No copies, no re-implementations, no
|
|
39
|
+
"parallel systems working side by side" (*"I want an integrated system, not a
|
|
40
|
+
dual system working side by side"*).
|
|
41
|
+
- This is the **Single Source of Truth** (SSOT) principle: every piece of
|
|
42
|
+
knowledge exists in exactly one place; every other reference *points* to it.
|
|
43
|
+
- SSOT checklist before shipping (from research on SSOT):
|
|
44
|
+
- Is any value/logic defined in more than one place?
|
|
45
|
+
- If this changes tomorrow, how many files do I touch? (Answer: **one**.)
|
|
46
|
+
- Would a new developer know where the authoritative version lives?
|
|
47
|
+
- Escalation paths included: if a request can escalate (to a stronger model,
|
|
48
|
+
a fallback, a retry, an admin), there is **one** escalation path module that
|
|
49
|
+
every caller routes through — not ad-hoc escalation logic scattered per
|
|
50
|
+
caller.
|
|
51
|
+
|
|
52
|
+
## Rule 3 — No hardcoding; config drives behavior
|
|
53
|
+
|
|
54
|
+
> *"DO NOT hard-code attributes of models ... stuff in the brackets is specific
|
|
55
|
+
> to opus, but not necessarily to any model we will add."* — Tunnel sessions
|
|
56
|
+
|
|
57
|
+
- Model names, thresholds, limits, timeouts, URLs, feature flags: all load from
|
|
58
|
+
config, never literal in logic.
|
|
59
|
+
- If you hardcode a value that another system (or a future system) might share,
|
|
60
|
+
you have created a second source of truth — see Rule 2.
|
|
61
|
+
- The module must behave the same for any config input; its logic is
|
|
62
|
+
config-agnostic.
|
|
63
|
+
|
|
64
|
+
## Rule 4 — Testable outside the host, then integrated verbatim
|
|
65
|
+
|
|
66
|
+
> *"MAKE IT TIGHT AND MODULAR AND FULLY TESTABLE OUTSIDE OF THE SERVER. TEST
|
|
67
|
+
> EVERYTHING 100% ANALOGOUS TO HOW IT WORKS ON THE SERVER ... THEN INTEGRATE
|
|
68
|
+
> BACK INTO THE SERVER."* — Tunnel sessions
|
|
69
|
+
|
|
70
|
+
- A module must run standalone: a test script imports and primes it **with the
|
|
71
|
+
exact same calls** the host would make.
|
|
72
|
+
- **Same modules in tests and production** — never a "test copy" of logic.
|
|
73
|
+
Tests import the production module; the host imports the same module.
|
|
74
|
+
(*"It should be imported in [the host] and used there with no changes — a
|
|
75
|
+
separate test script importing and priming the module can be created for
|
|
76
|
+
testing."*)
|
|
77
|
+
- **Testability is a design property, not a testing task** (research): if a
|
|
78
|
+
business rule needs a running server + real DB to validate, the architecture
|
|
79
|
+
is wrong. Core logic should run as plain functions with injected fakes.
|
|
80
|
+
- Build **seams** (ports-and-adapters): core logic depends on interfaces
|
|
81
|
+
(clock, IDs, persistence, external calls, message publishing), not on
|
|
82
|
+
concrete infrastructure. Adapters live at the edge.
|
|
83
|
+
- Verification flow: develop → test standalone (100% analogous) → **integrate
|
|
84
|
+
into the host verbatim** → re-test in place.
|
|
85
|
+
|
|
86
|
+
## Rule 5 — Refactor what is too complex to understand
|
|
87
|
+
|
|
88
|
+
> *"REFACTOR WHAT IS TOO COMPLEX FOR YOU TO UNDERSTAND!"* — Tunnel sessions
|
|
89
|
+
|
|
90
|
+
- Complexity you cannot explain is a defect, not a badge of honor.
|
|
91
|
+
- When you find yourself running "rounds like a moron" debugging something,
|
|
92
|
+
**stop and refactor the module** instead of patching blind.
|
|
93
|
+
- Refactor gate (when to invest): only refactor when it makes debugging and
|
|
94
|
+
individual component testing easier and faster, with the data you already
|
|
95
|
+
have. Not refactoring for its own sake; refactoring for **testability and
|
|
96
|
+
clarity**.
|
|
97
|
+
- Refactoring techniques that directly serve this (research-validated):
|
|
98
|
+
**Extract Method** (break long functions into named steps), **Extract Class/
|
|
99
|
+
Module** (group related logic), **Replace Conditional with Polymorphism**
|
|
100
|
+
(turn nested conditionals into modular dispatch), **Remove Duplication**
|
|
101
|
+
(collapse copies into one implementation).
|
|
102
|
+
|
|
103
|
+
## Rule 6 — Layer with clear boundaries, and document them
|
|
104
|
+
|
|
105
|
+
> *"Refactor the layering for readability completely, test everything in
|
|
106
|
+
> detail, and do a writeup for the layered system."* — Tunnel sessions
|
|
107
|
+
|
|
108
|
+
- Define layers (e.g., handler → router → modules → backends) with one-way
|
|
109
|
+
dependency rules. No layer reaches across another.
|
|
110
|
+
- **Do a writeup**: a short architecture doc (in the repo) stating what each
|
|
111
|
+
module is, what it uses, how and why, and where truth lives (the SSOT map).
|
|
112
|
+
(*"Properly document the modules and the main scaffolding to always have a
|
|
113
|
+
clear idea what is happening where."*)
|
|
114
|
+
- Research on architecture fitness: keep the "core" boring and deterministic
|
|
115
|
+
(no framework/IO inside); edges translate to and from infrastructure.
|
|
116
|
+
|
|
117
|
+
## Rule 7 — Debug observability: full I/O logging, replayable
|
|
118
|
+
|
|
119
|
+
> *"Shouldn't you also log somewhere the FULL input and outputs of the whole
|
|
120
|
+
> chain (during debug only) including headers and bodies ... and then
|
|
121
|
+
> comparing, since the lateral test just works?"* — Tunnel sessions
|
|
122
|
+
|
|
123
|
+
- During debug: log the **full input and output of the whole chain** (headers,
|
|
124
|
+
bodies, intermediate steps) to disk — not just errors.
|
|
125
|
+
- Side tests must log identically, so you can **compare** a passing lateral
|
|
126
|
+
test against a failing production call and see the divergence.
|
|
127
|
+
- Keep captured real traffic and **replay it through the structure**
|
|
128
|
+
(*"using stored message data and replaying it through the structure"*) to
|
|
129
|
+
reproduce and fix without the live host.
|
|
130
|
+
- Logging must be enough that long-term debugging works from log files and the
|
|
131
|
+
stored corpus alone.
|
|
132
|
+
|
|
133
|
+
## Rule 8 — Nothing may break existing functionality
|
|
134
|
+
|
|
135
|
+
> *"Nothing may break already existing functionality in the server."* — Tunnel sessions
|
|
136
|
+
|
|
137
|
+
- Modularity changes and refactors are **behavior-preserving**: same inputs,
|
|
138
|
+
same outputs, same side effects.
|
|
139
|
+
- After any restructuring, run the existing tests + a regression pass over the
|
|
140
|
+
previous behavior before declaring done.
|
|
141
|
+
- This is the SSOT/refactor safety net: refactoring restructures *structure*,
|
|
142
|
+
never *behavior*.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## Where this applies in ASF
|
|
147
|
+
|
|
148
|
+
- **Phase 4 (adversarial)**: challenge the design — is there duplication?
|
|
149
|
+
Where is the single source of truth? Is the module testable outside the
|
|
150
|
+
host? What breaks if a config value changes?
|
|
151
|
+
- **Phase 5 (PLAN.md)**: the Architecture/Design section must name the modules,
|
|
152
|
+
their boundaries, the one-way dependencies, where shared truth lives, and
|
|
153
|
+
how each module is tested standalone.
|
|
154
|
+
- **Phase 6 (implementation)**: apply Rules 1–8 as you build; extract modules
|
|
155
|
+
when triggers fire; write the architecture doc alongside the code.
|
|
156
|
+
- **Phase 7 (verification)**: the DoD checklist includes: no duplicated shared
|
|
157
|
+
logic (Rule 2), no hardcoded config values (Rule 3), every module tested
|
|
158
|
+
standalone with the same calls (Rule 4), architecture doc written (Rule 6),
|
|
159
|
+
existing functionality still green (Rule 8).
|
|
160
|
+
|
|
161
|
+
## Anti-patterns
|
|
162
|
+
|
|
163
|
+
- ❌ One giant file / god-object that "does everything"
|
|
164
|
+
- ❌ Copy-pasting shared logic instead of importing the one module
|
|
165
|
+
- ❌ A "test version" of a module that differs from the production version
|
|
166
|
+
- ❌ Hardcoded model names, thresholds, URLs in logic instead of config
|
|
167
|
+
- ❌ Escalation/fallback logic re-implemented per caller instead of one path
|
|
168
|
+
- ❌ Refactoring "for fun" without the testability/debugging payoff
|
|
169
|
+
- ❌ Shipping a module that cannot run outside the host
|
|
170
|
+
- ❌ Skipping the architecture writeup ("the code is self-documenting")
|