Skip to content

I0818 — The command registry is read in one pass

Replace the per-index, per-field awk lookups in mj_cmdreg_public, mj_cmdreg_ids and the event registry with one awk pass each, and read them once per process.

DONE wave 1 · p0 · implementation profile · runs alone

Part of M004 — Performance is executable evidence, and the hot path does no canonical work twice.

Objective

Replace the per-index, per-field awk lookups in mj_cmdreg_public, mj_cmdreg_ids and the event registry with one awk pass each, and read them once per process.

Why

Command coverage costs three seconds because mj_cmdreg_public runs dozens of awk processes and is called inside a loop over declared commands.

Current state

mj_cmdreg is one awk per key; mj_cmdreg_public loops it; mj_validate_command_coverage calls mj_cmdreg_public per declared command.

Desired state

Each registry is flattened once and its public ids and dispatch table are derived with one awk; the coverage validator reads every case header with one pass.

Scope

  • lib/commands.sh
  • lib/common.sh
  • test/cases/30_command_registry.sh
  • test/cases/31_command_coverage.sh

Out of scope

  • A change to share/commands.yaml

Dependencies

What waits on this

Acceptance criteria

  • validate:command_coverage and validate:command_surface each under 200 ms on this repository
  • Cases 30, 31, 35 and 36 pass unchanged
  • yaml_flatten count for doctor does not grow

Validation

  • MJ_TIMING=1 bin/majordomus doctor
  • bash test/run.sh 31_command_coverage

Evidence required

  • batch_reads

Evidence

coverstypecommandresultat commit
batch_readstestMJ_TIMING=1 bin/majordomus doctorvalidate:command_coverage went from 3080 ms to 74 ms and validate:command_surface from 352 ms to 141 ms on this repository; mj_cmdreg_public and mj_cmdreg_ids are one awk each, the coverage validator reads every case header in one pass and the public list once, the surface validator reads the dispatch table once, and mj_event_index is one pass; cases 15, 22, 30, 31, 33, 35 and 36 pass unchanged, including the mutations that remove a registry entry and add a dispatcher-only commandc9443ae

Risk

A batch read must produce exactly the per-key results; the cases that mutate the registry are the proof.

Timeline

started
2026-09-05T01:50:00Z
verified
2026-09-05T02:05:00Z
completed
2026-09-05T02:05:00Z

Those three fields, the evidence above and the state of the dependencies are all the status is made of. There is no status field to disagree with them.

Canonical record: .ai/repo/project/issues/I0818.yaml. Read it back with majordomus plan show I0818.