원클릭으로
topological-divergence
Use when measuring whether branches genuinely differ and deciding respawn or abort.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Use when measuring whether branches genuinely differ and deciding respawn or abort.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Use when attacking branches to find what the verifier cannot catch.
Use when flagging branch conviction or calibrating instinct against outcomes.
Use when budgeting, routing, and scaling a run to fit the ask.
Use when selecting the surviving branch on verifier evidence after collision.
Use when recording dead branches so future runs avoid re-litigating them.
Use when isolating branches in git worktrees and reconciling the survivor.
| name | topological-divergence |
| description | Use when measuring whether branches genuinely differ and deciding respawn or abort. |
"Branches must differ in topology, not style" is an assertion until something measures it. This gate measures it: superposition can silently collapse into N near-identical branches and waste the whole run's spend. The metric is AST shape, so a renamed variable does NOT count as divergence but a changed control flow does.
pqa.divergence.similarity(a, b) fingerprints each branch as its pre-order AST
node-type sequence (depth:NodeType lines) and ratios the fingerprints with
difflib.SequenceMatcher. 1.0 = identical topology; renames and reformatting do
not move the score.measure_divergence(branches, collapsed_at=0.95, divergent_below=0.7) scores every
pair and returns a DivergenceReport with a verdict:| Verdict | Condition | Orchestrator action |
|---|---|---|
| divergent | mean < 0.7 and max < 0.95 | proceed to collision |
| low-variance | one pair ≥ 0.95, or mean in [0.7, 0.95) | respawn-pair: redo the most similar branch |
| collapsed | mean ≥ 0.95 (or n < 2) | abort; re-spawn the whole superposition |
A superposition of 0 or 1 branches is "collapsed" by definition — degenerate runs do not sneak past the gate.
topology_axis fields on the returned
digests are the cheap signal: two branches claiming the same axis is a respawn
candidate before any AST work. Then confirm on the on-disk outputs via
pqa.superposition.validate_divergence(branches).respawn_plan(report) — it returns proceed,
respawn-pair (with pair_indices naming the most similar pair), or abort.divergence: prefix: the prompts produced convergence, so the next run needs
sharper axes — it is a prompt failure, never evidence against the approach itself.superpose stage record in .pqa/state.json, so --resume re-enters after the
gate rather than re-paying the generators.Two rate-limiter branches come back:
# b0 # b1
def allow(key): def permit(tenant):
n = counts[key] c = window[tenant]
if n >= LIMIT: if c >= MAX:
return False return False
counts[key] = n + 1 window[tenant] = c + 1
return True return True
Different names, same shape: both fingerprint to the same
Module/FunctionDef/Assign/If/Compare/Return/... sequence → similarity ≈ 1.0 → the
pair is flagged, verdict low-variance, respawn_plan returns respawn-pair on
(0, 1). The respawned b1 comes back as a bounded queue with backpressure — While,
Try, Raise nodes the fingerprint cannot mistake for a counter — similarity drops
to ~0.3, verdict divergent, proceed.
The gate caught what eyeballing the diff at 2am would have missed: the superposition was one idea wearing two names, about to be billed twice at fable prices.
collapsed. Attacking three identical branches gives the adversary
nothing to compare and the judge nothing to choose; aborting is cheaper than
theatre.spawn_prompts axes were vague, a respawn
with the same axis converges again — sharpen the axis, not just the retry.low-variance verdicts with more skepticism there, not less.