docs(brain): define repository conventions and add structural validator
New root-level documents establishing the Brain's identity and conventions: AGENTS.md (new, Brain-wide): - Replaces the Backend Residency coaching manual - Defines semantic contracts for each top-level directory - Documents type-specific frontmatter contracts - Link conventions (relative markdown, no Obsidian syntax) - Git commit standards (Conventional Commits) - Points to scripts/validate-brain.py for structural verification README.md (rewritten): - Describes the Brain as a knowledge graph, not a residency dashboard - Navigation table pointing to top-level directories with semantic purpose - No references to Backend Residency operational state inbox/README.md (new): - Explains the zero-friction capture rule - Documents the processing workflow (inbox → knowledge/projects/records) scripts/validate-brain.py (new): - Structural validator for AI agents and manual use - Checks: no deprecated directories, required root files, frontmatter presence and valid type on all content documents, relative link resolution - Run: python scripts/validate-brain.py - Passes cleanly on current repository state
This commit is contained in:
1 parent
a1152d4075
commit
c30f9a873c
4 files changed
+406
-18
No files matched your search
@@ -0,0 +1,161 @@
|
|||||||
|
# Brain — AI Agent Guide
|
||||||
|
|
||||||
|
This repository is a personal knowledge graph. It is not a residency dashboard, a project tracker, or an Obsidian vault. It is a durable store of structured information across multiple types.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Repository Purpose
|
||||||
|
|
||||||
|
The Brain stores five fundamentally different kinds of information:
|
||||||
|
|
||||||
|
| Directory | Contains |
|
||||||
|
| :--- | :--- |
|
||||||
|
| `inbox/` | Unprocessed captures — no classification required. Write first, classify later. |
|
||||||
|
| `knowledge/` | Durable understanding: concepts, technologies, and methods. |
|
||||||
|
| `projects/` | Contextual, project-specific documents. Each project owns its own sub-folder. |
|
||||||
|
| `records/` | Historical artifacts: journals, discussions, decisions, experiments. |
|
||||||
|
| `practice/` | Algorithm exercises, LeetCode writeups, and implementation drills. |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Semantic Contracts
|
||||||
|
|
||||||
|
### `inbox/`
|
||||||
|
Zero-friction capture zone. If the type or destination of a document is not immediately obvious, it belongs here. No metadata required. No naming perfection required. Documents are processed from inbox → knowledge / projects / records / plans during maintenance.
|
||||||
|
|
||||||
|
### `knowledge/`
|
||||||
|
Documents that answer: *"If I read this six months from now, will this help me understand something?"*
|
||||||
|
|
||||||
|
Sub-directories:
|
||||||
|
- `concepts/` — Disciplinary concepts and algorithms (e.g., binary search, data structures).
|
||||||
|
- `technologies/` — Tool- and language-specific knowledge (e.g., Python, Docker, tmux).
|
||||||
|
- `methods/` — Backend engineering practices and methodologies (e.g., testing, auth, SQL).
|
||||||
|
|
||||||
|
Knowledge documents do not become the canonical location for project-specific information. A knowledge document describes *what something is*; a project document describes *how this project uses it*.
|
||||||
|
|
||||||
|
### `projects/`
|
||||||
|
Each project lives in its own sub-folder (e.g., `projects/homelab/`, `projects/magnetflix/`). Projects may have their own `plans/`, `guides/`, `decisions/`, or `research/` sub-directories.
|
||||||
|
|
||||||
|
The folder establishes context (ownership/locality). The document's `type` field establishes its semantic role.
|
||||||
|
|
||||||
|
### `records/`
|
||||||
|
Historical artifacts. The original messy thinking is worth preserving — often what you want to recover later is not just the conclusion, but *why* you reached it.
|
||||||
|
|
||||||
|
Sub-directories:
|
||||||
|
- `journal/` — Dated engineering journals and retrospectives.
|
||||||
|
- `discussions/` — Conversations that informed decisions or produced knowledge.
|
||||||
|
- `decisions/` — Architectural decision records.
|
||||||
|
- `experiments/` — Prototypes, runbooks, and technical investigations.
|
||||||
|
|
||||||
|
### `practice/`
|
||||||
|
Unchanged in structure. Contains LeetCode writeups and Python solution files with their own Nix devShell environment. Do not reorganize this directory without reading its `flake.nix`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Metadata Convention
|
||||||
|
|
||||||
|
Every markdown document must have a YAML frontmatter block. `type` is the only universally required field. All other fields are type-specific.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# knowledge
|
||||||
|
---
|
||||||
|
type: knowledge
|
||||||
|
status: draft | stable
|
||||||
|
topics: [list, of, topics]
|
||||||
|
related: [optional, relative, paths]
|
||||||
|
---
|
||||||
|
|
||||||
|
# project (overview files only)
|
||||||
|
---
|
||||||
|
type: project
|
||||||
|
status: planned | active | paused | completed
|
||||||
|
---
|
||||||
|
|
||||||
|
# plan
|
||||||
|
---
|
||||||
|
type: plan
|
||||||
|
status: draft | active | completed | abandoned
|
||||||
|
project: project-name
|
||||||
|
---
|
||||||
|
|
||||||
|
# guide
|
||||||
|
---
|
||||||
|
type: guide
|
||||||
|
project: project-name
|
||||||
|
---
|
||||||
|
|
||||||
|
# decision
|
||||||
|
---
|
||||||
|
type: decision
|
||||||
|
status: proposed | accepted | superseded
|
||||||
|
project: project-name
|
||||||
|
---
|
||||||
|
|
||||||
|
# journal (no status field — journals are historical by definition)
|
||||||
|
---
|
||||||
|
type: journal
|
||||||
|
date: YYYY-MM-DD
|
||||||
|
---
|
||||||
|
|
||||||
|
# practice
|
||||||
|
---
|
||||||
|
type: practice
|
||||||
|
status: completed | active
|
||||||
|
topics: [list, of, topics]
|
||||||
|
---
|
||||||
|
|
||||||
|
# inbox (no status — classification happens during processing)
|
||||||
|
---
|
||||||
|
type: inbox
|
||||||
|
created: YYYY-MM-DD
|
||||||
|
---
|
||||||
|
```
|
||||||
|
|
||||||
|
Valid `type` values: `knowledge`, `project`, `plan`, `guide`, `decision`, `journal`, `discussion`, `experiment`, `practice`, `inbox`, `reference`.
|
||||||
|
|
||||||
|
**Important:** Folder location does not automatically determine every metadata field. A document inside `projects/homelab/plans/` is a `plan`, not a `project`. The folder establishes context. The `type` field establishes semantic role.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Link Conventions
|
||||||
|
|
||||||
|
- Use standard relative Markdown links: `[text](../relative/path.md)`
|
||||||
|
- Do not use Obsidian `[[double-bracket]]` syntax. The repository must be valid Markdown without Obsidian.
|
||||||
|
- For links to files in separate repositories (e.g., `bitetrack-api`), use their public GitHub URLs.
|
||||||
|
- When reorganizing files, run `python scripts/validate-brain.py` to catch broken links before committing.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Git Commit Standards
|
||||||
|
|
||||||
|
All commits must follow Conventional Commits format:
|
||||||
|
|
||||||
|
```
|
||||||
|
<type>(<scope>): <short description>
|
||||||
|
|
||||||
|
<body explaining what changed and why>
|
||||||
|
```
|
||||||
|
|
||||||
|
Types: `feat`, `docs`, `fix`, `refactor`, `chore`
|
||||||
|
Scopes (optional): `knowledge`, `projects`, `records`, `practice`, `inbox`, `brain`
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
```
|
||||||
|
docs(knowledge): add PostgreSQL indexing guide
|
||||||
|
refactor(brain): move homelab docs into projects/homelab/
|
||||||
|
feat(practice): add LeetCode 0075 sort colors writeup
|
||||||
|
```
|
||||||
|
|
||||||
|
Keep commits atomic: one logical change per commit.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Structural Validator
|
||||||
|
|
||||||
|
Run before committing structural changes:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python scripts/validate-brain.py
|
||||||
|
```
|
||||||
|
|
||||||
|
Checks: frontmatter presence, valid `type` fields, relative link resolution, no deprecated directories, required root files.
|
||||||
@@ -1,28 +1,87 @@
|
|||||||
# 🧠 Second Brain
|
# 🧠 Brain
|
||||||
|
|
||||||
Central repository for personal knowledge management, architecture plans, daily journals, backend engineering knowledge, practice code, homelab infrastructure designs, and project tracking.
|
A personal knowledge graph organized by document type, not by subject.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🧭 Navigation & Core Areas
|
## Structure
|
||||||
|
|
||||||
| Area | Focus & Purpose | Key Documents |
|
| Directory | What it contains |
|
||||||
| :--- | :--- | :--- |
|
| :--- | :--- |
|
||||||
| [**Knowledge Vault**](knowledge/README.md) | Structured backend engineering guides, tools, skills, Python, and DSA. | [SQL Deep Dive](knowledge/skills/sql.md)<br>[Auth & Security](knowledge/skills/auth.md)<br>[Testing & Pytest](knowledge/skills/testing.md)<br>[Pydantic](knowledge/python/pydantic.md)<br>[Docker Basics](knowledge/tools/docker.md)<br>[Tea (Gitea CLI)](knowledge/tools/tea.md)<br>[Printer Discovery & Setup](knowledge/tools/printer-setup-avahi-lpinfo.md) |
|
| [`inbox/`](inbox/) | Zero-friction capture. Write here when you don't know where something belongs yet. |
|
||||||
| [**Practice & Coding**](practice/README.md) | Algorithm patterns, LeetCode solutions, and implementation drills. | [Practiced Patterns Index](practice/LeetCode/00-practiced-patterns.md) |
|
| [`knowledge/`](knowledge/) | Durable understanding — things you know and want to keep. |
|
||||||
| [**Journal & Logs**](journal/README.md) | Daily engineering retrospectives, interview logs, and reflections. | [Interview Logs](docs/interview/LOG.md)<br>[Mistakes Log](docs/mistakes/template.md) |
|
| [`projects/`](projects/) | Contextual documents that belong to a specific project. |
|
||||||
| [**Homelab & Infrastructure**](homelab/README.md) | Systems architecture, NixOS migrations, DNS, CI/CD, and `appctl`. | [NixOS Server & Laptop Migration](homelab/nixos-server-laptop-migration.md)<br>[Domain Migration (`roadtotech.me`)](homelab/domain-migration-roadtotech.md)<br>[Appctl & Repositories Architecture](homelab/homelab-appctl-architecture.md)<br>[Brain Sync & Gitea Mirroring](homelab/brain-sync-and-gitea-mirroring.md) |
|
| [`records/`](records/) | Historical artifacts — things that happened. |
|
||||||
| [**Learning & Growth**](learning/README.md) | Academic tracking, residency curriculum milestones, and notes. | [Backend Residency Roadmap](learning/backend-residency.md)<br>[CI/CD Fundamentals](learning/cicd-fundamentals-and-gitops.md) |
|
| [`practice/`](practice/) | Algorithm exercises and implementation drills. |
|
||||||
| [**Projects**](projects/README.md) | Active software projects, architecture notes, and feature roadmaps. | [MagNetFlix](projects/magnetflix.md)<br>[Nekoweb](projects/nekoweb.md) |
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🎓 Backend Residency Core Documents
|
## Knowledge
|
||||||
|
|
||||||
- [**ROADMAP.md**](ROADMAP.md) — The strategic 90-day roadmap with phase exit gates.
|
```
|
||||||
- [**SKILLS.md**](SKILLS.md) — Confidence and interview readiness matrix for core backend technologies.
|
knowledge/
|
||||||
- [**AGENTS.md**](AGENTS.md) — The AI Coaching Manual and guidelines for the residency.
|
├── concepts/ ← Disciplinary ideas: algorithms, data structures
|
||||||
- [**CURRENT.md**](CURRENT.md) — Current active milestone and sprint focus.
|
├── technologies/ ← Tool and language knowledge: Python, Docker, Nix, tmux
|
||||||
- [**todo.md**](todo.md) — Master checklist of residency phases and tasks.
|
│ └── python/
|
||||||
- [**parking-lot.md**](knowledge/parking-lot.md) — Backlog of deferred topics to avoid scope creep.
|
└── methods/ ← Backend practices: testing, auth, SQL, CI/CD, ADRs
|
||||||
|
```
|
||||||
|
|
||||||
|
**Key documents:**
|
||||||
|
- [Binary Search](knowledge/concepts/binary-search.md)
|
||||||
|
- [HashMap](knowledge/concepts/hashmap.md)
|
||||||
|
- [Pydantic](knowledge/technologies/python/pydantic.md)
|
||||||
|
- [Docker](knowledge/technologies/docker.md)
|
||||||
|
- [Authentication & JWT](knowledge/methods/auth.md)
|
||||||
|
- [SQL](knowledge/methods/sql.md)
|
||||||
|
- [Testing](knowledge/methods/testing.md)
|
||||||
|
- [CI/CD & GitOps](knowledge/methods/cicd-fundamentals-and-gitops.md)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Projects
|
||||||
|
|
||||||
|
```
|
||||||
|
projects/
|
||||||
|
├── homelab/ ← Infrastructure, NixOS, appctl, CI/CD, networking
|
||||||
|
│ ├── plans/ ← Migration and strategy documents
|
||||||
|
│ └── guides/ ← Architecture and how-to documents
|
||||||
|
├── magnetflix/ ← Media application
|
||||||
|
└── nekoweb/ ← Web project
|
||||||
|
```
|
||||||
|
|
||||||
|
**Key documents:**
|
||||||
|
- [Homelab Overview](projects/homelab/overview.md)
|
||||||
|
- [MagNetFlix Overview](projects/magnetflix/overview.md)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Records
|
||||||
|
|
||||||
|
```
|
||||||
|
records/
|
||||||
|
└── journal/ ← Dated engineering retrospectives
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Practice
|
||||||
|
|
||||||
|
```
|
||||||
|
practice/
|
||||||
|
└── LeetCode/
|
||||||
|
├── 00-practiced-patterns.md ← Pattern index
|
||||||
|
├── 0001-two-sum.md
|
||||||
|
└── Solutions/ ← Python solution files
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Conventions
|
||||||
|
|
||||||
|
Every document has a `type` field in its YAML frontmatter. See [AGENTS.md](AGENTS.md) for the full metadata convention, directory semantics, link standards, and git commit format.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Inbox
|
||||||
|
|
||||||
|
Documents that haven't been classified yet live in [`inbox/`](inbox/). See [`inbox/README.md`](inbox/README.md) for the capture rule.
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
# 📥 Inbox
|
||||||
|
|
||||||
|
**Zero-friction capture zone.**
|
||||||
|
|
||||||
|
If you don't immediately know what something is or where it belongs, it goes here. No naming perfection required. No metadata required. No classification required.
|
||||||
|
|
||||||
|
Write first. Classify later.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## The rule
|
||||||
|
|
||||||
|
> If you're pausing to decide where something belongs, it goes in `inbox/`.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Processing
|
||||||
|
|
||||||
|
During a maintenance pass, each inbox document gets reviewed and moved:
|
||||||
|
|
||||||
|
```
|
||||||
|
inbox/
|
||||||
|
↓
|
||||||
|
knowledge/ → if it's durable understanding
|
||||||
|
projects/ → if it belongs to a specific project
|
||||||
|
records/ → if it's a historical artifact (journal, discussion, experiment)
|
||||||
|
plans/ → if it's future intent
|
||||||
|
```
|
||||||
|
|
||||||
|
If a document is too short or unclear to classify, leave it here. There is no obligation to atomize everything immediately.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Current inbox
|
||||||
|
|
||||||
|
- [`parking-lot.md`](parking-lot.md) — Deferred topics for future study.
|
||||||
Executable
+132
@@ -0,0 +1,132 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Brain Structural Validator
|
||||||
|
Run from the repository root: python scripts/validate-brain.py
|
||||||
|
|
||||||
|
Checks:
|
||||||
|
1. No deprecated top-level directories remain.
|
||||||
|
2. Required root files exist.
|
||||||
|
3. Every .md document (outside exempt paths) has YAML frontmatter.
|
||||||
|
4. Every frontmatter block has a valid `type` field.
|
||||||
|
5. Every relative markdown link resolves to an existing file.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
import pathlib
|
||||||
|
|
||||||
|
ROOT = pathlib.Path(__file__).parent.parent.resolve()
|
||||||
|
|
||||||
|
VALID_TYPES = {
|
||||||
|
"knowledge", "project", "plan", "guide", "decision",
|
||||||
|
"journal", "discussion", "experiment", "practice", "inbox", "reference",
|
||||||
|
}
|
||||||
|
|
||||||
|
DEPRECATED_DIRS = [
|
||||||
|
"homelab", "journal", "learning", "docs",
|
||||||
|
"knowledge/dsa", "knowledge/python", "knowledge/tools",
|
||||||
|
"knowledge/devenv", "knowledge/skills",
|
||||||
|
]
|
||||||
|
|
||||||
|
REQUIRED_ROOT_FILES = ["README.md", "AGENTS.md", "LICENSE"]
|
||||||
|
|
||||||
|
EXEMPT_PATTERNS = [
|
||||||
|
".obsidian",
|
||||||
|
"practice/LeetCode/Solutions",
|
||||||
|
"scripts",
|
||||||
|
".git",
|
||||||
|
]
|
||||||
|
|
||||||
|
# Root-level files that are navigational/meta and intentionally have no frontmatter
|
||||||
|
FRONTMATTER_EXEMPT_FILES = {
|
||||||
|
ROOT / "README.md",
|
||||||
|
ROOT / "AGENTS.md",
|
||||||
|
ROOT / "inbox" / "README.md",
|
||||||
|
}
|
||||||
|
|
||||||
|
errors: list[str] = []
|
||||||
|
warnings: list[str] = []
|
||||||
|
|
||||||
|
|
||||||
|
def is_exempt(path: pathlib.Path) -> bool:
|
||||||
|
rel = str(path.relative_to(ROOT))
|
||||||
|
return any(ex in rel for ex in EXEMPT_PATTERNS)
|
||||||
|
|
||||||
|
|
||||||
|
# ── Check 1: No deprecated directories ────────────────────────────────────────
|
||||||
|
print("Checking deprecated directories...")
|
||||||
|
for d in DEPRECATED_DIRS:
|
||||||
|
target = ROOT / d
|
||||||
|
if target.exists():
|
||||||
|
errors.append(f"Deprecated directory still exists: {d}/")
|
||||||
|
print(f" {'✓' if not any('Deprecated' in e for e in errors) else '✗'} Done.\n")
|
||||||
|
|
||||||
|
|
||||||
|
# ── Check 2: Required root files ──────────────────────────────────────────────
|
||||||
|
print("Checking required root files...")
|
||||||
|
for f in REQUIRED_ROOT_FILES:
|
||||||
|
if not (ROOT / f).exists():
|
||||||
|
errors.append(f"Missing required root file: {f}")
|
||||||
|
print(f" {'✓' if not any('Missing required' in e for e in errors) else '✗'} Done.\n")
|
||||||
|
|
||||||
|
|
||||||
|
# ── Check 3 & 4: Frontmatter presence and valid type ─────────────────────────
|
||||||
|
print("Checking frontmatter...")
|
||||||
|
fm_errors = 0
|
||||||
|
for md in ROOT.rglob("*.md"):
|
||||||
|
if is_exempt(md):
|
||||||
|
continue
|
||||||
|
if md in FRONTMATTER_EXEMPT_FILES:
|
||||||
|
continue
|
||||||
|
content = md.read_text(errors="replace")
|
||||||
|
rel = md.relative_to(ROOT)
|
||||||
|
if not content.startswith("---"):
|
||||||
|
errors.append(f"Missing frontmatter: {rel}")
|
||||||
|
fm_errors += 1
|
||||||
|
continue
|
||||||
|
# Extract frontmatter block
|
||||||
|
end = content.find("\n---", 3)
|
||||||
|
if end == -1:
|
||||||
|
errors.append(f"Malformed frontmatter (no closing ---): {rel}")
|
||||||
|
fm_errors += 1
|
||||||
|
continue
|
||||||
|
fm_block = content[3:end]
|
||||||
|
type_match = re.search(r'^type:\s*(\S+)', fm_block, re.MULTILINE)
|
||||||
|
if not type_match:
|
||||||
|
errors.append(f"Frontmatter missing 'type' field: {rel}")
|
||||||
|
fm_errors += 1
|
||||||
|
elif type_match.group(1) not in VALID_TYPES:
|
||||||
|
errors.append(f"Invalid type '{type_match.group(1)}': {rel}")
|
||||||
|
fm_errors += 1
|
||||||
|
print(f" {'✓' if fm_errors == 0 else '✗'} Done ({fm_errors} issues).\n")
|
||||||
|
|
||||||
|
|
||||||
|
# ── Check 5: Relative link resolution ─────────────────────────────────────────
|
||||||
|
print("Checking relative links...")
|
||||||
|
link_errors = 0
|
||||||
|
for md in ROOT.rglob("*.md"):
|
||||||
|
if is_exempt(md):
|
||||||
|
continue
|
||||||
|
if md in FRONTMATTER_EXEMPT_FILES:
|
||||||
|
continue
|
||||||
|
content = md.read_text(errors="replace")
|
||||||
|
for m in re.finditer(r'\[([^\]]*)\]\(([^)]+)\)', content):
|
||||||
|
target = m.group(2).split('#')[0].strip()
|
||||||
|
if not target or target.startswith('http') or target.startswith('file:') or target.startswith('mailto:'):
|
||||||
|
continue
|
||||||
|
resolved = (md.parent / target).resolve()
|
||||||
|
if not resolved.exists():
|
||||||
|
rel = md.relative_to(ROOT)
|
||||||
|
errors.append(f"Broken link in {rel}: {target}")
|
||||||
|
link_errors += 1
|
||||||
|
print(f" {'✓' if link_errors == 0 else '✗'} Done ({link_errors} broken links).\n")
|
||||||
|
|
||||||
|
|
||||||
|
# ── Summary ───────────────────────────────────────────────────────────────────
|
||||||
|
if errors:
|
||||||
|
print(f"❌ Validation failed — {len(errors)} error(s):\n")
|
||||||
|
for e in errors:
|
||||||
|
print(f" ✗ {e}")
|
||||||
|
sys.exit(1)
|
||||||
|
else:
|
||||||
|
print("✅ All checks passed. Brain structure is valid.")
|
||||||
Reference in new issue
Block a user