# aspect: code

> Code structure aspect. The public entrypoint is `context capture --code`.

## Target

Extract package, symbol, edge, digest, and source-file rows from the local
worktree. This aspect uses bundled runner mode (`runner.package` + `runner.bin`),
not local plugin mode. The context CLI owns `.context` writes and publishes the
raw bucket atomically.

## Raw Snapshot

Each capture writes a source-scoped bucket:

```text
raw/aspect/code/<source-slug>/<snapshot-id>/
```

The bucket contains:

- `source.yaml` - local source identity and publish upsert hints
- `manifest.json` - snapshot identity, runner hash, counts, and content hash
- `digests.jsonl` - module digest rows with `hash_id`, `module_path`, and `dir_commit`
- `source-files.jsonl` - service-compatible source file mapping
- `packages.jsonl` - flat package/module view
- `symbols.jsonl` - flat symbol view, with nested members flattened
- `edges.jsonl` - flat code relation view
- `_meta.yaml` - compact copy of snapshot metadata for legacy readers

## Notes

- New writes use `aspect:code:<source-slug>` as the source id.
- Repeated captures of the same commit, script hash, and snapshot content are
  reported as unchanged and do not create duplicate snapshots.
- Dirty worktrees are allowed; dirty module rows keep the real `dir_commit`
  and use a content-sensitive `hash_id`.
- The code aspect uses `evidence.mode: none`: it does not generate
  `raw/.evidence` block manifests. Symbols, files, and edges are already
  represented by the bucket JSONL indexes.
- `context compile --aspect code` converts package and symbol rows into
  code-owned Sections with code `source_ref` values such as
  `src-1#package:<package>@<hash>` and
  `src-1#symbol:<locator>:<kind>@<hash>`. These refs resolve against the raw
  code snapshot JSONL indexes, not against prose evidence blocks.
- Runner raw extraction results are intentionally not written as a separate
  bucket file. Future consumers should read `digests.jsonl` and the flat
  package/symbol/edge projections instead.
