# Markitect Infrastructure Tasks

Issues discovered while building the infospace-with-history example.
All three have been fixed in commit `706981c` and the pipeline script
refactored to use the fixed infrastructure directly.

## 1. Artifact Repository does not store content — RESOLVED

**File:** `markitect/prompts/resolver/resolver.py`, line 147-148
**Issue:** `content = f"[Content of {artifact.name} from {space_id}]"` — the
resolver returns placeholder text instead of actual artifact content because
the SQLiteArtifactRepository stores metadata (digest, name, type) but not
the content itself.
**Impact:** Consumers must maintain their own content cache alongside the
repository, defeating the purpose of centralised artifact storage.
**Fix applied:** Added `content` field to `Artifact` model, `content TEXT`
column to SQLite schema (with migration for existing DBs), and replaced
the resolver placeholder with `artifact.content`.

## 2. ContentMacro raw_text defaults to empty string — RESOLVED

**File:** `markitect/prompts/templates/models.py`, line 46
**Issue:** `raw_text: str = ""` — when macros are constructed programmatically
(not parsed from template text), `raw_text` defaults to `""`. The
ContextCompiler then calls `str.replace("", resolved.content)` which inserts
content between every character, producing multi-gigabyte output.
**Impact:** Silent data corruption; compiled prompts become unusable.
**Fix applied:** Added `__post_init__` to `ContentMacro` that auto-derives
`raw_text = f"@{{{self.target}}}"` when not provided.

## 3. No TemplateAnalyzer support for @{target} syntax — RESOLVED

**File:** `markitect/prompts/templates/parser.py`
**Issue:** The MacroParser parses `{{kind:target}}` syntax but the
templates in this example use the simplified `@{target}` syntax. There's
no automatic parsing for this format, requiring manual macro construction.
**Fix applied:** Added `SHORTHAND_PATTERN` to `MacroParser` that recognises
`@{target}` and maps it to `MacroKind.REQUIRED`. Updated `has_macros()`,
`count_macros()`, and `find_macro_positions()` accordingly.
