sdcs 1.3.0__tar.gz
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.
- sdcs-1.3.0/LICENSE +21 -0
- sdcs-1.3.0/PKG-INFO +457 -0
- sdcs-1.3.0/README.md +427 -0
- sdcs-1.3.0/pyproject.toml +79 -0
- sdcs-1.3.0/setup.cfg +4 -0
- sdcs-1.3.0/src/sdcs/__init__.py +8 -0
- sdcs-1.3.0/src/sdcs/audit.py +326 -0
- sdcs-1.3.0/src/sdcs/cli.py +184 -0
- sdcs-1.3.0/src/sdcs/init.py +588 -0
- sdcs-1.3.0/src/sdcs/verifier/__init__.py +15 -0
- sdcs-1.3.0/src/sdcs/verifier/topology.py +298 -0
- sdcs-1.3.0/src/sdcs.egg-info/PKG-INFO +457 -0
- sdcs-1.3.0/src/sdcs.egg-info/SOURCES.txt +19 -0
- sdcs-1.3.0/src/sdcs.egg-info/dependency_links.txt +1 -0
- sdcs-1.3.0/src/sdcs.egg-info/entry_points.txt +4 -0
- sdcs-1.3.0/src/sdcs.egg-info/requires.txt +7 -0
- sdcs-1.3.0/src/sdcs.egg-info/top_level.txt +1 -0
- sdcs-1.3.0/tests/test_audit.py +192 -0
- sdcs-1.3.0/tests/test_cli.py +73 -0
- sdcs-1.3.0/tests/test_init.py +118 -0
- sdcs-1.3.0/tests/test_topology.py +135 -0
sdcs-1.3.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Adam Murphy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
sdcs-1.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sdcs
|
|
3
|
+
Version: 1.3.0
|
|
4
|
+
Summary: Spec-Driven Cognitive Scaffolding (SDCS) - A deterministic cognitive harness for autonomous agentic software engineering.
|
|
5
|
+
Author: Adam Murphy
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/adamm285-dev/Spec-Driven-Cognitive-Scaffolding-SDCS
|
|
8
|
+
Project-URL: Repository, https://github.com/adamm285-dev/Spec-Driven-Cognitive-Scaffolding-SDCS
|
|
9
|
+
Project-URL: Specification, https://github.com/adamm285-dev/Spec-Driven-Cognitive-Scaffolding-SDCS/blob/main/SPEC-001.md
|
|
10
|
+
Keywords: agents,agentic-coding,ai,scaffolding,claude-code,cursor,gemini,autonomous-agents,evals,adr
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
19
|
+
Classifier: Topic :: Software Development :: Testing
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: PyYAML>=6.0
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
26
|
+
Requires-Dist: ruff>=0.5.0; extra == "dev"
|
|
27
|
+
Requires-Dist: black>=24.0.0; extra == "dev"
|
|
28
|
+
Requires-Dist: mypy>=1.10.0; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# Spec-Driven Cognitive Scaffolding (SDCS) Framework
|
|
32
|
+
|
|
33
|
+
[](SPEC-001.md)
|
|
34
|
+
[](https://github.com/)
|
|
35
|
+
[](https://www.python.org/)
|
|
36
|
+
[](LICENSE)
|
|
37
|
+
[](#)
|
|
38
|
+
|
|
39
|
+

|
|
40
|
+
|
|
41
|
+
A formal, file-based cognitive harness for autonomous agentic software engineering conforming to [SPEC-001](SPEC-001.md).
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Specifications
|
|
46
|
+
|
|
47
|
+
- **[SPEC-001 (v1.3.0)](SPEC-001.md):** Single-Agent Cognitive Harness — The active specification governing repository-level working memory, negative decisions, and cryptographic test verification.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## The Problem: The Failure of Monolithic Prompting
|
|
52
|
+
|
|
53
|
+

|
|
54
|
+
|
|
55
|
+
Autonomous coding agents typically fail not because of underlying model capability, but because of **context conflation**. When all operational logic, temporary thoughts, file directories, and project history are crammed into a single system prompt or chat log, three fatal pathologies emerge:
|
|
56
|
+
|
|
57
|
+
1. **Context Drift:** As conversational message counts increase, core architectural constraints and safety rules get diluted and pushed out of the model's effective attention window.
|
|
58
|
+
2. **Cartographic Hallucination:** Lacking a persistent, explicit map of the codebase, agents enter token-wasting brute-force search loops (`find`, `grep`) or hallucinate non-existent files and interfaces.
|
|
59
|
+
3. **Episodic Amnesia:** Agents possess no structured negative memory. When restarted or encountering a rollback, they repeatedly re-attempt architectural decisions that were already measured and rejected in prior sessions.
|
|
60
|
+
|
|
61
|
+
> **Root Cause:** Monolithic prompts conflate invariant rules, ephemeral scratchpad state, module cartography, and historical audit logs into a single bloated context window.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## The Core Cognitive Topography
|
|
66
|
+
|
|
67
|
+

|
|
68
|
+
|
|
69
|
+
SDCS decouples agent cognition into seven purpose-built files plus an isolated flight recorder:
|
|
70
|
+
|
|
71
|
+
| # | File | Pillar Role | Analogy | Description |
|
|
72
|
+
| :-: | :--- | :--- | :--- | :--- |
|
|
73
|
+
| **1** | `spine.md` | Constitutional Invariants | **The Law** | Immutable domain axioms, verification gates, and forbidden actions. |
|
|
74
|
+
| **2** | `wiring.yaml` | Declarative Topology | **The Mesh** | Component boundaries, service mesh, interface bindings, and contracts. |
|
|
75
|
+
| **3** | `roadmap.md` | Acceptance Contract | **The North Star** | High-level human intent vs. measured empirical reality (`[INTENT]` vs `[MEASURED]`). |
|
|
76
|
+
| **4** | `state.md` | Dynamic Working Memory | **The Whiteboard** | Active milestone objectives, immediate blockers, and pending gates (~300 token budget). |
|
|
77
|
+
| **5** | `app_map.md` | Repository Cartography | **The Compass** | Structural index of modules and responsibilities consulted prior to file access. |
|
|
78
|
+
| **6** | `decisions.md` | Negative Episodic Memory | **The Graveyard** | Rejection log of measured dead ends (`Claim` → `Measurement` → `Reopen Condition`). |
|
|
79
|
+
| **7** | `evals.md` | Positive Episodic Memory | **The Scorecard** | Benchmark standing, golden test fixtures, and SHA-256 diversity guards. |
|
|
80
|
+
| **+** | `sessions/*.md` | Historical Handoff Logs | **The Flight Recorder** | Discrete, immutable post-shift engineering handoffs. Never ingested on system boot. |
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Architectural Lineage & Theoretical Foundations
|
|
85
|
+
|
|
86
|
+
SDCS is not reinventing software theory; it is the deliberate, pragmatic application of battle-tested systems programming, distributed systems primitives, and formal methods adapted to constrain probabilistic LLM context windows. When an autonomous agent is given an unconstrained prompt and bash access, it drifts and rationalizes errors. By grounding agent workflows in classical computer science patterns, we achieve deterministic engineering stability:
|
|
87
|
+
|
|
88
|
+
* **The Blackboard Pattern** (*Erman, Lesser, Hayes-Roth, & Reddy, 1980*): Implemented in `state.md` to externalize volatile working memory, adopting Carnegie Mellon's *HEARSAY-II* pattern where opportunistic reasoning engines read and mutate an isolated, low-budget whiteboard instead of passing unbounded conversational state.
|
|
89
|
+
* **Design by Contract & Formal Invariant Theory** (*Hoare, 1969; Meyer, 1986*): Implemented in `spine.md` as non-negotiable domain axioms, preconditions, and execution gates that cannot be softened, bypassed, or negotiated by agent inference.
|
|
90
|
+
* **Modular Information Hiding** (*Parnas, 1972*): Implemented in `wiring.yaml` to enforce explicit component interfaces, runtime contracts, and tool boundaries, containing blast radii and eliminating circular module dependencies.
|
|
91
|
+
* **Optative vs. Indicative Requirements & Cybernetic Control** (*Wiener, 1948; Brinch Hansen, 1970; Jackson, 1995*): Implemented in `roadmap.md` to decouple high-level human intent (`[INTENT]`, optative policy) from measured empirical results (`[MEASURED]`, indicative mechanism), preventing teleological drift and proxy metric optimization.
|
|
92
|
+
* **Virtual Memory Page Tables & The Working Set Model** (*Denning, 1968; Kruchten, 1995*): Implemented in `app_map.md` as an external index of repository cartography, translating high-level task goals into explicit file paths so agents page only necessary dependencies into context rather than thrashing tokens on recursive filesystem scans.
|
|
93
|
+
* **Inverted Architecture Decision Records & Falsification** (*Popper, 1959; Nygard, 2011*): Implemented in `decisions.md` to establish negative episodic memory, inverting classic ADRs into an append-only rejection graveyard that blocks cyclical multi-turn regressions using empirical measurements and concrete reopening criteria.
|
|
94
|
+
* **Cryptographic Content Addressing** (*Merkle, 1979*): Implemented in `evals.md` to bind test fixtures and empirical standing to commit hashes and SHA-256 digests, eliminating the "Phantom Corpus" failure mode where duplicate files masquerade as valid coverage.
|
|
95
|
+
* **Write-Ahead Logging & Append-Only Ledgers** (*Gray & Reuter, 1992*): Implemented in `sessions/*.md` to physically isolate historical, write-once shift handoff records from the volatile execution loop, preventing context poisoning and eliminating git merge conflicts across parallel agents.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Pillars 1 & 2: Boundary & Topology
|
|
100
|
+
|
|
101
|
+

|
|
102
|
+
|
|
103
|
+
Constraining an autonomous agent's operational blast radius requires rigorous, explicit boundaries:
|
|
104
|
+
|
|
105
|
+
* **`spine.md` (Constitutional Invariants):**
|
|
106
|
+
- Immutable domain axioms that cannot be prompt-negotiated or overridden by agent assumptions.
|
|
107
|
+
- Deterministic verification gates (test runners, linters, coverage baselines).
|
|
108
|
+
- Absolute forbidden actions (e.g., modifying invariant definitions, committing secrets, unvetted destructive file ops).
|
|
109
|
+
* **`wiring.yaml` (Declarative Topology):**
|
|
110
|
+
- Maps the service mesh, subsystem interfaces, and package dependency graph.
|
|
111
|
+
- Defines strict tool boundaries and environment runtime contracts.
|
|
112
|
+
- Mandates explicit inputs and outputs across components to eliminate circular import loops.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Pillar 3: The Macro Acceptance Contract (`roadmap.md`)
|
|
117
|
+
|
|
118
|
+
Without an explicit `roadmap.md`, autonomous agents suffer from **Specification Drift** and **Scope Creep**—they optimize proxy metrics or invent unrequested requirements.
|
|
119
|
+
|
|
120
|
+
### Key Invariants:
|
|
121
|
+
1. **The Strict Dichotomy (`[INTENT]` vs `[MEASURED]`):**
|
|
122
|
+
- **`[INTENT]`**: The human/client's verbatim requirements for acceptance in production. Not negotiable by an agent, and never to be "improved" by agent inference.
|
|
123
|
+
- **`[MEASURED]`**: Empirical numbers, real benchmarks, and verified state directly extracted from tests and code.
|
|
124
|
+
2. **Strictly NO Task Queue:**
|
|
125
|
+
- Ephemeral, turn-by-turn tasks belong exclusively in `state.md`.
|
|
126
|
+
- Hand-maintained to-do lists in roadmaps inevitably rot, accumulate stale tasks, and misdirect agents.
|
|
127
|
+
3. **Telemetry Freshness:** Every `[MEASURED]` entry must link to a verified commit hash or milestone. Telemetry exceeding the freshness window (30 days / 50 commits) is tagged `[STALE]`.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## Pillars 4 & 5: Working Memory & Cartography
|
|
132
|
+
|
|
133
|
+

|
|
134
|
+
|
|
135
|
+
Agents frequently burn context windows on recursive filesystem queries. SDCS solves this with a two-tiered spatial memory:
|
|
136
|
+
|
|
137
|
+
* **`state.md` (The Blackboard - Pillar 4):**
|
|
138
|
+
- Houses ephemeral, turn-by-turn ground truth: current active objective, immediate blockers, and active test gates.
|
|
139
|
+
- **Strict ~300 Token Budget:** Pruned and overwritten after every completed subtask or milestone.
|
|
140
|
+
- Read on Turn 1 boot so the agent immediately knows where it left off without reading conversation history.
|
|
141
|
+
* **`app_map.md` (Codebase Cartography - Pillar 5):**
|
|
142
|
+
- A structured index of modules, entry points, and structural responsibilities.
|
|
143
|
+
- **The Golden Rule:** The agent consults `app_map.md` first, reading *only* the specific target files required for the task.
|
|
144
|
+
- Eliminates exhaustive brute-force search loops across large codebases.
|
|
145
|
+
- **Hierarchical Monorepo Scaling:** For enterprise codebases (>50 modules, >1,000 files), root `app_map.md` indexes subsystem interfaces (<1,000 tokens), while individual packages (e.g. `services/auth/app_map.md`) maintain nested cartography loaded on demand.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Symmetric Episodic Memory
|
|
150
|
+
|
|
151
|
+
Episodic memory must be bidirectional: an agent must know what **failed** just as clearly as what **passed**.
|
|
152
|
+
|
|
153
|
+
### Pillar 6: Negative Episodic Memory (`decisions.md`)
|
|
154
|
+
|
|
155
|
+

|
|
156
|
+
|
|
157
|
+
Without negative episodic memory, an agent encountering an edge case will repeatedly re-attempt hypotheses that failed in earlier sessions. `decisions.md` acts as an auditable **Rejection Graveyard**, enforcing a mandatory 3-part schema:
|
|
158
|
+
|
|
159
|
+
```markdown
|
|
160
|
+
## REJ-014: Morphological Closing Filter on Subfloor Mask
|
|
161
|
+
|
|
162
|
+
THE CLAIM:
|
|
163
|
+
Applying a 5x5 closing filter bridges broken line segments.
|
|
164
|
+
|
|
165
|
+
THE MEASUREMENT:
|
|
166
|
+
Halved room precision from 86.4% -> 43.1%; spawned 14 phantom polygons across bathroom fixtures.
|
|
167
|
+
|
|
168
|
+
WHAT WOULD REOPEN IT:
|
|
169
|
+
Blueprints scanned at < 150 DPI where contour continuity drops below 30%.
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
* **The Claim:** The optimization, algorithm, or refactor attempted.
|
|
173
|
+
* **The Measurement:** Empirical metric or test result demonstrating why it failed.
|
|
174
|
+
* **What Would Reopen It:** Concrete, falsifiable trigger required before any agent may retry the approach.
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
### Pillar 7: Positive Ground Truth & Standing (`evals.md`)
|
|
179
|
+
|
|
180
|
+

|
|
181
|
+
|
|
182
|
+
To prevent the **Phantom Corpus Trap** (where agents report illusory 100% test pass rates across files that are actually duplicate copies or empty templates), `evals.md` enforces cryptographic fixture verification:
|
|
183
|
+
|
|
184
|
+
* **Empirical Standing:** Defines current verified baseline performance anchored to git commit hashes.
|
|
185
|
+
* **Corpus Diversity Invariant:** Every golden benchmark fixture is cryptographically fingerprinted via SHA-256 digests. Duplicate byte-identical files under different names trigger an immediate audit halt.
|
|
186
|
+
* **Freshness Contract:** Expiration limits that require re-measuring baseline scores when dependencies or model weights update.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Working Memory vs. Shift Handoff: The Flight Recorder Protocol
|
|
191
|
+
|
|
192
|
+

|
|
193
|
+
|
|
194
|
+
A critical failure mode of agent architectures is token exhaustion caused by auto-loading historical conversation logs on boot. SDCS enforces a strict boundary between working memory and historical shift archives:
|
|
195
|
+
|
|
196
|
+
| Artifact | Role | Lifecycle | Agent Ingestion |
|
|
197
|
+
| :--- | :--- | :--- | :--- |
|
|
198
|
+
| **`state.md`** | **The Whiteboard** (Active Working Memory) | Constantly overwritten and pruned | **Always read on Turn 1.** Contains only active objectives, immediate blockers, and current verification status (~300 tokens). |
|
|
199
|
+
| **`sessions/*.md`** | **The Flight Recorder** (Shift Handoff Log) | Write-once, append-only discrete files | **CRITICAL INVARIANT: NEVER ingested on system boot.** Queried on demand only when an agent needs targeted forensic context. |
|
|
200
|
+
|
|
201
|
+
### Why Discrete Files Beat One Monolithic `sessions.md`
|
|
202
|
+
1. **Zero Git Merge Conflicts:** Concurrent agent workers across separate branches never collide on a shared append-only log.
|
|
203
|
+
2. **Deterministic Context Retrieval:** Target specific sessions (e.g., `sessions/2026-09-19_state-machine.md`) via targeted grep instead of ingesting a 30,000-token diary.
|
|
204
|
+
3. **Natural Checkpointing:** Every discrete file acts as an immutable, timestamped snapshot of that engineering shift.
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
## The Autonomous Execution Cycle
|
|
209
|
+
|
|
210
|
+

|
|
211
|
+
|
|
212
|
+
SDCS transforms passive static files into a deterministic, 4-phase continuous execution engine:
|
|
213
|
+
|
|
214
|
+
1. **Phase 1: Orientation**
|
|
215
|
+
- Hydrate constraints and current ground truth in strict order:
|
|
216
|
+
- `spine.md` → `roadmap.md` → `app_map.md` → `decisions.md` → `evals.md` → `state.md`.
|
|
217
|
+
2. **Phase 2: Planning**
|
|
218
|
+
- Formulate atomic diffs against `state.md`.
|
|
219
|
+
- Read `wiring.yaml` + strictly relevant target files identified via `app_map.md`.
|
|
220
|
+
3. **Phase 3: Execution**
|
|
221
|
+
- Apply isolated code mutations.
|
|
222
|
+
- Run empirical verification gates defined in `evals.md` (linters, test suites, benchmarks).
|
|
223
|
+
4. **Phase 4: Close-Out**
|
|
224
|
+
- Prune and update `state.md`.
|
|
225
|
+
- Append rejected hypotheses to `decisions.md`.
|
|
226
|
+
- Write an immutable flight recorder log in `sessions/YYYY-MM-DD_<topic>.md`.
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Lossless Compaction: The "Prepare for Compact" Protocol
|
|
231
|
+
|
|
232
|
+
In long engineering sessions spanning dozens of turns, AI context windows inevitably fill up. Development environments (such as Claude Code's `/compact`, Cursor chat resets, Aider history truncations, or LLM context window roll-offs) periodically summarize or prune the conversation transcript. When an un-scaffolded agent undergoes compaction, it suffers from **Compaction Amnesia**: active hypothesis chains, test gate states, unrecorded dead ends, and mental model cartography are wiped out. The agent wakes up on post-compact Turn 1 confused, prone to regression, and repeating measured errors.
|
|
233
|
+
|
|
234
|
+
SDCS eliminates Compaction Amnesia through the **Mid-Shift Checkpoint Protocol ("prepare for compact")** and the **Wiring Mutation Invariant (Pillar 2)**.
|
|
235
|
+
|
|
236
|
+
### The Operational Dimensions: Why, When, Where, and How
|
|
237
|
+
|
|
238
|
+
| Dimension | Specification Contract | Operational Details |
|
|
239
|
+
| :--- | :--- | :--- |
|
|
240
|
+
| **WHY** | **Lossless Memory Persistence & Boundary Guard** | Guarantees zero context loss across context window compactions. Externalizes fine-grained findings into the immutable flight recorder while keeping active working memory trimmed to $\le 300$ tokens so post-compact Turn 1 hydration is instant, focused, and drift-free. |
|
|
241
|
+
| **WHEN** | **1. Human Trigger:** `"prepare for compact"`<br>**2. Context Saturation (~70–80%)**<br>**3. Mid-Shift Milestone Completion** | Triggered mid-shift whenever the developer issues the command `"prepare for compact"` before running `/compact`, or whenever token usage approaches window capacity during multi-hour pair programming. |
|
|
242
|
+
| **WHERE** | **Cross-Pillar Synchronization:**<br>• `wiring.yaml` (Pillar 2)<br>• `sessions/*.md` (+1 Flight Recorder)<br>• `state.md` (Pillar 4)<br>• `decisions.md` (Pillar 6)<br>• `app_map.md` (Pillar 5)<br>• `roadmap.md` (Pillar 3) | Checkpoints are written to physical disk files before memory is cleared:<br>1. `wiring.yaml`: Audited and updated in-stride for newly introduced subsystems.<br>2. `sessions/YYYY-MM-DD_<topic>.md`: Discrete immutable flight recorder log.<br>3. `state.md`: Aggressively pruned strictly to $\le 300$ tokens.<br>4. `decisions.md`: Rejections and dead ends logged.<br>5. `app_map.md`: Synced with new/modified file paths.<br>6. `roadmap.md`: `[MEASURED]` telemetry logged if milestones were met. |
|
|
243
|
+
| **HOW** | **5-Step Automated Execution Cycle** | The agent mechanically executes a standardized 5-step checklist and emits an explicit readiness signal before compaction proceeds. |
|
|
244
|
+
|
|
245
|
+
### How It Works: The 5-Step Checkpoint Execution
|
|
246
|
+
|
|
247
|
+
```
|
|
248
|
+
[Developer: "prepare for compact" or Token Saturation Nears]
|
|
249
|
+
│
|
|
250
|
+
▼
|
|
251
|
+
1. Topology & Subsystem Audit ──► Runs `sdcs verify --topology` to audit wiring.yaml
|
|
252
|
+
│
|
|
253
|
+
▼
|
|
254
|
+
2. Flight Recorder Snapshot ──► Writes immutable log to `sessions/YYYY-MM-DD_<topic>.md`
|
|
255
|
+
│
|
|
256
|
+
▼
|
|
257
|
+
3. Blackboard Pruning ──► Prunes `state.md` to ≤ 300 tokens (Objective + Gate + Next Action)
|
|
258
|
+
│
|
|
259
|
+
▼
|
|
260
|
+
4. Episodic Memory Sweeps ──► Records failed approaches to `decisions.md` & updates `app_map.md`
|
|
261
|
+
│
|
|
262
|
+
▼
|
|
263
|
+
5. Compact Readiness Signal ──► Emits confirmation: "Ready for compaction." (Proceed to /compact)
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### In-Stride Updates: The Wiring Mutation Invariant (Pillar 2)
|
|
267
|
+
|
|
268
|
+
During extended engineering sessions, agents often add new packages or refactor module hierarchies. SDCS defines precise rules for when and how agents interact with `wiring.yaml`:
|
|
269
|
+
|
|
270
|
+
* **In-Stride Updates (Additive):** When the agent creates new subsystems, packages, or modules, it **MUST update `wiring.yaml` in-stride** (in the same step/commit as code creation). This ensures that new components have declared boundary contracts before Gate T AST verification runs.
|
|
271
|
+
* **Prohibited Relaxation (Bypasses & Cycles):** Modifying `wiring.yaml` to relax existing architectural boundaries, add circular dependencies, or bypass Gate T rejections without explicit human authorization (`SDCS_ALLOW_INVARIANT_MUTATION=1`) is strictly forbidden. If an import fails Gate T, the agent must decouple via dependency inversion or serialize the failure as an Inverted ADR (`## REJ-XXX`) into `decisions.md`.
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Automated Integrity Enforcement
|
|
276
|
+
|
|
277
|
+

|
|
278
|
+
|
|
279
|
+
SDCS provides deterministic Python tooling to bootstrap repositories and enforce verification gates:
|
|
280
|
+
|
|
281
|
+
* **`sdcs_init.py` (`sdcs init`):**
|
|
282
|
+
- Scaffolds the complete 7-pillar framework into any existing repository.
|
|
283
|
+
- Automatically indexes existing files and directory structure into `app_map.md`.
|
|
284
|
+
- Generates compliant `AGENTS.md` behavioral guidance, `sessions/template.md`, and `prompts/grillme.md`.
|
|
285
|
+
* **`sdcs grill` (`python sdcs_init.py --grill`):**
|
|
286
|
+
- Emits the `/grillme` adversarial spec elicitation prompt to interview human stakeholders and harden requirements into quantifiable `[INTENT]` contracts before code is generated.
|
|
287
|
+
* **`sdcs verify --topology` (`sdcs verify`):**
|
|
288
|
+
- Statically audits codebase Abstract Syntax Trees (AST) against `wiring.yaml` subsystem boundaries without importing code (Gate T).
|
|
289
|
+
- Automatically formats prohibited import edges into Inverted Architecture Decision Records (`## REJ-XXX`) and appends them to `decisions.md` (`--append-rejections`).
|
|
290
|
+
* **`audit_evals_corpus.py` (`sdcs audit`):**
|
|
291
|
+
- Validates that all benchmark fixtures listed in `evals.md` physically exist on disk.
|
|
292
|
+
- Recalculates SHA-256 hashes to catch unversioned drift or corrupted test assets.
|
|
293
|
+
- **Diversity Enforcement:** Automatically halts execution if duplicate byte-identical files masquerade as independent test cases.
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## Quickstart
|
|
298
|
+
|
|
299
|
+
### Installation
|
|
300
|
+
|
|
301
|
+
You can install `sdcs` via standard `pip` or run the standalone script directly:
|
|
302
|
+
|
|
303
|
+
#### Option 1: 1-Line Install directly from GitHub (No manual clone needed)
|
|
304
|
+
```bash
|
|
305
|
+
pip install git+https://github.com/adamm285-dev/Spec-Driven-Cognitive-Scaffolding-SDCS.git
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
#### Option 2: Clone and Install locally (For contributors / development)
|
|
309
|
+
```bash
|
|
310
|
+
git clone https://github.com/adamm285-dev/Spec-Driven-Cognitive-Scaffolding-SDCS.git
|
|
311
|
+
cd Spec-Driven-Cognitive-Scaffolding-SDCS
|
|
312
|
+
pip install -e .
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
#### Option 3: Zero-Install Standalone Script
|
|
316
|
+
If you don't want to install a package into your Python environment, `sdcs_init.py` is completely self-contained with zero non-standard library dependencies:
|
|
317
|
+
```bash
|
|
318
|
+
# Run directly with Python
|
|
319
|
+
python sdcs_init.py --help
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### 1. Initialize SDCS in Any Repository
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
# Scaffold the 7 pillars + sessions/ + AGENTS.md in repo root
|
|
326
|
+
sdcs init
|
|
327
|
+
|
|
328
|
+
# Or scaffold into a dedicated .agent/ directory
|
|
329
|
+
sdcs init --use-agent-dir
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
#### CLI Options
|
|
333
|
+
* `--target-dir <path>`: Target repository root path (default: `.`).
|
|
334
|
+
* `--use-agent-dir`: Store the 7 pillars and `sessions/` inside `.agent/` instead of the root.
|
|
335
|
+
* `--skip-agents-md`: Skip generating the `AGENTS.md` behavioral prompting file.
|
|
336
|
+
* `--force`: Overwrite existing files.
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
### 2. Audit Ground Truth Integrity
|
|
341
|
+
|
|
342
|
+
```bash
|
|
343
|
+
# Audit evals.md test fixtures and SHA-256 hashes
|
|
344
|
+
sdcs audit
|
|
345
|
+
|
|
346
|
+
# Or invoke the script directly
|
|
347
|
+
python audit_evals_corpus.py
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
* **Asset Reachability:** Verifies referenced fixture paths exist on disk.
|
|
351
|
+
* **Cryptographic Accuracy:** Asserts recorded SHA-256 digests match file contents.
|
|
352
|
+
* **Corpus Diversity & Anti-Evasion:** Detects both byte-identical files and **near-duplicates** (fixtures differing only by trivial whitespace, empty lines, or dummy formatting padding).
|
|
353
|
+
* **Hash Populator:** Automatically computes and displays hashes for rows marked `pending`.
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
357
|
+
### 3. Verify AST Topology Boundaries (Gate T)
|
|
358
|
+
|
|
359
|
+
```bash
|
|
360
|
+
# Statically audit codebase imports against wiring.yaml subsystem boundaries
|
|
361
|
+
sdcs verify --topology
|
|
362
|
+
|
|
363
|
+
# Automatically format boundary violations into inverted ADRs (## REJ-XXX)
|
|
364
|
+
# and append them directly to decisions.md
|
|
365
|
+
sdcs verify --topology --append-rejections
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
* **Zero Execution Risk:** Audits Abstract Syntax Trees (AST) using Python's standard `ast` module without importing or executing runtime code.
|
|
369
|
+
* **Negative Memory Serialization:** Programmatically binds architectural failures to Pillar 6 (`decisions.md`) using the strict **Claim $\rightarrow$ Measurement $\rightarrow$ Reopen Condition** schema.
|
|
370
|
+
* **Pre-Commit Hook Integration:** Enforced automatically during `git commit` to block structural boundary violations before code enters the repository.
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
### 4. Adversarial Spec Elicitation (`/grillme`)
|
|
375
|
+
|
|
376
|
+
Deterministic runtime execution requires unambiguous specifications. SDCS includes the **`/grillme` Adversarial Spec Elicitation Protocol** as an authoring tool to eliminate fuzzy requirements:
|
|
377
|
+
|
|
378
|
+
```bash
|
|
379
|
+
# Print the elicitation prompt to copy or pipe into an LLM session
|
|
380
|
+
sdcs grill
|
|
381
|
+
|
|
382
|
+
# Target a specific milestone
|
|
383
|
+
sdcs grill --milestone M-002
|
|
384
|
+
|
|
385
|
+
# Or invoke directly via the bootstrap script
|
|
386
|
+
python sdcs_init.py --grill
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
* **Zero Tolerance for Vague Adjectives:** Rejects terms like "fast", "clean", or "scalable".
|
|
390
|
+
* **Extracts Hard Ceilings & Floors:** Demands quantitative latency, throughput, memory, and coverage targets.
|
|
391
|
+
* **Auto-Populates `roadmap.md`:** Generates structured `[INTENT]` and `[MEASURED]` acceptance criteria.
|
|
392
|
+
* **Scaffolded File:** Generated at `prompts/grillme.md` (or `.agent/prompts/grillme.md`).
|
|
393
|
+
|
|
394
|
+
---
|
|
395
|
+
|
|
396
|
+
## Operational Scale Profiles
|
|
397
|
+
|
|
398
|
+
SDCS is built for **autonomous, multi-turn shifts** where context drift causes expensive regressions—not for single-line autocomplete. To prevent ceremony overhead on small tasks, use the appropriate profile:
|
|
399
|
+
|
|
400
|
+
| Profile | Hydration Set | Token Budget | Ideal For |
|
|
401
|
+
| :--- | :--- | :--- | :--- |
|
|
402
|
+
| **Lite** | `spine.md` + `state.md` | ~400 tokens | Interactive pair-programming, CSS/typo fixes, quick single-file refactors. |
|
|
403
|
+
| **Standard** | `spine.md` + `roadmap.md` + `app_map.md` + `state.md` | ~1,500 tokens | Subsystem feature work, localized refactors, unit test coverage expansion. |
|
|
404
|
+
| **Full Shift** | All 7 Pillars + `sessions/template.md` on close-out | ~2,500–3,500 tokens | Autonomous multi-turn agent runs, overnight refactors, cross-subsystem migrations. |
|
|
405
|
+
|
|
406
|
+
---
|
|
407
|
+
|
|
408
|
+
## Pragmatic Enforcement & The Permission Boundary
|
|
409
|
+
|
|
410
|
+
### Defense-in-Depth: Stopping the "Soft Invariant" Hole
|
|
411
|
+
When an autonomous agent encounters a failing test gate on Turn 12, a known failure mode is **rationalization**: editing `spine.md` or altering test runner flags to force "task completion." SDCS secures invariants across distinct architectural layers:
|
|
412
|
+
|
|
413
|
+
1. **Behavioral Layer (`AGENTS.md`):** Non-negotiable system rules prohibiting invariant tampering and requiring structured hydration.
|
|
414
|
+
2. **Topological Invariant Gate (Gate T):** AST-level static import audit ensuring code respects `wiring.yaml` subsystem boundaries, serializing violations into `decisions.md`.
|
|
415
|
+
3. **Constitutional Invariant Gate (Gate C):** Pre-commit hook automatically rejects commits modifying `spine.md` or `wiring.yaml` unless explicitly overridden via `SDCS_ALLOW_CONSTITUTIONAL_MUTATION=1`.
|
|
416
|
+
4. **Working Memory Sync Gate (Gate S):** CI/pre-commit checks requiring `state.md` synchronization whenever PRs or commits introduce $\ge 40$ modified lines.
|
|
417
|
+
5. **OS / Container Sandbox:** In automated agent environments, `spine.md` and `wiring.yaml` can be locked via `chmod 444` or mounted as read-only volumes (`:ro`).
|
|
418
|
+
|
|
419
|
+
### Git Hook Modes
|
|
420
|
+
|
|
421
|
+
| Strategy | Ideal Scenario | Mechanics | Velocity Impact |
|
|
422
|
+
| :--- | :--- | :--- | :--- |
|
|
423
|
+
| **Behavioral Prompting (`AGENTS.md`)** *(Recommended)* | Solo developers, rapid prototyping, interactive pair programming. | Embeds hydration order, wiring invariants, and mid-shift checkpoint ("prepare for compact") protocols into agent system rules. | **Zero friction.** Keeps you in flow state without blocking terminal commands. |
|
|
424
|
+
| **Advisory Git Hook (`sdcs.mode advisory`)** | Teams that want gentle reminders when refactors get large. | Emits terminal warnings on commits ≥ 40 lines without aborting. | **Zero blockage.** Visual feedback without interrupting commit flow. |
|
|
425
|
+
| **Strict Git Hook (`sdcs.mode strict`)** | Unattended autonomous loops, background agents, and CI/CD pipelines. | Rejects commits if `state.md` is missing, constitutional invariants are mutated (Gate C), or AST topology boundaries are breached (Gate T). | **High rigor.** Guarantees memory synchronization and invariant integrity. |
|
|
426
|
+
|
|
427
|
+
### Activating Git Hooks
|
|
428
|
+
|
|
429
|
+
```bash
|
|
430
|
+
# Configure git to use the repository hooks directory
|
|
431
|
+
git config core.hooksPath .githooks
|
|
432
|
+
|
|
433
|
+
# Select mode: 'advisory' (warning only) or 'strict' (blocking gate)
|
|
434
|
+
git config sdcs.mode advisory
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
---
|
|
438
|
+
|
|
439
|
+
## Author & Citation
|
|
440
|
+
|
|
441
|
+
If you use SDCS or reference the SPEC-001 architecture in your research, agent frameworks, or production systems, please cite the project:
|
|
442
|
+
|
|
443
|
+
```bibtex
|
|
444
|
+
@software{murphy2026sdcs,
|
|
445
|
+
author = {Murphy, Adam},
|
|
446
|
+
title = {Spec-Driven Cognitive Scaffolding (SPEC-001): A Deterministic Architecture for Autonomous Coding Agents},
|
|
447
|
+
year = {2026},
|
|
448
|
+
version = {v1.3.0},
|
|
449
|
+
publisher = {GitHub},
|
|
450
|
+
howpublished = {\url{https://github.com/adamm285-dev/Spec-Driven-Cognitive-Scaffolding-SDCS}}
|
|
451
|
+
}
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
* **Author:** Adam Murphy
|
|
455
|
+
* **License:** [MIT](LICENSE)
|
|
456
|
+
* **Contributing:** [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
457
|
+
* **Security Policy:** [SECURITY.md](SECURITY.md)
|