gaia-framework 1.60.0 → 1.62.0
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/CLAUDE.md +1 -1
- package/README.md +1 -1
- package/_gaia/_config/global.yaml +1 -1
- package/_gaia/_config/manifest.yaml +2 -2
- package/_gaia/core/config.yaml +1 -1
- package/_gaia/core/engine/workflow.xml +1 -10
- package/_gaia/lifecycle/config.yaml +1 -1
- package/_gaia/lifecycle/skills/memory-management.md +133 -9
- package/_gaia/lifecycle/workflows/anytime/brownfield-onboarding/instructions.xml +69 -1
- package/gaia-install.sh +1 -1
- package/package.json +1 -1
- package/_gaia/lifecycle/skills/memory-management-cross-agent.md +0 -218
package/CLAUDE.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
# GAIA Framework v1.
|
|
2
|
+
# GAIA Framework v1.62.0
|
|
3
3
|
|
|
4
4
|
This project uses the **GAIA** (Generative Agile Intelligence Architecture) framework — an AI agent framework for Claude Code that orchestrates software product development through 26 specialized agents, 65 workflows, and 8 shared skills.
|
|
5
5
|
|
package/README.md
CHANGED
package/_gaia/core/config.yaml
CHANGED
|
@@ -68,17 +68,8 @@ execution modes (normal/yolo/planning), checkpoints, and quality gates.
|
|
|
68
68
|
<action if="agent is 'dev-*' (wildcard)">Check if workflow.yaml declares agent_auto_detect: true. If true, execute the agent_auto_detect_strategy from workflow.yaml to determine the stack. If auto-detection succeeds, resolve to {project-root}/_gaia/dev/agents/{detected_stack}-dev.md and inform user: "Auto-detected developer: {agent_name} based on {detection_source}." If auto-detection fails or agent_auto_detect is false/absent: ask user which stack developer to use (typescript, angular, flutter, java, python, mobile, go), then resolve to {project-root}/_gaia/dev/agents/{stack}-dev.md</action>
|
|
69
69
|
<action if="agent file resolved">Read the agent persona file — adopt its persona, name, communication style, rules, and domain knowledge for the duration of this workflow</action>
|
|
70
70
|
<action if="agent file resolved">Do NOT execute the agent's activation protocol, greeting, or menu — the workflow engine controls step execution</action>
|
|
71
|
+
<action if="agent file resolved">Do NOT load the agent's memory sidecar — the workflow engine manages its own checkpoints</action>
|
|
71
72
|
<action if="agent file resolved">Check for {project-root}/_gaia/_config/agents/{agent-id}.customize.yaml. If found, load and merge overrides (persona_overrides, menu_additions, menu_removals, skill_additions, rule_additions, skill_overrides, skill_section_overrides). For dev agents, also check all-dev.customize.yaml and merge (agent-specific takes precedence over all-dev).</action>
|
|
72
|
-
|
|
73
|
-
<!-- Memory Load Protocol (E9-S7) — Load agent memory sidecar files after persona, before instructions -->
|
|
74
|
-
<action if="agent file resolved">Read {project-root}/_memory/config.yaml to resolve agent tier and sidecar path. If the file does not exist, log "Memory config not found — skipping memory loading." and skip all remaining memory load actions in this step.</action>
|
|
75
|
-
<action if="agent file resolved">Resolve the agent's tier classification: look up the resolved agent ID in _memory/config.yaml tier lists — check tiers.tier_1.agents, tiers.tier_2.agents, and tiers.tier_3.agents in that order. If the agent ID is not found in any tier list (untiered), treat as Tier 3 by default — load decision-log.md only if it exists, with no budget enforcement.</action>
|
|
76
|
-
<action if="agent file resolved">Resolve sidecar path: read agents.{agent-id}.sidecar from _memory/config.yaml, construct absolute path as {project-root}/_memory/{sidecar_value}/. If the agent entry is not found in the agents section, construct path as {project-root}/_memory/{agent-id}-sidecar/.</action>
|
|
77
|
-
<action if="agent file resolved">Check if the sidecar directory exists. If the directory does not exist or is empty, skip all file loading silently — no error, no warning. Proceed to Step 4.</action>
|
|
78
|
-
<action if="agent file resolved and tier == 1">Load canonical sidecar files (silently skip any that do not exist): ground-truth.md, decision-log.md, conversation-context.md (3 files). These provide the agent's persistent ground truth, decision history, and recent conversation context.</action>
|
|
79
|
-
<action if="agent file resolved and tier == 2">Load canonical sidecar files (silently skip any that do not exist): decision-log.md, conversation-context.md (2 files). Tier 2 agents do not have ground-truth.md.</action>
|
|
80
|
-
<action if="agent file resolved and tier == 3 or untiered">Load canonical sidecar file (silently skip if it does not exist): decision-log.md (1 file). Tier 3 and untiered agents receive minimal memory context.</action>
|
|
81
|
-
<action if="agent file resolved and tier in [1, 2]">Estimate token budget usage: sum the byte lengths of all loaded sidecar files, divide by the token_approximation value (default: 4 chars per token, from _memory/config.yaml archival.token_approximation). Compare against the agent's session_budget from the tier definition in _memory/config.yaml. If usage reaches or exceeds the budget_warn_at threshold (0.8 / 80% from _memory/config.yaml archival.budget_warn_at): display warning "Memory budget at {N}% for {agent_name} — {used}K of {budget}K tokens." For Tier 3 and untiered agents (session_budget: null), skip the token budget check entirely.</action>
|
|
82
73
|
</step>
|
|
83
74
|
|
|
84
75
|
<step n="4" title="Load Instructions">
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
inherits: "{project-root}/_gaia/_config/global.yaml"
|
|
3
3
|
|
|
4
4
|
module_name: "lifecycle"
|
|
5
|
-
module_version: "1.
|
|
5
|
+
module_version: "1.39.0"
|
|
6
6
|
|
|
7
7
|
planning_artifacts: "{project-root}/docs/planning-artifacts"
|
|
8
8
|
implementation_artifacts: "{project-root}/docs/implementation-artifacts"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: memory-management
|
|
3
|
-
version: '1.
|
|
3
|
+
version: '1.0'
|
|
4
4
|
applicable_agents: [all]
|
|
5
|
-
description: '
|
|
5
|
+
description: 'Session load/save, decision formatting, stale detection, deduplication, context summarization'
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
<!-- SECTION: decision-formatting -->
|
|
@@ -96,13 +96,13 @@ Persist agent session data to sidecar files. Agent-agnostic — takes sidecar pa
|
|
|
96
96
|
- Read entire file, replace in memory, write entire file back
|
|
97
97
|
|
|
98
98
|
**Token budget enforcement (before write):**
|
|
99
|
-
-
|
|
100
|
-
-
|
|
101
|
-
-
|
|
102
|
-
-
|
|
103
|
-
-
|
|
99
|
+
- Calculate projected file size after append (current size + new entries size)
|
|
100
|
+
- Approximate tokens: character count / 4
|
|
101
|
+
- If projected size exceeds `tier_budget`: warn with current/max budget and offer options:
|
|
102
|
+
- **Archive oldest entries** — move oldest N entries to `archive/` subdirectory to make room
|
|
103
|
+
- **Force save** — save anyway, exceeding the budget
|
|
104
104
|
- Never silently truncate or block a save operation
|
|
105
|
-
-
|
|
105
|
+
- Warn at 80% of budget ("approaching limit"), warn at 90% ("near limit"), trigger archival prompt at 100%
|
|
106
106
|
<!-- END SECTION -->
|
|
107
107
|
|
|
108
108
|
<!-- SECTION: context-summarization -->
|
|
@@ -195,4 +195,128 @@ Detect and merge duplicate decision entries within a decision log.
|
|
|
195
195
|
**Output:** List of duplicate pairs with recommended action (auto-archive or review).
|
|
196
196
|
<!-- END SECTION -->
|
|
197
197
|
|
|
198
|
-
<!--
|
|
198
|
+
<!-- SECTION: cross-ref-loading -->
|
|
199
|
+
## Cross-Reference Loading (ADR-015)
|
|
200
|
+
|
|
201
|
+
Load another agent's sidecar files as read-only cross-references. All cross-ref loading is JIT (just-in-time) — never preloaded at session start.
|
|
202
|
+
|
|
203
|
+
### Schema: `<memory-reads>` Tag
|
|
204
|
+
|
|
205
|
+
Agent persona files declare cross-references using this XML schema inside the `<agent>` block:
|
|
206
|
+
|
|
207
|
+
```xml
|
|
208
|
+
<memory-reads>
|
|
209
|
+
<cross-ref agent="{agent-id}" file="{file-name}" mode="{recent|full|summary}" required="{true|false}" />
|
|
210
|
+
<!-- Additional cross-ref entries -->
|
|
211
|
+
</memory-reads>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Attributes:**
|
|
215
|
+
- `agent` (required) — the agent ID whose sidecar to read (e.g., "architect", "validator")
|
|
216
|
+
- `file` (required) — the sidecar file to read (e.g., "decision-log", "ground-truth", "conversation-context")
|
|
217
|
+
- `mode` (required) — loading mode: `recent`, `full`, or `summary`
|
|
218
|
+
- `required` (optional, default: "true") — if "false", skip gracefully when the sidecar is absent
|
|
219
|
+
|
|
220
|
+
### Read-Only Access: `load_cross_ref()`
|
|
221
|
+
|
|
222
|
+
Cross-references are loaded through `load_cross_ref()`, which is a **read-only** path — separate from `load_own()` (the agent's own sidecar, which supports read/write).
|
|
223
|
+
|
|
224
|
+
**Parameters:**
|
|
225
|
+
- `sidecar_path` — absolute path to the **target** agent's sidecar directory (e.g., `_memory/architect-sidecar/`)
|
|
226
|
+
- `file_name` — which file to read (e.g., "decision-log.md", "ground-truth.md")
|
|
227
|
+
- `mode` — loading mode: `recent`, `full`, or `summary`
|
|
228
|
+
- `budget_remaining` — remaining token budget for cross-references
|
|
229
|
+
|
|
230
|
+
**Write-Guard:**
|
|
231
|
+
Any attempt to write to a sidecar that is not the current agent's own sidecar MUST raise a **hard error** (not a warning). The write-guard blocks all write operations through `load_cross_ref()`. Only `load_own()` permits writes, and only to the agent's own sidecar directory.
|
|
232
|
+
|
|
233
|
+
**Procedure:**
|
|
234
|
+
1. Validate the target sidecar path is NOT the current agent's own sidecar (self-reference guard — see Validation section below)
|
|
235
|
+
2. Check budget_remaining BEFORE loading — if insufficient, apply progressive downgrade
|
|
236
|
+
3. Read the target file from disk (read-only — no file creation, no modification)
|
|
237
|
+
4. Apply mode filtering (see Loading Modes below)
|
|
238
|
+
5. Return filtered content as read-only data
|
|
239
|
+
|
|
240
|
+
### Loading Modes
|
|
241
|
+
|
|
242
|
+
**`recent` mode** — Load entries from the last 2 sprints only:
|
|
243
|
+
- Parse decision-log entries using ADR-016 format
|
|
244
|
+
- Filter by Sprint field: keep entries where sprint matches current sprint or previous sprint
|
|
245
|
+
- If sprint metadata is absent from entries, fall back to date-based filtering (last 30 days)
|
|
246
|
+
- Approximate token cost: character count / 4
|
|
247
|
+
|
|
248
|
+
**`full` mode** — Load the entire file content:
|
|
249
|
+
- Read full file, respect budget cap
|
|
250
|
+
- If file exceeds budget_remaining: truncate oldest entries first (keep most recent)
|
|
251
|
+
- Approximate token cost: character count / 4
|
|
252
|
+
|
|
253
|
+
**`summary` mode** — Load section headers only:
|
|
254
|
+
- Parse the file for markdown headers (lines starting with `#`, `##`, `###`)
|
|
255
|
+
- Stop at section boundaries — do not load body content
|
|
256
|
+
- Minimal token cost
|
|
257
|
+
|
|
258
|
+
### JIT Loading
|
|
259
|
+
|
|
260
|
+
Cross-references are loaded **just-in-time** during workflow step execution — NOT at agent activation or session start. Loading is triggered only when a workflow step explicitly requires cross-agent context.
|
|
261
|
+
|
|
262
|
+
**Trigger:** The workflow engine checks `<memory-reads>` declarations and loads cross-references only when the current step's execution context requires cross-agent data. No cross-references are preloaded eagerly.
|
|
263
|
+
|
|
264
|
+
### Budget Enforcement
|
|
265
|
+
|
|
266
|
+
**Pre-load budget check:** Before each cross-reference load, calculate:
|
|
267
|
+
- Tokens already consumed by own sidecar
|
|
268
|
+
- Tokens already consumed by previously loaded cross-references
|
|
269
|
+
- Estimated tokens for the next cross-reference (based on mode and file size)
|
|
270
|
+
|
|
271
|
+
**Progressive downgrade chain:** When budget is insufficient for the requested mode:
|
|
272
|
+
1. `full` → downgrade to `recent`
|
|
273
|
+
2. `recent` → downgrade to `summary`
|
|
274
|
+
3. `summary` → downgrade to `skip` (do not load, log warning)
|
|
275
|
+
|
|
276
|
+
Log every downgrade as a warning in the session checkpoint:
|
|
277
|
+
`"Cross-ref downgraded: {agent}/{file} from {original_mode} to {new_mode} — budget {used}/{total}"`
|
|
278
|
+
|
|
279
|
+
**Val's 50% cross-ref budget cap:**
|
|
280
|
+
Val (validator) has a `cross_ref_budget_cap` of 0.5 in `_memory/config.yaml`, meaning cross-references may consume at most 50% of Val's 300K session budget (= 150K tokens max for cross-refs). Val's load priority order: architect → pm → sm. If the 150K cap is hit mid-load, remaining cross-references are downgraded progressively.
|
|
281
|
+
|
|
282
|
+
**Tier budget ceilings:**
|
|
283
|
+
- Tier 1 agents: 300K session budget (own sidecar + cross-refs combined)
|
|
284
|
+
- Tier 2 agents: 100K session budget (own sidecar + cross-refs combined)
|
|
285
|
+
- Tier 3 agents: no explicit budget enforcement
|
|
286
|
+
|
|
287
|
+
### Graceful Error Handling
|
|
288
|
+
|
|
289
|
+
**Missing sidecar directory or file:**
|
|
290
|
+
- If the target sidecar directory does not exist: log a warning ("Cross-ref skipped: {agent} sidecar directory not found"), skip this cross-reference, and continue workflow execution
|
|
291
|
+
- If the target file within the sidecar does not exist: log a warning ("Cross-ref skipped: {agent}/{file} not found"), skip, continue
|
|
292
|
+
|
|
293
|
+
**Malformed or corrupt sidecar files:**
|
|
294
|
+
- If the target file exists but cannot be parsed (malformed markdown, corrupt content, unparseable entries): log a warning ("Cross-ref skipped: {agent}/{file} is malformed"), skip this cross-reference, and continue
|
|
295
|
+
- Never halt the workflow due to a cross-reference loading failure
|
|
296
|
+
|
|
297
|
+
**Absent optional cross-references:**
|
|
298
|
+
- If `<cross-ref required="false">` and the target is absent: skip silently (no warning)
|
|
299
|
+
- If `<cross-ref required="true">` (default) and the target is absent: log warning but still continue
|
|
300
|
+
|
|
301
|
+
### Consistency Validation
|
|
302
|
+
|
|
303
|
+
At session start, validate that agent persona `<memory-reads>` declarations are consistent with `_memory/config.yaml` cross_references matrix:
|
|
304
|
+
|
|
305
|
+
1. Parse the agent's `<memory-reads>` block from the persona file
|
|
306
|
+
2. Load the agent's entry from `_memory/config.yaml` → `cross_references.{agent_id}.reads_from`
|
|
307
|
+
3. Compare: every entry in config.yaml should have a matching `<cross-ref>` in the persona file
|
|
308
|
+
4. If mismatch found: produce a **warning** (not an error) — `_memory/config.yaml` is the authoritative source. The persona file declaration should mirror it.
|
|
309
|
+
|
|
310
|
+
**Self-reference guard:**
|
|
311
|
+
If an agent's `<memory-reads>` declares a `<cross-ref>` where the `agent` attribute matches the current agent's own ID, reject it with a validation error at session start. An agent must not reference its own sidecar as a cross-reference — own-sidecar access is through `load_own()`.
|
|
312
|
+
|
|
313
|
+
### Checkpoint Provenance
|
|
314
|
+
|
|
315
|
+
After loading cross-references, record in the session checkpoint:
|
|
316
|
+
- Which cross-references were loaded (agent, file, mode)
|
|
317
|
+
- File checksums (`shasum -a 256`) of each loaded cross-reference file
|
|
318
|
+
- Any downgrades or skips that occurred
|
|
319
|
+
- Total tokens consumed by cross-references
|
|
320
|
+
|
|
321
|
+
This enables `/gaia-resume` to detect stale cross-references when resuming a session.
|
|
322
|
+
<!-- END SECTION -->
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
/gaia-review-api (optional, if APIs) → /gaia-adversarial → /gaia-test-design → /gaia-test-framework (optional) → /gaia-create-epics → /gaia-threat-model → /gaia-infra-design → /gaia-trace → /gaia-ci-setup → /gaia-readiness-check</action>
|
|
83
83
|
</step>
|
|
84
84
|
|
|
85
|
-
<step n="7" title="Bootstrap
|
|
85
|
+
<step n="7" title="Bootstrap Agent Ground Truth" optional="true">
|
|
86
86
|
<action>Check if Val is installed: verify {project-root}/_gaia/lifecycle/agents/validator.md exists AND {memory_path}/validator-sidecar/ directory exists</action>
|
|
87
87
|
<check if="validator.md not found OR validator-sidecar/ not found">Skip Step 7 silently — Val is not installed. Brownfield onboarding continues without ground truth bootstrap.</check>
|
|
88
88
|
|
|
@@ -102,6 +102,74 @@
|
|
|
102
102
|
|
|
103
103
|
<action>Write extracted project facts to {memory_path}/validator-sidecar/ground-truth.md. If ground-truth.md already exists with content: merge new facts with existing entries — add new facts, update changed facts, flag removed facts — never destructive overwrite. Follow merge semantics from ground-truth-management conflict-resolution section. If ground-truth.md is empty or new: write all extracted facts as initial seed entries with verification count = 1.</action>
|
|
104
104
|
<action>Report: "Seeded {N} ground-truth entries from brownfield artifacts + filesystem scan"</action>
|
|
105
|
+
|
|
106
|
+
<!-- Step 7d/7e/7f: Tier 1 Agent Ground Truth Bootstrap (E9-S12) -->
|
|
107
|
+
|
|
108
|
+
<ask>Bootstrap Tier 1 agent ground truth (Theo, Derek, Nate)? [y/n]</ask>
|
|
109
|
+
|
|
110
|
+
<action>JIT load ground-truth-management skill sections from {project-root}/_gaia/lifecycle/skills/ground-truth-management.md: entry-structure, conflict-resolution, brownfield-extraction. All ground-truth entries must follow the canonical entry format from the entry-structure section. When the same fact appears in multiple source documents with conflicting values (e.g., different version numbers), annotate the entry with "conflicting sources: {source1} says X, {source2} says Y" and use the higher-precedence source (brownfield-assessment.md > project-documentation.md for tech stack facts).</action>
|
|
111
|
+
|
|
112
|
+
<!-- Step 7d: Theo (Architect) ground truth extraction (AC1) -->
|
|
113
|
+
<action>Step 7d — Theo ground truth extraction.
|
|
114
|
+
Read {planning_artifacts}/architecture.md and extract:
|
|
115
|
+
— Tech stack (languages, frameworks, runtime versions) → variable-inventory entries
|
|
116
|
+
— ADRs (architecture decision records — ID, title, status, rationale) → structural-pattern entries
|
|
117
|
+
— Component inventory (modules, packages, services) → file-inventory entries
|
|
118
|
+
— Dependency map (internal and external dependencies) → cross-reference entries
|
|
119
|
+
|
|
120
|
+
If {planning_artifacts}/architecture.md does not exist: fall back to {planning_artifacts}/brownfield-assessment.md for Theo. Extract tech stack, file counts, and project structure from the brownfield assessment instead.
|
|
121
|
+
|
|
122
|
+
Token budget guard: Theo has a 150K token budget (150,000 tokens). Estimate extraction size (characters / 4). If estimated tokens exceed 60% threshold (90,000 tokens), trim to highest-signal entries — prioritize ADRs and tech stack over detailed file inventories.
|
|
123
|
+
|
|
124
|
+
Write extracted entries to {memory_path}/architect-sidecar/ground-truth.md.
|
|
125
|
+
If the {memory_path}/architect-sidecar/ directory does not exist, create it along with a new ground-truth.md file with standard headers.
|
|
126
|
+
If ground-truth.md already exists with content: follow merge semantics from the conflict-resolution section — add new entries, update changed entries, preserve existing entries. Never perform a destructive overwrite.</action>
|
|
127
|
+
|
|
128
|
+
<!-- Step 7e: Derek (Product Manager) ground truth extraction (AC2) -->
|
|
129
|
+
<action>Step 7e — Derek ground truth extraction.
|
|
130
|
+
Read {planning_artifacts}/prd.md and extract:
|
|
131
|
+
— Functional requirements (feature list, requirement IDs) → structural-pattern entries
|
|
132
|
+
— User stories and acceptance criteria summaries → cross-reference entries
|
|
133
|
+
|
|
134
|
+
If {planning_artifacts}/prd.md does not exist: fall back to {planning_artifacts}/prd-brownfield-gaps.md as the alternate PRD path for Derek.
|
|
135
|
+
|
|
136
|
+
Read {planning_artifacts}/epics-and-stories.md and extract for Derek:
|
|
137
|
+
— Epic overview (epic IDs, titles, story counts) → file-inventory entries
|
|
138
|
+
— Story-to-epic mappings → cross-reference entries
|
|
139
|
+
|
|
140
|
+
Read {test_artifacts}/nfr-assessment.md (if present) and extract for Derek:
|
|
141
|
+
— Quality baselines (performance targets, security posture, test coverage) → variable-inventory entries
|
|
142
|
+
If {test_artifacts}/nfr-assessment.md does not exist: log warning "nfr-assessment.md not found in test_artifacts — skipping quality baselines for Derek" and continue without error.
|
|
143
|
+
|
|
144
|
+
Token budget guard: Derek has a 100K token budget (100,000 tokens). Estimate extraction size (characters / 4). If estimated tokens exceed 60% threshold (60,000 tokens), trim to highest-signal entries — prioritize functional requirements and epic summaries over detailed story mappings.
|
|
145
|
+
|
|
146
|
+
Write extracted entries to {memory_path}/pm-sidecar/ground-truth.md.
|
|
147
|
+
If the {memory_path}/pm-sidecar/ directory does not exist, create it along with a new ground-truth.md file with standard headers.
|
|
148
|
+
If ground-truth.md already exists with content: follow merge semantics from the conflict-resolution section — add new entries, update changed entries, preserve existing entries. Never perform a destructive overwrite.</action>
|
|
149
|
+
|
|
150
|
+
<!-- Step 7f: Nate (Scrum Master) ground truth extraction (AC3) -->
|
|
151
|
+
<action>Step 7f — Nate ground truth extraction.
|
|
152
|
+
Read {implementation_artifacts}/sprint-status.yaml (if it exists) and extract for Nate:
|
|
153
|
+
— Current sprint ID, story count, points total → variable-inventory entries
|
|
154
|
+
— Story status distribution → structural-pattern entries
|
|
155
|
+
|
|
156
|
+
Read {memory_path}/sm-sidecar/velocity-data.md (if it exists) and extract for Nate:
|
|
157
|
+
— Velocity history (sprint-over-sprint) → variable-inventory entries
|
|
158
|
+
— Capacity data → variable-inventory entries
|
|
159
|
+
|
|
160
|
+
If neither {implementation_artifacts}/sprint-status.yaml nor {memory_path}/sm-sidecar/velocity-data.md exists: complete this step gracefully with a log message "insufficient sprint data, velocity unavailable" and write ground-truth.md omitting velocity entries. Do not raise an error.
|
|
161
|
+
|
|
162
|
+
Token budget guard: Nate has a 100K token budget (100,000 tokens). Estimate extraction size (characters / 4). If estimated tokens exceed 60% threshold (60,000 tokens), trim to highest-signal entries — prioritize current sprint status over historical velocity data.
|
|
163
|
+
|
|
164
|
+
Write extracted entries to {memory_path}/sm-sidecar/ground-truth.md.
|
|
165
|
+
If the {memory_path}/sm-sidecar/ directory does not exist, create it along with a new ground-truth.md file with standard headers.
|
|
166
|
+
If ground-truth.md already exists with content: follow merge semantics from the conflict-resolution section — add new entries, update changed entries, preserve existing entries. Never perform a destructive overwrite.</action>
|
|
167
|
+
|
|
168
|
+
<!-- Summary report (AC6) -->
|
|
169
|
+
<action>After all Tier 1 extractions complete, output a summary report:
|
|
170
|
+
"Seeded {N} entries for Theo, {M} entries for Derek, {K} entries for Nate"
|
|
171
|
+
If sprint data was absent for Nate, append a note: "(sprint data absent — velocity entries omitted)"
|
|
172
|
+
Include token budget status for each agent (GREEN/YELLOW/RED).</action>
|
|
105
173
|
</step>
|
|
106
174
|
|
|
107
175
|
<next-step command="/gaia-review-api">
|
package/gaia-install.sh
CHANGED
|
@@ -6,7 +6,7 @@ set -euo pipefail
|
|
|
6
6
|
# Installs, updates, validates, and reports on GAIA installations.
|
|
7
7
|
# ─────────────────────────────────────────────────────────────────────────────
|
|
8
8
|
|
|
9
|
-
readonly VERSION="1.
|
|
9
|
+
readonly VERSION="1.62.0"
|
|
10
10
|
readonly GITHUB_REPO="https://github.com/jlouage/Gaia-framework.git"
|
|
11
11
|
readonly MANIFEST_REL="_gaia/_config/manifest.yaml"
|
|
12
12
|
|
package/package.json
CHANGED
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: memory-management-cross-agent
|
|
3
|
-
version: '1.0'
|
|
4
|
-
applicable_agents: [all]
|
|
5
|
-
description: 'Cross-agent memory extensions: cross-reference loading (ADR-015) and budget monitoring (ADR-014). Split from memory-management.md per 300-line skill limit.'
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
<!-- SECTION: cross-reference-loading -->
|
|
9
|
-
## Cross-Reference Loading (ADR-015)
|
|
10
|
-
|
|
11
|
-
Load another agent's sidecar files as read-only cross-references. All cross-ref loading is JIT (just-in-time) — never preloaded at session start.
|
|
12
|
-
|
|
13
|
-
### Schema: `<memory-reads>` Tag
|
|
14
|
-
|
|
15
|
-
Agent persona files declare cross-references using this XML schema inside the `<agent>` block:
|
|
16
|
-
|
|
17
|
-
```xml
|
|
18
|
-
<memory-reads>
|
|
19
|
-
<cross-ref agent="{agent-id}" file="{file-name}" mode="{recent|full|summary}" required="{true|false}" />
|
|
20
|
-
</memory-reads>
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
**Attributes:**
|
|
24
|
-
- `agent` (required) — the agent ID whose sidecar to read (e.g., "architect", "validator")
|
|
25
|
-
- `file` (required) — the sidecar file to read (e.g., "decision-log", "ground-truth", "conversation-context")
|
|
26
|
-
- `mode` (required) — loading mode: `recent`, `full`, or `summary`
|
|
27
|
-
- `required` (optional, default: "true") — if "false", skip gracefully when the sidecar is absent
|
|
28
|
-
|
|
29
|
-
### Read-Only Access: `load_cross_ref()`
|
|
30
|
-
|
|
31
|
-
Cross-references are loaded through `load_cross_ref()`, which is a **read-only** path — separate from `load_own()` (the agent's own sidecar, which supports read/write).
|
|
32
|
-
|
|
33
|
-
**Parameters:**
|
|
34
|
-
- `sidecar_path` — absolute path to the **target** agent's sidecar directory (e.g., `_memory/architect-sidecar/`)
|
|
35
|
-
- `file_name` — which file to read (e.g., "decision-log.md", "ground-truth.md")
|
|
36
|
-
- `mode` — loading mode: `recent`, `full`, or `summary`
|
|
37
|
-
- `budget_remaining` — remaining token budget for cross-references
|
|
38
|
-
|
|
39
|
-
**Write-Guard:**
|
|
40
|
-
Any attempt to write to a sidecar that is not the current agent's own sidecar MUST raise a **hard error** (not a warning). The write-guard blocks all write operations through `load_cross_ref()`. Only `load_own()` permits writes, and only to the agent's own sidecar directory.
|
|
41
|
-
|
|
42
|
-
**Procedure:**
|
|
43
|
-
1. Validate the target sidecar path is NOT the current agent's own sidecar (self-reference guard)
|
|
44
|
-
2. Check budget_remaining BEFORE loading — if insufficient, apply progressive downgrade
|
|
45
|
-
3. Read the target file from disk (read-only — no file creation, no modification)
|
|
46
|
-
4. Apply mode filtering (see Loading Modes below)
|
|
47
|
-
5. Calculate token estimate: character count / 4 (using `token_approximation` from `_memory/config.yaml`)
|
|
48
|
-
6. Return filtered content as read-only data with token estimate for caller budget deduction
|
|
49
|
-
|
|
50
|
-
### Loading Modes
|
|
51
|
-
|
|
52
|
-
**`recent` mode** — Load entries from the last 2 sprints only:
|
|
53
|
-
- Parse decision-log entries using ADR-016 format
|
|
54
|
-
- Filter by Sprint field: keep entries where sprint matches current sprint or previous sprint
|
|
55
|
-
- If sprint metadata is absent from entries, fall back to date-based filtering (last 30 days)
|
|
56
|
-
- Approximate token cost: character count / 4
|
|
57
|
-
|
|
58
|
-
**`full` mode** — Load the entire file content:
|
|
59
|
-
- Read full file, respect budget cap
|
|
60
|
-
- If file exceeds budget_remaining: truncate oldest entries first (keep most recent)
|
|
61
|
-
- Approximate token cost: character count / 4
|
|
62
|
-
|
|
63
|
-
**`summary` mode** — Load section headers only:
|
|
64
|
-
- Parse the file for markdown headers (lines starting with `#`, `##`, `###`)
|
|
65
|
-
- Stop at section boundaries — do not load body content
|
|
66
|
-
- Minimal token cost
|
|
67
|
-
|
|
68
|
-
### JIT Loading
|
|
69
|
-
|
|
70
|
-
Cross-references are loaded **just-in-time** during workflow step execution — NOT at agent activation or session start. Loading is triggered only when a workflow step explicitly requires cross-agent context.
|
|
71
|
-
|
|
72
|
-
**Trigger:** The workflow engine checks `<memory-reads>` declarations and loads cross-references only when the current step's execution context requires cross-agent data. No cross-references are preloaded eagerly.
|
|
73
|
-
|
|
74
|
-
### Budget Enforcement
|
|
75
|
-
|
|
76
|
-
**Pre-load budget check:** Before each cross-reference load, calculate:
|
|
77
|
-
- Tokens already consumed by own sidecar
|
|
78
|
-
- Tokens already consumed by previously loaded cross-references
|
|
79
|
-
- Estimated tokens for the next cross-reference (based on mode and file size)
|
|
80
|
-
|
|
81
|
-
**Per-agent `cross_ref_budget_cap`:** Some agents have a `cross_ref_budget_cap` in `_memory/config.yaml` (e.g., validator: 0.5). This caps cross-reference token consumption at that fraction of the agent's session budget. If loading would exceed the cap, halt loading and downgrade remaining cross-refs progressively.
|
|
82
|
-
|
|
83
|
-
**Progressive downgrade chain:** When budget is insufficient for the requested mode:
|
|
84
|
-
1. `full` → downgrade to `recent`
|
|
85
|
-
2. `recent` → downgrade to `summary`
|
|
86
|
-
3. `summary` → downgrade to `skip` (do not load, log warning)
|
|
87
|
-
|
|
88
|
-
Log every downgrade as a warning in the session checkpoint:
|
|
89
|
-
`"Cross-ref downgraded: {agent}/{file} from {original_mode} to {new_mode} — budget {used}/{total}"`
|
|
90
|
-
|
|
91
|
-
**Val's 50% cross-ref budget cap:**
|
|
92
|
-
Val (validator) has a `cross_ref_budget_cap` of 0.5 in `_memory/config.yaml`, meaning cross-references may consume at most 50% of Val's 300K session budget (= 150K tokens max for cross-refs). Val's load priority order: architect, pm, sm. If the 150K cap is hit mid-load, remaining cross-references are downgraded progressively.
|
|
93
|
-
|
|
94
|
-
**Tier budget ceilings:**
|
|
95
|
-
- Tier 1 agents: 300K session budget (own sidecar + cross-refs combined)
|
|
96
|
-
- Tier 2 agents: 100K session budget (own sidecar + cross-refs combined)
|
|
97
|
-
- Tier 3 agents: no explicit budget enforcement
|
|
98
|
-
|
|
99
|
-
### Graceful Error Handling
|
|
100
|
-
|
|
101
|
-
**Missing sidecar directory or file:**
|
|
102
|
-
- If the target sidecar directory does not exist: log a warning ("Cross-ref skipped: {agent} sidecar directory not found"), skip this cross-reference, and continue workflow execution without error
|
|
103
|
-
- If the target file within the sidecar does not exist: log a warning ("Cross-ref skipped: {agent}/{file} not found"), skip, continue
|
|
104
|
-
|
|
105
|
-
**Empty sidecar directory:**
|
|
106
|
-
- If the target sidecar directory exists but contains no files: return empty result gracefully with no error — matching the contract of the `session-load` section
|
|
107
|
-
|
|
108
|
-
**Malformed or corrupt sidecar files:**
|
|
109
|
-
- If the target file exists but cannot be parsed (malformed markdown, corrupt content, unparseable entries): log a warning ("Cross-ref skipped: {agent}/{file} is malformed"), skip this cross-reference, and continue
|
|
110
|
-
- Never halt the workflow due to a cross-reference loading failure
|
|
111
|
-
|
|
112
|
-
**Absent optional cross-references:**
|
|
113
|
-
- If `<cross-ref required="false">` and the target is absent: skip silently (no warning)
|
|
114
|
-
- If `<cross-ref required="true">` (default) and the target is absent: log warning but still continue
|
|
115
|
-
|
|
116
|
-
**Agent not in cross-reference matrix:**
|
|
117
|
-
- If the calling agent has no entry in `_memory/config.yaml` `cross_references`, return empty result with no error
|
|
118
|
-
|
|
119
|
-
### Consistency Validation
|
|
120
|
-
|
|
121
|
-
At session start, validate that agent persona `<memory-reads>` declarations are consistent with `_memory/config.yaml` cross_references matrix:
|
|
122
|
-
|
|
123
|
-
1. Parse the agent's `<memory-reads>` block from the persona file
|
|
124
|
-
2. Load the agent's entry from `_memory/config.yaml` → `cross_references.{agent_id}.reads_from`
|
|
125
|
-
3. Compare: every entry in config.yaml should have a matching `<cross-ref>` in the persona file
|
|
126
|
-
4. If mismatch found: produce a **warning** (not an error) — `_memory/config.yaml` is the authoritative source
|
|
127
|
-
|
|
128
|
-
**Self-reference guard:**
|
|
129
|
-
If an agent's `<memory-reads>` declares a `<cross-ref>` where the `agent` attribute matches the current agent's own ID, reject it with a validation error at session start. An agent must not reference its own sidecar as a cross-reference — own-sidecar access is through `load_own()`.
|
|
130
|
-
|
|
131
|
-
### Checkpoint Provenance
|
|
132
|
-
|
|
133
|
-
After loading cross-references, record in the session checkpoint:
|
|
134
|
-
- Which cross-references were loaded (agent, file, mode)
|
|
135
|
-
- File checksums (`shasum -a 256`) of each loaded cross-reference file
|
|
136
|
-
- Any downgrades or skips that occurred
|
|
137
|
-
- Total tokens consumed by cross-references
|
|
138
|
-
|
|
139
|
-
This enables `/gaia-resume` to detect stale cross-references when resuming a session.
|
|
140
|
-
<!-- END SECTION -->
|
|
141
|
-
|
|
142
|
-
<!-- SECTION: budget-monitoring -->
|
|
143
|
-
## Budget Monitoring (ADR-014)
|
|
144
|
-
|
|
145
|
-
Shared utility for checking token budget usage against tier-defined thresholds. Used by `session-save` and other memory operations to determine when archival is needed.
|
|
146
|
-
|
|
147
|
-
### Parameters
|
|
148
|
-
|
|
149
|
-
- `sidecar_path` — absolute path to the agent's sidecar directory
|
|
150
|
-
- `tier_budget` — session token budget for this agent's tier (from `_memory/config.yaml`). If null or absent, the agent is untiered.
|
|
151
|
-
- `current_usage` — current token count (own sidecar files + cross-refs loaded in this session)
|
|
152
|
-
- `projected_addition` — token count of content about to be written/loaded
|
|
153
|
-
|
|
154
|
-
### Threshold Definitions (config-driven)
|
|
155
|
-
|
|
156
|
-
All thresholds are read from `_memory/config.yaml` `archival` block at runtime. Never hardcode these values.
|
|
157
|
-
|
|
158
|
-
- `budget_warn_at` — fraction of budget at which a warning is returned (e.g., 0.8 = 80%)
|
|
159
|
-
- `budget_alert_at` — fraction of budget at which an alert is returned (e.g., 0.9 = 90%)
|
|
160
|
-
- `budget_archive_at` — fraction of budget at which archival is triggered (e.g., 1.0 = 100%)
|
|
161
|
-
- `token_approximation` — characters per token for size estimation (e.g., 4)
|
|
162
|
-
- `archive_subdir` — subdirectory name within sidecar for archived entries (e.g., "archive")
|
|
163
|
-
|
|
164
|
-
### Procedure
|
|
165
|
-
|
|
166
|
-
1. Read `_memory/config.yaml` archival block to get threshold values
|
|
167
|
-
2. Calculate `projected_total = current_usage + projected_addition`
|
|
168
|
-
3. Calculate `usage_ratio = projected_total / tier_budget`
|
|
169
|
-
4. Return threshold status:
|
|
170
|
-
- `usage_ratio < budget_warn_at` → status: `ok` (no action needed)
|
|
171
|
-
- `usage_ratio >= budget_warn_at AND < budget_alert_at` → status: `warn` ("approaching budget limit")
|
|
172
|
-
- `usage_ratio >= budget_alert_at AND < budget_archive_at` → status: `alert` ("near budget limit")
|
|
173
|
-
- `usage_ratio >= budget_archive_at` → status: `archive_needed` ("budget exceeded, archival required")
|
|
174
|
-
|
|
175
|
-
### Archival Protocol
|
|
176
|
-
|
|
177
|
-
When status is `archive_needed`:
|
|
178
|
-
1. Identify the oldest N entries in `decision-log.md` that would free sufficient tokens
|
|
179
|
-
2. Move those entries to `{sidecar_path}/{archive_subdir}/` (e.g., `_memory/architect-sidecar/archive/`)
|
|
180
|
-
3. Create the archive subdirectory if it does not exist (`mkdir -p`)
|
|
181
|
-
4. Use atomic read-modify-write pattern: read full file, remove archived entries, write full file back
|
|
182
|
-
5. Re-check budget after archival — if still over budget, archive more entries (up to 3 iterations)
|
|
183
|
-
6. Archive subdirectory is gitignored — archived entries are historical, not version-controlled
|
|
184
|
-
|
|
185
|
-
### Token Estimation
|
|
186
|
-
|
|
187
|
-
Token count is approximated using the `token_approximation` value from `_memory/config.yaml` (default: 4 chars per token). No tokenizer library is used — this aligns with ADR-005 (zero runtime dependencies).
|
|
188
|
-
|
|
189
|
-
Formula: `tokens = character_count / token_approximation`
|
|
190
|
-
|
|
191
|
-
### Running Session Total
|
|
192
|
-
|
|
193
|
-
Track cumulative token usage across the session:
|
|
194
|
-
- Own sidecar files loaded via `session-load`
|
|
195
|
-
- Cross-references loaded via `cross-reference-loading`
|
|
196
|
-
- New entries being written via `session-save`
|
|
197
|
-
|
|
198
|
-
The combined total is checked against the tier budget ceiling.
|
|
199
|
-
|
|
200
|
-
### Untiered Agent Handling
|
|
201
|
-
|
|
202
|
-
If `tier_budget` is null, absent, or the agent has no tier assignment in `_memory/config.yaml` (applies to 9 untiered agents: analyst, data-engineer, performance, ux-designer, brainstorming-coach, design-thinking-coach, innovation-strategist, presentation-designer, problem-solver):
|
|
203
|
-
- Skip all budget enforcement — no threshold checks, no archival trigger
|
|
204
|
-
- Return status: `no_budget` with no error
|
|
205
|
-
- This is a no-op: the caller proceeds without any budget constraint
|
|
206
|
-
- Never raise an error for untiered agents
|
|
207
|
-
|
|
208
|
-
### Return Value
|
|
209
|
-
|
|
210
|
-
```yaml
|
|
211
|
-
status: ok | warn | alert | archive_needed | no_budget
|
|
212
|
-
usage_ratio: 0.75 # current usage as fraction of budget (null if no_budget)
|
|
213
|
-
tokens_used: 225000 # current token count (null if no_budget)
|
|
214
|
-
tokens_budget: 300000 # tier budget ceiling (null if no_budget)
|
|
215
|
-
tokens_projected: 230000 # projected total after addition (null if no_budget)
|
|
216
|
-
message: "Budget at 75% — no action needed"
|
|
217
|
-
```
|
|
218
|
-
<!-- END SECTION -->
|