Skip to content

Commit 822f330

Browse files
docs: consolidate 5 uncovered spec files into dev.md (v3.9) (#21485)
1 parent 4b15992 commit 822f330

1 file changed

Lines changed: 208 additions & 2 deletions

File tree

scratchpad/dev.md

Lines changed: 208 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Developer Instructions
22

3-
**Version**: 3.8
4-
**Last Updated**: 2026-03-06
3+
**Version**: 3.9
4+
**Last Updated**: 2026-03-18
55
**Purpose**: Consolidated development guidelines for GitHub Agentic Workflows
66

77
This document consolidates specifications from the scratchpad directory into unified developer instructions. It provides architecture patterns, security guidelines, code organization rules, and testing practices.
@@ -20,6 +20,8 @@ This document consolidates specifications from the scratchpad directory into uni
2020
- [MCP Integration](#mcp-integration)
2121
- [Go Type Patterns](#go-type-patterns)
2222
- [Quick Reference](#quick-reference)
23+
- [Repo Memory](#repo-memory)
24+
- [Release Management](#release-management)
2325
- [Additional Resources](#additional-resources)
2426

2527
---
@@ -313,6 +315,37 @@ maybe_needed_utils.go
313315

314316
**Solution**: Wait until 2-3 use cases emerge, then extract common patterns.
315317

318+
### String Processing: Sanitize vs Normalize
319+
320+
The codebase uses two distinct patterns for string transformation:
321+
322+
| Pattern | Purpose | Functions |
323+
|---------|---------|-----------|
324+
| **Sanitize** | Remove/replace invalid characters | `SanitizeName()`, `SanitizeWorkflowName()`, `SanitizeIdentifier()` |
325+
| **Normalize** | Standardize format | `normalizeWorkflowName()`, `normalizeSafeOutputIdentifier()` |
326+
327+
**Decision rule**:
328+
- Use **sanitize** when input may contain invalid characters (user input, artifact names, file paths)
329+
- Use **normalize** when converting between valid representations (file extensions, naming conventions)
330+
331+
```go
332+
// SANITIZE: User input → valid identifier
333+
sanitized := SanitizeIdentifier("My Workflow: Test/Build")
334+
// Returns: "my-workflow-test-build"
335+
336+
// NORMALIZE: File name → workflow ID (remove extension)
337+
normalized := normalizeWorkflowName("weekly-research.md")
338+
// Returns: "weekly-research"
339+
340+
// NORMALIZE: safe output identifier (dashes → underscores)
341+
normalized := normalizeSafeOutputIdentifier("create-issue")
342+
// Returns: "create_issue"
343+
```
344+
345+
**Anti-pattern**: Do not sanitize already-normalized strings. `normalizeWorkflowName` output is already valid — additional sanitization is unnecessary processing.
346+
347+
See `scratchpad/string-sanitization-normalization.md` for full function reference and decision tree.
348+
316349
---
317350

318351
## Validation Architecture
@@ -484,6 +517,35 @@ func validateIssueConfig(cfg CreateIssueConfig) error {
484517
}
485518
```
486519

520+
### Validation File Refactoring
521+
522+
Large validation files should be split into focused, single-responsibility validators when they exceed complexity thresholds.
523+
524+
**Thresholds**:
525+
- **Target**: 100-200 lines per file
526+
- **Acceptable**: 200-300 lines
527+
- **Refactor required**: 300+ lines, or 2+ unrelated validation domains in one file
528+
529+
**Naming convention**: `{domain}_{subdomain}_validation.go`
530+
531+
**Logger convention** (one per file):
532+
```go
533+
var bundlerSafetyLog = logger.New("workflow:bundler_safety_validation")
534+
```
535+
536+
**Refactoring process**:
537+
1. Group existing functions by domain
538+
2. Create new files with domain-specific package headers and loggers
539+
3. Move functions preserving signatures
540+
4. Split test files to match the new structure (one test file per validation file)
541+
5. Update `validation.go` package documentation to reference new files
542+
543+
**Shared helpers**: If a helper is used by only one domain, keep it in that domain's file. If used equally across domains, create `{domain}_helpers.go`.
544+
545+
See `scratchpad/validation-refactoring.md` for a complete step-by-step guide using the `bundler_validation.go` split as a reference implementation.
546+
547+
---
548+
487549
### YAML Parser Compatibility
488550

489551
GitHub Agentic Workflows uses **`goccy/go-yaml` v1.18.0** (YAML 1.2 compliant parser). This affects validation behavior and tool integration.
@@ -2088,6 +2150,144 @@ type Everything interface {
20882150

20892151
---
20902152

2153+
## Repo Memory
2154+
2155+
Repo Memory provides persistent, git-backed storage for AI agents across workflow runs. Agents read and write files in `/tmp/gh-aw/repo-memory/{id}/`, which are automatically committed to a `memory/{id}` branch after each job.
2156+
2157+
### Data Flow
2158+
2159+
```mermaid
2160+
graph TD
2161+
A[Agent Job Start] --> B[Clone memory/{id} branch]
2162+
B --> C[Agent reads/writes /tmp/gh-aw/repo-memory/{id}/]
2163+
C --> D[Upload artifact: repo-memory-{id}]
2164+
D --> E[Push Repo Memory Job]
2165+
E --> F[Download artifact]
2166+
F --> G[Validate: size, count, patch]
2167+
G --> H[Commit and push to memory/{id} branch]
2168+
```
2169+
2170+
### Path Conventions
2171+
2172+
| Layer | Pattern | Example |
2173+
|-------|---------|---------|
2174+
| Runtime directory | `/tmp/gh-aw/repo-memory/{id}` | `/tmp/gh-aw/repo-memory/default` |
2175+
| Artifact name | `repo-memory-{id}` | `repo-memory-default` |
2176+
| Git branch | `memory/{id}` | `memory/default` |
2177+
| Prompt path | `/tmp/gh-aw/repo-memory/{id}/` | `/tmp/gh-aw/repo-memory/default/` |
2178+
2179+
The prompt path always includes a trailing slash to indicate a directory for agent file operations.
2180+
2181+
**File glob patterns** match against **relative paths from the artifact root** — branch names are not part of the path:
2182+
2183+
```yaml
2184+
# ✅ Correct: relative path from artifact root
2185+
file-glob:
2186+
- "*.jsonl"
2187+
- "metrics/**"
2188+
2189+
# ❌ Wrong: includes branch name
2190+
file-glob:
2191+
- "memory/default/*.jsonl"
2192+
```
2193+
2194+
### Configuration
2195+
2196+
```yaml
2197+
tools:
2198+
# Boolean: enable with defaults (id: default, branch: memory/default)
2199+
repo-memory: true
2200+
2201+
# Object: custom configuration
2202+
repo-memory:
2203+
target-repo: myorg/memory-repo
2204+
branch-name: memory/agent-state
2205+
max-file-size: 524288 # 512 KB
2206+
file-glob: ["*.md", "*.json"]
2207+
2208+
# Array: multiple independent memories
2209+
repo-memory:
2210+
- id: session
2211+
branch-name: memory/session
2212+
- id: logs
2213+
branch-name: memory/logs
2214+
max-file-size: 2097152 # 2 MB
2215+
```
2216+
2217+
### Validation Limits
2218+
2219+
| Parameter | Default | Maximum |
2220+
|-----------|---------|---------|
2221+
| `max-file-size` | 10 KB | 100 MB |
2222+
| `max-file-count` | 100 files | 1000 files |
2223+
| `max-patch-size` | 10 KB | 100 KB |
2224+
2225+
Patch size is validated after `git add .` by computing `git diff --cached`. If the total diff exceeds `max-patch-size`, the push is aborted. Both upload and push steps run unconditionally (`if: always()`) to preserve memory state even when the agent job fails.
2226+
2227+
### Implementation Files
2228+
2229+
- `pkg/workflow/repo_memory.go` - Core configuration and compilation
2230+
- `pkg/workflow/repo_memory_prompt.go` - Agent prompt generation
2231+
- `actions/setup/sh/clone_repo_memory_branch.sh` - Git clone and orphan branch creation
2232+
- `actions/setup/js/push_repo_memory.cjs` - Artifact download, validation, and push
2233+
2234+
See `scratchpad/repo-memory.md` for the full specification including campaign mode, validation schemas, and cross-layer testing strategy.
2235+
2236+
---
2237+
2238+
## Release Management
2239+
2240+
### Changeset CLI
2241+
2242+
The project uses a custom changeset CLI (`scripts/changeset.js`) for managing version releases.
2243+
2244+
**Commands**:
2245+
2246+
```bash
2247+
# Preview next version from changesets (read-only, never modifies files)
2248+
node scripts/changeset.js version
2249+
make version
2250+
2251+
# Create release (updates CHANGELOG, tags, pushes to remote)
2252+
node scripts/changeset.js release
2253+
make release # Recommended: runs tests first
2254+
2255+
# Specify release type explicitly
2256+
node scripts/changeset.js release patch
2257+
node scripts/changeset.js release minor
2258+
node scripts/changeset.js release major
2259+
2260+
# Skip confirmation prompt
2261+
node scripts/changeset.js release --yes
2262+
```
2263+
2264+
**Changeset file format** (`.changeset/*.md`):
2265+
2266+
```markdown
2267+
---
2268+
"gh-aw": minor
2269+
---
2270+
2271+
Brief description of the change
2272+
```
2273+
2274+
**Bump types**: `patch` (0.0.x), `minor` (0.x.0), `major` (x.0.0).
2275+
2276+
**Release prerequisites**:
2277+
- Clean working tree (all changes committed or stashed)
2278+
- On `main` branch
2279+
2280+
**Standard release workflow**:
2281+
1. Add changeset files to `.changeset/` for each significant change
2282+
2. Run `make version` to preview the next version and CHANGELOG entry
2283+
3. Run `make release` to create the release (updates CHANGELOG, deletes changeset files, commits, tags, and pushes)
2284+
2285+
**Releasing without changesets**: When no changeset files exist, the CLI defaults to `patch` and adds a generic "Maintenance release" entry to the CHANGELOG.
2286+
2287+
See `scratchpad/changesets.md` for complete documentation.
2288+
2289+
---
2290+
20912291
## Additional Resources
20922292

20932293
### Agent Instruction Files
@@ -2115,6 +2315,11 @@ These files are loaded automatically by compatible AI tools (e.g., GitHub Copilo
21152315
- [YAML Version Gotchas](./yaml-version-gotchas.md) - YAML 1.1 vs 1.2 parser compatibility: `on:` key behavior, false positive prevention
21162316
- [Architecture Diagram](./architecture.md) - Package structure and dependency diagram for the `gh-aw` codebase
21172317
- [Guard Policies Specification](./guard-policies-specification.md) - GitHub MCP guard policies: `repos` scope and `min-integrity` access control
2318+
- [Repo Memory Specification](./repo-memory.md) - Persistent git-backed storage: configuration, path conventions, campaign mode, and cross-layer testing
2319+
- [Changesets CLI](./changesets.md) - Version release management: changeset file format, release workflow, and CLI commands
2320+
- [Validation Refactoring Guide](./validation-refactoring.md) - Step-by-step process for splitting large validation files into focused single-responsibility validators
2321+
- [String Sanitization vs Normalization](./string-sanitization-normalization.md) - Distinction between sanitize and normalize patterns; function reference and decision tree
2322+
- [Serena Tools Quick Reference](./serena-tools-quick-reference.md) - Tool usage statistics and efficiency analysis for Serena MCP integration
21182323

21192324
### External References
21202325

@@ -2126,6 +2331,7 @@ These files are loaded automatically by compatible AI tools (e.g., GitHub Copilo
21262331
---
21272332

21282333
**Document History**:
2334+
- v3.9 (2026-03-18): Added 5 previously uncovered spec files: Repo Memory section (from `repo-memory.md`: git-backed persistent storage, path conventions, configuration, validation limits), Release Management section (from `changesets.md`: changeset CLI, release workflow), Validation File Refactoring subsection (from `validation-refactoring.md`: complexity thresholds, naming conventions, process steps), String Processing subsection in Code Organization (from `string-sanitization-normalization.md`: sanitize vs normalize decision rule), and 7 new Related Documentation links. Coverage: 68 spec files (5 new).
21292335
- v3.8 (2026-03-06): Fixed 2 tone issues — "Extreme Simplicity" heading → "Minimal Configuration Model" (mdflow.md:199), "Deep analysis" → "Detailed analysis" (README.md:40). Coverage: 63 spec files (62 spec + 1 test artifact).
21302336
- v3.7 (2026-03-06): Fixed 3 tone issues — removed "intuitive way" (guard-policies-specification.md:17), replaced "User-friendly: Intuitive frontmatter syntax" with "Consistent syntax: Follows existing frontmatter conventions" (guard-policies-specification.md:303), and replaced "significantly improves the developer experience" with precise language (engine-architecture-review.md:312). Coverage: 63 spec files (62 spec + 1 test artifact).
21312337
- v3.6 (2026-03-05): Fixed 2 tone issues — removed "seamlessly" from guard-policies-specification.md:307 and "robust" from pr-checkout-logic-explained.md:56. Coverage: 63 spec files (62 spec + 1 test artifact).

0 commit comments

Comments
 (0)