Skip to content

Latest commit

 

History

History
95 lines (71 loc) · 4.27 KB

enumerate.md

File metadata and controls

95 lines (71 loc) · 4.27 KB

enumerate.sh

Revision: 1 Last modified: 2026-12-04T19:00:00Z

Overview

enumerate.sh discovers and enumerates the consumers of this constitution and writes them to a JSON document.

It is a thin POSIX-sh entrypoint: the entire body is exec python3 _enumerate_impl.py "$@". The real work — multi-source probing, JSON construction and needle checks — lives in the co-located _enumerate_impl.py (Python stdlib plus PyYAML for --config parsing). That split is deliberate: the shell layer exists only so callers have a stable sh entrypoint in a sh-oriented tool tree, and it adds no logic of its own that could drift from the implementation.

The interesting judgement is in exit code 5. "One or more probes degraded" is a partial enumeration — some sources answered, some did not. Returning a plain success would present a partial list as a complete one; returning a hard failure would discard the sources that did answer. The code is distinct so a caller can decide, and the --out document's source_reachability block records which sources were actually reached.

Prerequisites

  • sh for this entrypoint; python3 plus PyYAML for the implementation.
  • _enumerate_impl.py beside it (resolved relative to this script, not the caller's cwd).
  • A fastcycle config file (--config) naming the sources to probe.
  • No environment variables are read.

Usage examples

# enumerate consumers
sh scripts/fastcycle/consumers/enumerate.sh \
  --config fastcycle.yaml --out consumers.json

# prove the enumeration is reproducible
sh scripts/fastcycle/consumers/enumerate.sh \
  --config fastcycle.yaml --out consumers.json --determinism-check

Exit codes

Code Meaning
0 OK — enumeration complete.
1 Determinism mismatch (--determinism-check only).
2 Usage error (bad/missing flags, unparseable config).
3 Control-needle failure (CA-004) — the enumerator's own instrument could not be trusted.
4 All sources unreachable — no enumeration is possible.
5 One or more probes degraded: a partial enumeration. Consult the --out document's source_reachability block (T177 Round 1 B1).

Codes 4 and 5 are the pair that keeps a partial answer honest. 4 means "nothing could be reached"; 5 means "some things could, and here is which".

Edge cases

  • Every source unreachable. Exit 4, not an empty 0. An empty consumer list and an unreachable network must not look the same.
  • One source down. Exit 5 with the document still written, so a caller can proceed knowingly on partial data rather than being blocked or misled.
  • Needle failure. Exit 3; the needle exists (CA-004) so a genuinely empty result and a broken probe are distinguishable.
  • --determinism-check mismatch. Exit 1, meaning the same inputs produced two different enumerations.
  • A --config without the expected structure. Usage error (2) rather than a silently empty probe set.
  • The implementation file missing. The exec fails and the shell's own error surfaces — this entrypoint adds no fallback, by design.

Internal behaviour

  1. Resolves its own directory (HERE) from $0, not from the caller's cwd.
  2. execs python3 "$HERE/_enumerate_impl.py" "$@" — argument pass-through with no translation.
  3. The implementation probes each configured source, builds the consumer document, runs the CA-004 needle, records source_reachability, and writes --out.
  4. The process exit status is the implementation's own; this script has no code path that could change it.

Related scripts

Calls scripts/fastcycle/consumers/_enumerate_impl.py.

Related in the same contract family (contracts/consumer-audit-and-migration.md, CA-001..CA-005): scripts/fastcycle/consumers/migrate.sh (migration, CA-019..CA-028) and scripts/fastcycle/consumers/audit.py (consumer audit).

Guarded by scripts/fastcycle/tests/test_consumer_enumerate_red.sh (T166).

See also docs/scripts/migrate.sh.md and docs/scripts/audit.py.md.

Last verified

2026-12-04 — bash -n scripts/fastcycle/consumers/enumerate.sh → exit 0. sh scripts/fastcycle/consumers/enumerate.sh with no arguments exits 2 (required --config and --out absent, rejected by the implementation).