close
Skip to content

docs(autosde): forbid new work on the gateway boot path - #2472

Merged
CrysisDeu merged 1 commit into
mainfrom
feat/autosde-boot-path-rule
Aug 10, 2026
Merged

docs(autosde): forbid new work on the gateway boot path#2472
CrysisDeu merged 1 commit into
mainfrom
feat/autosde-boot-path-rule

Conversation

@CrysisDeu

Copy link
Copy Markdown
Collaborator

What

Adds a blocking AutoSDE rule, no-new-work-on-gateway-boot-path, to AUTOSDE.yaml.

Why

Gateway startup on a real profile has grown to roughly 20s, and none of it is a
regression in the boot code — the boot statements are materially unchanged since
v0.1.2. What changed is that the data those statements traverse became
non-empty. A cold boot on an empty KIROCREW_HOME still reaches HTTP 200 in
2.34s; the same code against a populated knowledge corpus spends ~4.55s on the
event loop before the socket binds, and three of its scans return zero rows.

That shape — a boot step that is free until it isn't, with no scaling guard and
no reviewer prompt to notice — is what this rule is for. The cost also compounds:
startup that holds the loop long enough for the stall watchdog to fire gets the
process killed and respawned into the same startup, converting a latency bug
into a crash loop.

The rule

It names the boot path precisely, so a reviewer can tell whether a diff is on it:

  • GatewayOrchestrator.run() up to the KIROCREW_READY print
  • start_dashboard() up to await _start_site(site, port)
  • any _init_*() or setup_*_routes() reached from those
  • cli.py's gateway command before asyncio.run()

Six rejected shapes, each drawn from a defect actually found in this codebase
rather than from principle:

  1. A new awaited or synchronous step before the socket binds.
  2. Subsystem construction as a side effect of route registration — a
    setup_*_routes() that also builds a pipeline or opens a store drags that
    init onto the boot path where nobody reading the route file will find it.
  3. Work whose cost scales with user data. Forbidden at any measured speed,
    because the measurement was taken on an empty profile.
  4. Unconditional maintenance — orphan sweeps, integrity scans, vacuum, reindex,
    or a migration that scans instead of checking a version.
  5. Eager import or instantiation of a subsystem that is optional or disabled.
    Gate the import, not just the handler.
  6. Reading a lazily-initialized accessor from boot code, which silently breaks
    the lazy-init contract its author wrote.

It also lists the accepted alternatives — memoized first-use accessor,
asyncio.create_task, await asyncio.to_thread, or letting dependent routes
503 until ready — so a reviewer can point at a fix rather than only object. If a
step genuinely must run at boot, the rule requires the PR to say why it cannot
be deferred and to state its worst-case bound on a large profile.

Scope

Judgment tier only, following the two-tier split this repo already documents in
test/test_no_blocking_call_on_loop.py: deterministic cases become a hard gate,
judgment cases become an AutoSDE rule. "Does this step need to be on the
critical path?" cannot be decided statically, so it belongs here. A deterministic
companion is possible — AST-count the pre-bind statements in run() /
start_dashboard() and pin them in a baseline, in the style of
config-baseline.json — and is deliberately left for a follow-up.

Testing

  • AUTOSDE.yaml parses; 5 rules present, the new one carries 4 file-patterns.
  • No Python or TypeScript touched, so pytest / isort / flake8 / mypy / tsc /
    vitest are unaffected. There is no schema test over AUTOSDE.yaml — the only
    test-tree references to rule ids are # loop-ok: suppression comments.

Note on when it takes effect

All four review workflows extract rules from the base commit rather than the PR
HEAD (git show "$BASE_SHA:AUTOSDE.yaml"), so that a PR cannot weaken the rules
it is reviewed against. This rule therefore does not gate its own PR; it starts
applying to PRs opened after it merges. AUTOSDE.yaml is also in the
:(exclude) list in code-review.yml, so the deterministic job skips it.

Everything between process start and the dashboard socket accepting
requests runs once, in order, on one thread. Every statement added there
is paid by every user on every launch, and a startup that holds the loop
long enough for the stall watchdog to fire turns a latency bug into a
crash loop.

The rule names the boot path precisely (GatewayOrchestrator.run up to
KIROCREW_READY, start_dashboard up to _start_site, the _init_* and
setup_*_routes reached from those, and cli.py before asyncio.run) and
rejects six shapes, each drawn from a defect found in this codebase:
a new awaited step before the socket binds, subsystem construction as a
side effect of route registration, work that scales with user data,
unconditional maintenance sweeps, eager import of a disabled subsystem,
and reading a lazy-init accessor from boot code.

It also states the accepted alternatives, so a reviewer can point at one
instead of only rejecting: a memoized first-use accessor, a background
task, an off-loop thread hop, or letting dependent routes 503 until
ready.
@CrysisDeu
CrysisDeu requested a review from a team as a code owner August 10, 2026 03:52
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Aug 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed e36dc231e673d3bd29e5fbf444e2a1eb9e219587 — this comment is updated in place on each push.

Review details

The entire PR adds a single blocking AUTOSDE rule to AUTOSDE.yaml and touches no code. Adding or tightening a rule is explicitly not a finding, and the addition is well-formed and consistent with the existing rule structure.

No findings.

[OPUS-REVIEWED] e36dc23

Verdict parsed from the review's SHA-scoped output markers for commit e36dc231e673d3bd29e5fbf444e2a1eb9e219587.

False positive or not applicable? A repository writer can comment:
/ai-review override fable e36dc231e673d3bd29e5fbf444e2a1eb9e219587: <one-sentence reason>

@github-actions

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of e36dc231e673d3bd29e5fbf444e2a1eb9e219587 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] e36dc23

False positive or not applicable? A repository writer can comment:
/ai-review override gpt e36dc231e673d3bd29e5fbf444e2a1eb9e219587: <one-sentence reason>

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Advisory design-level review of e36dc231e673d3bd29e5fbf444e2a1eb9e219587 — updated in place on each push; does not block merge.

Design-Verdict: PASS

A real, incident-shaped risk (boot latency compounding into watchdog crash loops), addressed at the right layer with concrete anchors and an explicit escape hatch.

Suggestions

  • The rule fires on diffs to the four boot files, but boot cost added inside a subsystem's own module (e.g. a constructor run() already calls) never loads it; a one-line note telling reviewers to trace transitive init cost from those anchors would close the main blind spot without widening the file patterns.

[DESIGN-REVIEWED] e36dc23

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Aug 10, 2026
@CrysisDeu
CrysisDeu merged commit 7304bb0 into main Aug 10, 2026
76 of 77 checks passed
@CrysisDeu
CrysisDeu deleted the feat/autosde-boot-path-rule branch August 10, 2026 07:57
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant