Answer an aggregating question by traversing every file in a named corpus inside a sandbox, so the corpus never enters the context window. Use when the answer exists in no single file: \"how many threads have not moved in 30 days\", \"which pipeline rows have no CRM card\". Do NOT use to find something already recorded somewhere - that is /recall, which retrieves rather than counts.
$npx -y skills add HEADING-OS-Official/heading-os --skill census --agent claude-code
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Census?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/heading-os-official-census)
---
name: census
description: "Answer an aggregating question by traversing every file in a named corpus inside a sandbox, so the corpus never enters the context window. Use when the answer exists in no single file: \"how many threads have not moved in 30 days\", \"which pipeline rows have no CRM card\". Do NOT use to find something already recorded somewhere - that is /recall, which retrieves rather than counts."
argument-hint: "<aggregating question> [--corpus threads|crm|context|auto_memory|knowledge]"
allowed-tools: "Read, Write, Bash(.venv/bin/python:*)"
metadata:
author: Misha Hanin
email: misha.hanin@headingos.com
version: "1.0"
x-heading-routing:
category: Operations
triggers:
- "how many X have Y"
- "count across the workspace"
- "which pipeline rows have no card"
- "which threads have not moved in N days"
- "aggregate over the whole corpus"
- "intersection of people and pipeline"
exclusions:
- "\"what do we know about X\" / \"where did we decide Y\" -> /recall"
- "\"add a note\" / \"distill this\" -> /zk"
- "\"what would Odin say\" -> /odin"
- "background on a company or person -> /osint"
- "an exact string in a known file -> Grep"
router: auto
x-heading-capability:
what: >
Answers a counting or set question over the workspace by writing and running a
traversal program over the files, returning a count or a path list with the
sources that produced it.
how: >
Run /census "<question>" [--corpus SCOPE]. The traversal program is printed
before it runs; read it, then approve. Execution is always sandboxed with no
network and a read-only corpus.
when: >
Use when the answer needs many files visited and sits in none of them. For
"what do we know about X" use /recall; for a new note /zk; for external intel
/osint; for an exact string Grep.
---
**Data addresses.** Resources in the data repository are named here by their
logical name, never by a path. Resolve the name before the file operation and
use what it prints:
.venv/bin/python scripts/data-path.py path <name>
Use `read <name>` for a source that may legitimately be absent, and
`read --required <name>` for one whose absence is a defect. An unknown name
refuses; it never resolves to a plausible directory, and a path written out
here goes stale the day the directory moves.
# /census — aggregation over the corpus
Answer an aggregating question by traversing the corpus, not by retrieving from it.
## Why this exists
The step-1 benchmark (2026-08-13) measured the incumbent retrieval path against
15 code-computed truths. On the aggregating class the retrieval ceiling was **0.000**.
All seven questions scored exactly 0.00. That is not a low score but an
unreachable one. The answer sits in no single chunk, so top-K cannot return it at
any depth.
`/census` measured **6 of 7** on the same questions and the same corpus state.
Median 0.05 s per answer, against 0.92 s for retrieval.
The one miss is a known wording debt, not a capability gap. agg-09 names a
reference list of countries that the traversal never receives. It therefore
measures whether the list was guessed. It stays wrong, because the alternative
was a program rewritten after the answer was known.
Both numbers live in `census-bench` in the data overlay.
## When NOT to apply
| Signal | Route to |
| --- | --- |
| "what do we know about X", "where did we decide Y" | `/recall` |
| The corpus scope fits the context window | `/recall` — the engine REFUSES with exit `4` |
| An exact string in a known file | `Grep` |
| A new note to capture | `/zk` |
| Advice from the Odin brain | `/odin` |
| Anything about a person or company outside the workspace | `/osint` |
The window refusal is not advice. SRLM (arXiv:2603.15653) reports that a traversal
primitive on a corpus that already fits actively hurts, so the engine refuses
rather than degrade quietly.
## Corpus scopes
| Scope | What it mounts |
| --- | --- |
| `threads` | the business thread registry |
| `crm` | the CRM contact cards |
| `context` | the context documents, including the pipeline |
| `auto_memory` | the auto-memory files and their index |
| `knowledge` | the whole knowledge base (`knowledge-base`): the `/zk` note directories AND every child another registry name owns there, the Odin brain, `research-surveys`, `intelligence` and `book-library` once the C3 move repoints them. A question about notes says so: count only the immediate children no other name claims |
Default scope set: `threads`, `crm`, `context`, `auto_memory`. Name scopes with
repeated `--corpus` flags; a scope you do not name is not mounted, so the
traversal cannot read it at all.
The whole data repository is one privacy class. So no home inside a
scope is withheld, and no folder aborts the run (operator decision 2026-10-16).
`SANDBOX_DENY_SEGMENTS` in `scripts/utils/sandbox.py` lists the segments the box
never mounts. The engine skips a scope directory that matches it and prints a
warning. A denied directory under a mounted one gets a tmpfs overlay, so it is
absent inside the box. Never edit that constant to match the index: its change
control is `.claude/rules/generated-code-execution.md`.
## Protocol
1. **State the question as a count or a set.** "How many", "which files", "which
pairs". A question that wants prose is a `/recall` question.
2. **Write the traversal program** against the mount paths. The engine mounts
each home of a scope at its data-root-relative address under `/data/`. To
find that address, resolve the registry name with
`python scripts/data-path.py path <name>` and strip the data root. The
`mounts` table of a `--json` run shows the same addresses. A scope with
several homes (`threads`, `context`) mounts each home separately. So glob
`/data/**/*.md` or iterate the mount table, not one directory.
Write results to `/out/answer.json`.
3. **Read the printed program before you run it.** The engine prints the program
by default. It then runs the program. It does NOT wait for you, and `--no-print-program`
removes the print. So reading is your discipline, not a gate the engine
enforces. What makes the eval/exec carve-out legitimate is the four sandbox
controls in `.claude/rules/generated-code-execution.md`, not this step.
4. **Run it.** `.venv/bin/python scripts/census.py "<question>" --program <file> --corpus <scope>`.
5. **Report the count AND the sources.** An answer whose paths cannot be opened
and checked by hand is not an answer.
## The return shape
Counts, paths and pairs only:
```json
{"kind": "count", "value": 13, "sources": ["<scope>/a.md"]}
{"kind": "paths", "paths": [...], "sources": [...]}
{"kind": "pairs", "pairs": [["a.md", "b.md"]], "sources": [...]}
```
Free prose needs `--free-text` and comes back tagged
`"provenance": "untrusted"`. That tag is the fourth control. The other three
protect the child; this one protects the parent. The RESULT travels to a session
that HAS the network and the credentials. An injected instruction never needs to
run inside the box. It only needs a quote in the return.
## Exit codes
| Code | Meaning |
| --- | --- |
| 0 | answered |
| 2 | bad arguments, or an unknown corpus scope |
| 3 | the traversal failed, or its return did not satisfy the schema |
| 4 | the corpus fits the context window — use `/recall` |
| 5 | the sandbox refused: no bubblewrap, no mountable scope left, or a timeout |
| 6 | the return exceeded the return budget |
Denied scope directories are dropped BEFORE the window check, so the size the
window refusal measures is the size of what will actually be mounted.
## NEVER
- Never run a traversal outside the sandbox, and never fall back to running one
when bubblewrap is missing. No sandbox, no run.
- Never mount a corpus scope read-write, and never mount a segment `SANDBOX_DENY_SEGMENTS` names.
- Never return free prose without `--free-text`, and never let a traversal vouch
for text it read out of the corpus.
- Never give the sandbox a network channel of any kind, including a broker that
would relay a model call on its behalf.
- Never approve a traversal program without reading it.
- Never quote a traversal's answer without the sources that produced it.
- Never send anything outbound. This primitive reads and counts.