escalate-arch-runtime
Only on explicit human request, run consent-gated Python introspection to recover routes or models missed by static extraction.
- License 许可
- MIT
- 最近更新
- 2026-11-12
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- escalate-arch-runtime
- metadata
- { "tags": "arch, runtime, introspection, escalation, security", "bundles": "crux-docs", "triggers": "escalate the arch runtime | run the runtime arch introspection | recover the routes by running my app | introspect my FastAPI/Flask/Django app for arch", "risk_level": "high", "routing_note": "Human-invoked only. An optional fidelity upgrade a human may choose, never the remedy any crux surface points a reader at. Runs a Python target's import-time code in a subprocess-isolated child behind the two-factor `CRUX_ARCH_ALLOW_RUNTIME=1` consent gate; writes an advisory into `<docs_dir>/inbox/`, never into `arch/`.", "requires_access": "write-tree" }
- description
- Only on explicit human request, run consent-gated Python introspection to recover routes or models missed by static extraction.
- disable-model-invocation
- true
03 SKILL.md 正文
Escalate Arch Runtime
Recover the two arch surfaces static extraction is blind to — a framework's route table and its ORM model schema — for Python targets, by running the target's import-time code in a confined subprocess. This is the highest-risk capability in the project; every guarantee below is load-bearing.[^adr]
Scope — an optional fidelity upgrade, never a pointed-to remedy
This skill is an optional fidelity upgrade a human may choose, never the
remedy any crux surface points a reader at.[^clause-11] derive-arch never
names this skill, offers it, or points a reader here — a stubbed verdict, or
an exit-2 ParserUnavailable with no verdict at all, is a recorded fact, not
an invitation to escalate. Invocation starts only from a human's own explicit
request, named in the frontmatter description above.
When this runs — the two-factor consent gate
Execution runs only under two independent, non-model-mediated factors:
- Factor (a): the standing capability flag
CRUX_ARCH_ALLOW_RUNTIME=1, set out-of-band by a human, off by default, never auto-detected. The executor reads it directly and enforces a fail-closed floor: it requires a TTY and refuses under any CI marker (CI,CONTINUOUS_INTEGRATION,GITHUB_ACTIONS,GITLAB_CI,BUILDKITE,CIRCLECI,JENKINS_URL,TF_BUILD), so it hard-fails in CI even with the flag set. - Factor (b): a per-execution permission event — the harness permission prompt on the executing tool call, or the human's own shell invocation. It is enforced OUTSIDE the executor and is NEVER self-attested; no config value, environment variable, or repo file substitutes for it.
The TTY check is a floor, not proof of consent. The guarantee that consent is never model-mediated rests on three structural facts: this skill is human- invoked only, is excluded from run-execution autonomy, and must not be allowlisted for auto-approval.
Invocation — one of two mutually exclusive grammars
The human names the target explicitly. The harness never auto-detects the framework.
Run under the TARGET's interpreter (the one that can import the app's
dependencies) via --python:
uv run "${CRUX_PLUGIN_ROOT}/scripts/crux/arch/runtime/__main__.py" \
--app <module>:<attr> \
--python .venv/bin/python --repo-root . --docs-dir bionic
- FastAPI / Flask:
--app module:attr, whereattris an app instance (introspected directly — FastAPIapp.routes, Flaskapp.url_map) or a zero-argument application factory such ascreate_app(called with zero args, then introspected). A factory that requires arguments yields an honest no-capture, never a guess. - Django:
--settings module.pathand NO--app. The harness setsDJANGO_SETTINGS_MODULE, injects a dummy DB backend, runsdjango.setup(), walksROOT_URLCONF(depth cap 50 + cycle guard), and readsapps.get_models(). Django routes carrymethod: null.
A module-level app.run() / uvicorn.run(app) with no __main__ guard blocks
on import; the harness cannot prevent that, so such a target yields no capture —
killed by the timeout — and never a hang.
Confinement (stdlib-only; Linux + macOS)
Per-control, kernel-enforced where the platform provides the primitive and best-effort where it does not:
- Temp-clone working tree — the target's own package is copied into a scratch
tempdir (capped at 256 MiB, refused above), the child's cwd and
sys.pathrooted there. This reroutes writes; it is not a filesystem boundary. A same-UID absolute-path or native write to the real tree, the venv, or~/.cruxis a stated residual an OS-level sandbox closes. - Fresh strict env allowlist — the child environment is built fresh, never
os.environ.copy(). OnlyPATH,LANG,LC_*,HOME(redirected to scratch), andDJANGO_SETTINGS_MODULEsurvive, so no ambient secret reaches the child. - Network cut — Linux enters
os.unshare(CLONE_NEWUSER | CLONE_NEWNET)(CPython 3.12+; fail-closes to no-capture when unavailable). macOS is best-effort Python-level socket neutralization plus the audithook; a native path can still open a socket there (stated residual). - Resource caps + process-group lifecycle —
RLIMIT_CPU30 s,RLIMIT_AS2 GiB (Linux),RLIMIT_NPROC64,RLIMIT_NOFILE256 (soft == hard). The parent waits with a wall-clock timeout (default 60 s, clamped 5–300), thenkillpgSIGTERM → 5 s grace → SIGKILL. Asetsidescapee MAY outlive the run (stated residual). - Audit deny-list —
socket.*,subprocess.*,os.system,os.exec*,os.fork/forkpty/posix_spawn, and write-modeopenoutside scratch.
Every failure mode is a no-capture refusal, never a hang.
The capture is untrusted advisory data
The child writes a closed-schema JSON document to a dedicated descriptor. The
parent drains it under a 4 MiB pre-parse byte cap and a deadline, then parses it
with json.loads ONLY, validates against a strict schema that rejects unknown
keys, applies count/length caps, and re-escapes every value through derive's
_cell. A forged capture is bounded to garbage advisory output a human reviews
before filing; it never reaches the spine.
Where results land — outside arch/
The advisory is written to <docs-dir>/inbox/, marked runtime_sourced: true,
with provenance, no in-body clock, and no absolute paths. A human files it as a
research synthesis page or a session brief. An optional OpenAPI-shaped fold-back
candidate is also written to inbox/; a human may review and commit it into the
target repo, where the deterministic extractor consumes it on the next normal
derive. Nothing non-deterministic ever lands under arch/ or touches the
spine hash.
Test surface
The harness tests run against the cycle-authored FastAPI, Flask, and Django
fixture apps under crux/scripts/tests/fixtures/runtime_*, plus plain-Python
hostile fixtures — never an arbitrary external application.
[^adr]: The runtime-execution decision — the Python import-only runtime arch introspection executor, its confinement contract control-by-control, and its stated residuals — recorded in the target tree's ADRs.
[^clause-11]: The script-driven arch extraction decision, the clause retiring derive-arch's chat-only escalation offer and narrowing this skill's scope to a human-chosen fidelity upgrade — recorded in the target tree's ADRs.
04 同仓库更多 Skills
whiteboarding
Explore an idea through docs-informed dialogue before committing to a design. Capture the exploration for later filing as a brief.
verify-code-docs
Check generated code documentation against source and report drift without regenerating it.
transition-observation
Apply a human disposition to an observation's lifecycle state without changing its claim or body.
transition-invariant
Ratify, reject, or retire an invariant on human direction. Update lifecycle metadata without changing the invariant's body.
transition-decision
Apply a human ratify, reject, or defer verdict to a recovered decision candidate; ratification creates a Proposed ADR or observation.
transition-brief
Publish or abandon a draft brief, updating lifecycle metadata and indexes without changing its body.