STEP 1651 — Stopping-Condition Pipeline v0.1 89/89 PASS

2026-09-01 · src/aios/stopping-condition/ · npm test:step1651

起点

藤本さん directive 「STEP 4 の pipeline 統合を進めて頂けますか?」 (2026-09-01)。 chat-Claude 2026-09-01 dialogue で 提示された 「既存 AI に実装不可能だが必要不可欠な チューンアップ用パーツ」 4 件のうち、 4 番目 = 停止条件 の 実装。

「モデルは『もう分からない』を内部から検出できない。 境界を外部から宣言する装置 (locate_first_error → boundary_report → escalate の流れ) が これに当たります。」 (chat-Claude, 2026-09-01)

本 STEP 直前 状態:

3 primitive + 1 composer

File役割Signature (要約)
locate-first-error.tsReasoningStep[] を scan、 最初の non-TRUE 位置を pinlocateFirstError(steps) → FirstErrorLocation | Error
boundary-report.tsFirstErrorLocation → 構造化 Boundary + suggestedTargetboundaryReport(location) → Boundary
escalate.tsBoundary → EscalationPayload + 任意 ledger anchorescalate(boundary, opts) → EscalationPayload
run-pipeline.ts3 primitive を 一本 に 繋いだ default 経路runStoppingCondition(input) → Outcome | Error

決定表 — 停止条件の mapping

Table L (locateFirstError, stopKind 分類)

#ConditionstopKind
L1steps.length === 0 or 非 arrayerror 'invalid-input'
L2全 step が TRUEall-clear
L3最初の non-TRUE = NEITHERneither-halt
L4最初の non-TRUE = FALSEfalse-violation
L5最初の non-TRUE = ZEROzero-void
L6最初の non-TRUE = BOTH/INFINITY/FLOWING/SELFother-nondefinite

Table B (boundaryReport, kind → suggestedTarget)

#BoundaryKindsuggestedTarget意味
B1all-clearnone境界 打たず pass-through
B2neither-haltw48-negcap「判定不能」 は W-48 Negative Capability 保留に流す
B3false-violationexternal-oracle「主張が破れた」 は rei-checker-mcp / Lean 4 等 別 verifier
B4zero-voidhuman「値の不在」 は 藤本さん judgment
B5other-nondefinitepeer-reviewBOTH/INFINITY/FLOWING/SELF は 別 model / chat-Claude cross-check

Table E (escalate, anchor behavior)

#ConditionledgerAnchor
E1boundary.kind === 'all-clear'skip (anchor 不要、 target='none')
E2anchorToLedger === false / undefinedskip (フィールド undefined)
E3anchorToLedger === true, fn 未指定{appended:false, reason:'no-anchor-fn'}
E4anchorToLedger === true, fn 成功{appended:true, entryHash, entrySeq}
E5anchorToLedger === true, fn throw{appended:false, reason:'anchor-threw:<msg>'}

統合先 (既存部品との接続)

Test 結果 — 89/89 PASS + upstream regression clean

SectionPASS/Total内容
1. locateFirstError 決定表19/19invalid-input 3 + all-clear + NEITHER/FALSE/ZERO/BOTH/INFINITY/FLOWING/SELF 各 kind + index/counts/step 保持
2. boundaryReport mapping16/165 kind × suggestedTarget + lastClaim propagation + honestScope
3. escalate payload & anchor20/20all-clear skip + override + default target + anchor 4 状態 (false/no-fn/success/throw) + emittedAt ISO
4. runStoppingCondition pipeline18/18invalid + 全 stopKind 経由 + override + anchor 呼出 + all-clear anchor skip + throw graceful
5. Integration invariants16/168 verdict × expected target + successCount 単調性 + payload preservation + escalationId 一意性
合計89/890 fail
Regression — STEP 163148/48invariance-checker v0.1 (dep upstream)
Regression — STEP 164750/50LLM-judge comparator v0.1 (dep upstream)

使い方 (例)

import { runStoppingCondition } from './src/aios/stopping-condition';

const outcome = runStoppingCondition({
  sequenceId: 'proof-attempt-42',
  steps: [
    { stepId: 'lemma-1', claim: 'H holds', verdict: 'TRUE',    reason: 'checker:pass', source: 'rei-checker-mcp' },
    { stepId: 'lemma-2', claim: 'H⇒G',    verdict: 'TRUE',    reason: 'checker:pass', source: 'rei-checker-mcp' },
    { stepId: 'lemma-3', claim: 'G⇒K',    verdict: 'NEITHER', reason: 'undecidable',  source: 'invariance-checker' },
    { stepId: 'lemma-4', claim: 'K holds', verdict: 'TRUE',    reason: 'checker:pass', source: 'rei-checker-mcp' },
  ],
  anchorToLedger: true,
  ledgerAnchorFn: myLedgerAppender,   // dependency-injected
});

if ('error' in outcome) throw new Error(outcome.error);
console.log(outcome.summary);
// → "stopping-condition | seq(2/4) | kind=neither-halt | target=w48-negcap | anchor=ok"

// outcome.escalation で 外部 (W-48 保留 / MCP tool / UI) に渡す payload 取得
// - boundary.location.step で 停止した step の 詳細 access
// - boundary.suggestedTarget で default target
// - escalation.ledgerAnchor.entryHash で tamper-evident 記録の pin

Honest scope (v0.1)

  1. Pure pipeline のみ: LLM 呼出 / 外部 verifier 実起動 / 人間通知 は 一切 行わない。 payload 生成のみ。 async 版は v0.2+ candidate。
  2. Verdict correctness は 上流責任: ReasoningStep.verdict は caller が 用意 (invariance-checker / rei-checker-mcp 経由 想定)。 本 module は verdict の 正しさ について 主張しない。
  3. Ledger anchor は Dependency Injection: ledgerAnchorFn は caller 提供、 STEP 1638 hash-chained ledger の 実 wire は 別 STEP candidate。 v0.1 は test で mock fn を 使う。
  4. SuggestedTarget は default: targetOverride で 上書き可、 mapping は caller の 運用に合わせて 別 module で 拡張可。
  5. 「最初の non-TRUE」 の shallow scan のみ: 複数 boundary の 同時検出 / hierarchical stopping (sub-sequence 内 stop) は 未対応、 v0.2+ candidate。
  6. MCP surface 未 wire: rei-aios MCP tool として の 公開は 別 STEP candidate (STEP 1644 agent-connector-mcp の 手続 参照、 execute mode 非公開 discipline を 参考に)。

次 STEP candidate

関連 file

STEP 1554 atomic-commit protocol dogfood 33 例目。 3 tab 併走中 独立 arc、 藤本さん 4 部品 statement (chat-Claude 2026-09-01) 直接 応答、 STEP 1651 番号 = npx tsx scripts/claim-step.ts --slug stopping_condition_pipeline_v01 で 中央 counter から 一意取得済。