gemstack-ai 1.0.1 → 1.1.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/.agents/rules/01-gemstack-core.md +15 -0
- package/.agents/rules/02-gemstack-constitution.md +12 -1
- package/.agents/skills/gemstack-handoff/SKILL.md +2 -1
- package/.agents/skills/gemstack-plan/SKILL.md +2 -1
- package/.agents/skills/gemstack-review/SKILL.md +7 -5
- package/.agents/skills/gemstack-ship/SKILL.md +5 -0
- package/.agents/skills/gemstack-spec/SKILL.md +3 -2
- package/.agents/skills/gemstack-tasks/SKILL.md +4 -3
- package/.gemstack/state.json +20 -2
- package/CHANGELOG.md +52 -0
- package/MANUAL.md +4 -4
- package/README.md +36 -8
- package/RELEASE_NOTES.md +105 -0
- package/assets/logo.jpg +0 -0
- package/docs/architecture-consistency.md +144 -0
- package/gemstack-ai-1.1.2.tgz +0 -0
- package/handoff.md +27 -40
- package/package.json +3 -2
- package/scripts/ci/smoke-cli.js +1 -0
- package/specs/006-architecture-consistency-engine/.gemstack.json +9 -0
- package/specs/006-architecture-consistency-engine/plan.md +319 -0
- package/specs/006-architecture-consistency-engine/spec.md +179 -0
- package/specs/006-architecture-consistency-engine/tasks.md +532 -0
- package/specs/templates/plan.md +11 -0
- package/specs/templates/spec.md +17 -0
- package/specs/templates/tasks.md +1 -0
- package/src/cli.js +9 -4
- package/src/commands/verify.js +311 -0
- package/src/lib/contracts.js +388 -0
- package/src/lib/findings.js +227 -0
- package/src/lib/hasher.js +103 -0
- package/src/lib/state.js +143 -0
- package/src/mcp-server.js +1 -1
- package/template/.agents/rules/01-gemstack-core.md +15 -0
- package/template/.agents/rules/02-gemstack-constitution.md +12 -1
- package/template/.agents/skills/gemstack-handoff/SKILL.md +2 -1
- package/template/.agents/skills/gemstack-plan/SKILL.md +2 -1
- package/template/.agents/skills/gemstack-review/SKILL.md +7 -5
- package/template/.agents/skills/gemstack-ship/SKILL.md +5 -0
- package/template/.agents/skills/gemstack-spec/SKILL.md +3 -2
- package/template/.agents/skills/gemstack-tasks/SKILL.md +4 -3
- package/template/docs/architecture-consistency.md +144 -0
- package/template/specs/templates/plan.md +11 -0
- package/template/specs/templates/spec.md +17 -0
- package/template/specs/templates/tasks.md +1 -0
- package/gemstack-ai-1.0.1.tgz +0 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# Architecture Consistency & Phase Freezing
|
|
2
|
+
|
|
3
|
+
Gemstack includes a native, deterministic **Architecture Consistency Engine** and **Phase Freezing** protocol. It prevents AI agents from silently introducing contradictions, architectural drift, or unauthorized mutations across the Spec-Driven Development lifecycle.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. The Architecture Consistency Problem
|
|
8
|
+
|
|
9
|
+
In complex AI coding projects, language models often agree to constraints in a specification (such as "zero external dependencies" or "single tenant isolation"), but later quietly contradict them in implementation or tasks (e.g. installing unauthorized packages).
|
|
10
|
+
|
|
11
|
+
Gemstack solves this mechanically at the framework layer:
|
|
12
|
+
1. Architectural decisions are declared as formal, machine-verifiable **contracts**.
|
|
13
|
+
2. Upstream phases (`SPEC`, `PLAN`, `TASKS`) are cryptographically **frozen**.
|
|
14
|
+
3. Downstream phases inherit contracts and are mechanically compared for contradictions.
|
|
15
|
+
4. Any contradiction or mutation immediately halts execution as a deterministic blocker.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 2. Canonical Contract Block Format
|
|
20
|
+
|
|
21
|
+
Contracts are declared inside phase markdown files (`spec.md`, `plan.md`, `tasks.md`) within a column-0 fenced code block:
|
|
22
|
+
|
|
23
|
+
```gemstack-contracts
|
|
24
|
+
[
|
|
25
|
+
{
|
|
26
|
+
"id": "zero-dependency-core",
|
|
27
|
+
"type": "BOOLEAN_INVARIANT",
|
|
28
|
+
"value": true
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"id": "database-engine",
|
|
32
|
+
"type": "ENUM_SET",
|
|
33
|
+
"values": ["sqlite", "postgres"]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"id": "external-sync",
|
|
37
|
+
"type": "BOUNDARY",
|
|
38
|
+
"value": "FORBIDDEN"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Block Parsing Rules
|
|
44
|
+
- **Exactly One Block**: Each phase document may contain at most one `gemstack-contracts` block. Multiple blocks trigger a `CONTRACT_PARSE_ERROR`.
|
|
45
|
+
- **Legacy Mode**: Phase documents with 0 contract blocks operate in **LEGACY** mode without errors or blocking.
|
|
46
|
+
- **Strict Encoding**: UTF-8 without BOM is required; CRLF and LF line endings are canonically normalized to LF.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 3. The Six Canonical Contract Types
|
|
51
|
+
|
|
52
|
+
Gemstack enforces six deterministic contract types:
|
|
53
|
+
|
|
54
|
+
| Contract Type | Value Shape | Description / Evaluation |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| `ENUM_SET` | `values: string[]` | Closed set of allowed identifiers. Order-insensitive. Downstream cannot add unapproved values. |
|
|
57
|
+
| `IDENTITY_TUPLE` | `tuple: string[]` | Immutable composite tuple. Order-insensitive, duplicate-sensitive, exact-member matching. |
|
|
58
|
+
| `PROVENANCE_RULE` | `source: string, rule: string` | Origin and lineage constraints. Downstream cannot omit or alter provenance. |
|
|
59
|
+
| `BOOLEAN_INVARIANT` | `value: boolean` | Strict binary invariant (e.g. `true` for zero-dependency). Downstream contradiction is blocked. |
|
|
60
|
+
| `BOUNDARY` | `value: "FORBIDDEN" | "REQUIRED"` | Hard system boundary. Only `FORBIDDEN` and `REQUIRED` are valid. |
|
|
61
|
+
| `ROADMAP_LIMIT` | `value: string | number` | Milestone or scope bound (e.g. max task count). Downstream cannot expand beyond the limit. |
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 4. Cross-Phase Contract Inheritance
|
|
66
|
+
|
|
67
|
+
Contracts follow a strict unidirectional inheritance hierarchy:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
SPEC (declares base contracts)
|
|
71
|
+
│
|
|
72
|
+
▼
|
|
73
|
+
PLAN (inherits SPEC contracts + may add technical contracts)
|
|
74
|
+
│
|
|
75
|
+
▼
|
|
76
|
+
TASKS (inherits consolidated SPEC + PLAN contracts)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- **Inheritance**: Downstream phases automatically inherit all upstream contracts. An inherited contract does not need to be re-declared downstream unless adding specific attributes.
|
|
80
|
+
- **Equivalence**: Redeclaring an inherited contract with identical semantics passes validation.
|
|
81
|
+
- **Contradiction**: Redeclaring an inherited contract with contradictory values triggers `FROZEN_CONTRACT_VIOLATION` and blocks execution.
|
|
82
|
+
- **Additive Extension**: Downstream phases may introduce new contract IDs as long as they do not conflict with existing contracts.
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## 5. Phase Freezing & Mutation Detection
|
|
87
|
+
|
|
88
|
+
When a phase is completed and approved by the human supervisor, its artifact is cryptographically sealed:
|
|
89
|
+
- **Canonical Hash**: Normalized SHA-256 (64 lowercase hexadecimal characters).
|
|
90
|
+
- **CRLF Normalization**: All line breaks are normalized to LF (`\n`) prior to hashing, ensuring identical digests across Windows, macOS, and Linux.
|
|
91
|
+
- **UTF-8 BOM Forbidden**: Leading Byte Order Marks trigger `CONTRACT_PARSE_ERROR`.
|
|
92
|
+
- **Mutation Detection**: If an upstream artifact (`spec.md` or `plan.md`) is modified after approval, `gemstack verify` detects the hash mismatch and halts with `FROZEN_ARTIFACT_CHANGED`.
|
|
93
|
+
|
|
94
|
+
> **VERIFY != FREEZE**: `gemstack verify`, `gemstack doctor`, and agent reviews are strictly read-only and **never** overwrite or mutate accepted phase hashes.
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 6. Findings & Anti-Loop Lifecycle
|
|
99
|
+
|
|
100
|
+
When a consistency rule is violated, Gemstack generates a structured **Finding**:
|
|
101
|
+
- **Canonical Fingerprint**: Full 64-character lowercase SHA-256 digest computed over `{ code, contractId, phase, location }`.
|
|
102
|
+
- **Display Token**: First 12 characters of the fingerprint for human-readable CLI display.
|
|
103
|
+
- **Finding Lifecycle**:
|
|
104
|
+
- `OPEN`: Active blocker preventing shipping.
|
|
105
|
+
- `RESOLVED`: Violation was corrected in artifacts.
|
|
106
|
+
- `ACCEPTED_EXCEPTION`: Formally approved human exception.
|
|
107
|
+
- `SUPERSEDED`: Replaced by a subsequent finding.
|
|
108
|
+
- **Anti-Loop Protection**: If a previously `RESOLVED` defect re-appears in subsequent runs, it is immediately re-opened to `OPEN`.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 7. Accepted Exceptions & Context Hash
|
|
113
|
+
|
|
114
|
+
When an architectural deviation is intentionally approved by a human supervisor, it is recorded in the feature sidecar with a cryptographic `contextHash`:
|
|
115
|
+
|
|
116
|
+
`contextHash = SHA-256(upstreamAcceptedHash + currentComparedHash + normalizedContract)`
|
|
117
|
+
|
|
118
|
+
If the upstream phase artifact, compared phase artifact, or contract representation changes, the suppression is automatically invalidated and the violation re-opens as a blocking finding.
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
## 8. State & Persistence Boundary
|
|
123
|
+
|
|
124
|
+
Gemstack strictly separates operational state from historical audit trails:
|
|
125
|
+
- **`.gemstack/state.json`**: Lightweight operational state only (active feature, completed phases, guard mode, verification summary). Historical finding arrays are forbidden in this file.
|
|
126
|
+
- **`specs/<feature>/.gemstack.json`**: Per-feature sidecar hosting the complete audit log, phase hash history, finding fingerprints, and accepted exceptions.
|
|
127
|
+
- **Atomic Operations**: All state writes use temporary file creation and atomic file renaming to prevent corruption during unexpected shutdowns or process kills.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 9. Verification Integration (`gemstack verify`)
|
|
132
|
+
|
|
133
|
+
Architectural consistency is embedded as **Step 4/5** in the unified `gemstack verify` command:
|
|
134
|
+
|
|
135
|
+
```text
|
|
136
|
+
[INFO] --- 4/5 Verificación de Consistencia de Arquitectura y Hashes de Fase ---
|
|
137
|
+
[OK] [STRUCTURED] 5 contrato(s) base declarados en spec.md.
|
|
138
|
+
[OK] Hash congelado de spec.md verificado: f5d423eaf508...
|
|
139
|
+
[OK] Hash congelado de plan.md verificado: 1ce0e5886342...
|
|
140
|
+
[OK] Hash congelado de tasks.md verificado: dfad2484ad11...
|
|
141
|
+
[OK] Verificación de consistencia arquitectónica aprobada (0 bloqueadores).
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
If any contracts contradict, artifacts mutate, or unapproved blockers exist, `gemstack verify` exits with code 1, halting CI/CD pipelines.
|
|
@@ -36,3 +36,14 @@ ruta/archivo: [Razón]
|
|
|
36
36
|
| Violación de Regla | Por qué es necesario | Alternativa simple rechazada por |
|
|
37
37
|
|--------------------|----------------------|-----------------------------------|
|
|
38
38
|
| [Ej. Wrapper] | [Razón] | [Razón] |
|
|
39
|
+
|
|
40
|
+
## 6. Contratos Aditivos del Plan (Opcional - Upgrade A)
|
|
41
|
+
<!--
|
|
42
|
+
Hereda automáticamente los contratos de spec.md.
|
|
43
|
+
Si se requieren contratos técnicos adicionales compatibles, declararlos aquí en un bloque canónico.
|
|
44
|
+
No modifiques contratos de spec sin aprobación explícita de enmienda.
|
|
45
|
+
-->
|
|
46
|
+
```gemstack-contracts
|
|
47
|
+
[
|
|
48
|
+
]
|
|
49
|
+
```
|
|
@@ -33,3 +33,20 @@
|
|
|
33
33
|
## 5. Entidades Clave (Data / Models)
|
|
34
34
|
- **[Entidad 1]**: [Representación abstracta]
|
|
35
35
|
- **[Entidad 2]**: [Relación]
|
|
36
|
+
|
|
37
|
+
## 6. Contratos Arquitectónicos Congelados (Opcional - Upgrade A)
|
|
38
|
+
<!--
|
|
39
|
+
Declara decisiones arquitectónicas congeladas usando el bloque canónico.
|
|
40
|
+
Tipos soportados: ENUM_SET, IDENTITY_TUPLE, PROVENANCE_RULE, BOOLEAN_INVARIANT, BOUNDARY, ROADMAP_LIMIT.
|
|
41
|
+
Si no se incluye este bloque, la feature operará en modo LEGACY.
|
|
42
|
+
-->
|
|
43
|
+
```gemstack-contracts
|
|
44
|
+
[
|
|
45
|
+
{
|
|
46
|
+
"id": "feature-invariants",
|
|
47
|
+
"type": "BOOLEAN_INVARIANT",
|
|
48
|
+
"value": true,
|
|
49
|
+
"description": "Invariante principal congelada para este feature"
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
```
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
Instrucciones:
|
|
5
5
|
- Marca con `[P]` las tareas que sean seguras de paralelizar (por ej. si usas múltiples subagentes).
|
|
6
6
|
- Incluye la redacción y validación de TESTS ANTES de la implementación real.
|
|
7
|
+
- Hereda los contratos congelados de SPEC y PLAN por defecto (no se requiere bloque de contratos).
|
|
7
8
|
-->
|
|
8
9
|
|
|
9
10
|
## Fase 1: Tests (Test-First Imperative)
|
package/gemstack-ai-1.0.1.tgz
DELETED
|
Binary file
|