Skip to content

feat(orchestrator): PolicyLoop — SELT self-healing control layer over…#1

Open
dfu925-ux wants to merge 88 commits into
mainfrom
feature/policy-loop
Open

feat(orchestrator): PolicyLoop — SELT self-healing control layer over…#1
dfu925-ux wants to merge 88 commits into
mainfrom
feature/policy-loop

Conversation

@dfu925-ux

Copy link
Copy Markdown
Owner

Co to robi

Warstwa PolicyLoop — samonaprawczy pipeline SELT nad niezmienionym Orchestrator.run_loop/4. Wpięcie przez huki, bez przepisywania jądra routingu TRINITY.

Wdrożone prace badawcze

  • SELT (arXiv:2506.07557) — tryby :learn/:think/:mimic/:recite jako struktury promptu (Mode).
    • Control-R (arXiv:2506.00189) — Reasoning Control Fields → budżet tokenów per stan + meta-prompt.
    • AIRL-S/PRM (arXiv:2508.14313) — agregacja PRM-Min (najsłabsze ogniwo).
    • LLaMA-Berry/PPRM (NAACL 2025) — relatywne ocenianie kandydatów (drift guard).

Bezpieczeństwo

  • AuditGate z 3 rozdzielnymi licznikami (trinity_turns / self_heal / citeclaw); twardy stop HITL przez {:shutdown, {:audit_gate, _}} pod supervisorem :transient.
    • Izolowany Executor: Docker + opcjonalny gVisor (--net none, --cap-drop=ALL, --read-only, --pids-limit).

Zmiany w jądrze (addytywne, wstecznie kompatybilne)

  • RoleInjector.inject_role/3 (stare /2 deleguje).
    • Orchestrator: prompt_directives w run_ctx + użycie /3.

Testy

  • 4 testy integracyjne PolicyLoop — zielone (sukces SELT, self-heal+regresja, trip safe-gate).
    • Pełny zestaw: 306 testów przechodzi. (3 lokalne failures w Parity.Check to artefakt CRLF z klonu na Windows — niezwiązane z tym PR, przechodzą na Linuksie/CI.)

dfu925-ux added 30 commits June 24, 2026 18:13
- do_turn: Keyword.split route_opts -> routing keys to CoordinationHead.route,
  generation keys (:max_tokens budget, :temperature, :reference_required)
  forwarded to agent dispatch. Fixes ArgumentError (unknown :max_tokens /
  temperature must be positive) surfaced by live run_loop.
- inference.ex: explicit per-call :inference_max_tokens/:inference_temperature
  now override the pool spec -> Control-R budget actually reaches the LLM API.
- scripts/phase6_scopeB_e2e.exs: full PolicyLoop E2E (host router + live Qwen,
  stubbed Executor). Validates SELT loop + AuditGate end-to-end.

mix test: no new regressions (306, 4 pre-existing env failures). Scope B: {:ok}.
…ct; <thought>/fence-safe extractor + unit test
…scoring; fix mock test for worker-response contract
…k) + fix B worker pool qwen-max->qwen-coder-plus + GLM discrimination test (3/3)
…— blind 47/54, oracle 48/54, zero false-accepts
…48->54/54 (87%->100%), A 42->52/54 (78%->96%). Sufit zniesiony - waskie gardlo bylo Workerem. B 44/54 (81,5%): petla<goly worker, GLM-verifier teraz waskim gardlem (+403 FreeTierOnly zanieczyszcza pomiar).
…e_fun). Napisane przez Qwen Worker, audyt Claude Core. 7 tests 0 failures. Marker [[cite:ID]], uchwyty nie payload (Konst. par.5), fail-closed (par.7). Zakres L1 (istnienie cytowania), NIE L2 (entailment).
…aw MCP client (Content-Length framing, fail-closed). E2E: real DOI verified, fake DOI rejected. 24 tests 0 failures.
…ugh reference gate; 8b regex rewritten pattern-engine-free (source policy); TRINITY_SANDBOX_RUNTIME moved to config/runtime.exs boundary; scripts/ excluded from source policy scan
…ter + injectable entailment seams, fail-closed, opt-in via retrieval_fun/entailment_fun. Written by Worker subagent, audited by Claude Core. 355 tests, 1 known env failure.
…eText retrieval_fun (fetch_pdf -> pdftotext, fail-closed, payload-free). Worker subagent, audit Claude Core. 378 tests, 1 known CUDA failure.
…n via DashScope, OpenAI-compatible). Injectable seams post_fun/api_key_fun, fail-closed on missing key/http/transport/bad output, errors carry only statuses+lengths, pattern-engine-free parsing. Worker subagent, audit Claude Core. 391 tests, 1 known CUDA failure.
…etch_pdf/pdftotext -> qwen3.7-max judge -> ClaimGate). ALL PASS: true claim SUPPORTED, false claim not_entailed, unregistered id rejected without LLM. Proven key/endpoint combo documented in-script.
…er (CiteClaw cite_fun + SourceText retrieval + EntailmentJudge judge), default model qwen3.7-max, DASHSCOPE key moved to runtime.exs boundary. 395 tests, 1 known CUDA failure.
…p 5, farthest-first kmeans, eigh orientation autodetect) on best-of-N, opt-in clustering/candidate_pool, injectable clustering_fun seam, fail-open fallback. 406 tests, 1 known CUDA failure. Worker subagent, audit + root-cause Claude Core.
… blind-Verifier termination to :recite; /ground cannot bypass ReferenceGate/ClaimGate. 3 new tests, 0 regressions, bypass closed E2E.
…terminal SELT stages skip sandbox execution (opt-in), inner run_loop cap injectable. /code E2E: 1439.18 in 85s, 1x run_loop (was 5-6x, 23min, AuditGate). Worker subagent, audit Claude Core. 415 tests, 1 known CUDA failure.
…er engine (Config/Coordinator/Runner/Formatter/History/CLI), seam contract mirrored 1:1 from assistant.exs (stage-aware /code, pass-through reference gate, empty-code guard, layer-0 depth classifier), contract-shape tests (opts kwlist, seam arities, slm_context). Qwen worker v2 after audit rejection v1, audit Claude Core. 424 tests, 1 known CUDA failure. Also versions scripts/assistant.exs (closes v18 debt).
…ract [[cite:ID]] in runner+mode :recite, injected entailment_fun (JUDGE_MODEL, max_tokens 1024), stage_aware_execution for /ground, StateManager.drop_empty (reasoning-burn poisoned history), worker max_tokens 512->2048, CiteClawClient: npx -y, non-sticky startup failure, timeout 15s->60s. Plus v20 web UI (web/, chat_ui, tests), README_ASSISTANT, judge 8->1024. NOT run through mix test (owner decision 08.07) - /ground E2E confirmed live 23:25-23:37.
…udge in ground contract, configurable ClaimGate :max_source_chars (default 4000 intact, /ground=60k: lexical window is cross-language blind, PL claim vs EN source picked random 2k slice), judge timeout 30s->120s for full-source verdicts, rejected-response snippet logging in citation gate (History only persists final result - 3 blind diagnoses in a row). claim_gate 14/14 green. Root cause found: worker refuses to cite arXiv 2506 as 'future paper' + thought-block truncation at 2048 - retrieval-first is next (HANDOFF v22).
… worker :recite prompt via base_opts seam, doc_id extraction arXiv/DOI from prompt (pattern-engine-free), SourceText fetch fail-open, shared 60k cap with L2 judge. 22 new tests green; remaining reds = pre-existing bc251eb policy debt + known CUDA. Worker subagent, audit + policy fixes Claude Core.
…ops labels (git=CMD, mix=WSL), retrieval-first E2E green
dfu925-ux added 30 commits July 15, 2026 21:54
…ource:<path>, L2-only, fail-closed); path-traversal fix + 12 tests (Codex impl, Claude audit)
…t) - reasoning models exhaust output cap before content
…osed for local sources) + single-line bench prompts
…ard + verdict-token strip + coordinator dir fail-fast (CRAG pilot v2: 17/20, FAR 1/20)
…ers), report upgrades (CI, FAR-strict/semantic, safety/liveness, canary E1), consultation lesson
…ig - n=30: 26/30 PASS, FAR-strict 0/30 (Wilson upper ~11%), FRR 3/30 + lessons (stepwise protocol, budget discipline)
…n + external validity caveat, demote coin-flip claim, v3 backlog (escalation hard cases)
… codes) - pure classifier + adapter wiring + server escalation seam (Laguna M.1 draft, Claude audit+completion); brief token fix for source policy
…ise-acceptance 3/30 vs system 0/30 both, FRR trade-off explicit (Qwen review follow-up: two-category split, resilient headline); baseline script + lessons (Anthropic block loop)
…tity grounding, cite schema, formatter fixes, hard cases H1-H5, second seed deferred to post-v3 (W2)
…ck + closed known_ids space + precise gate feedback to retry prompt (citation_feedback, no new counters); series prompt unified; 547 tests green
…ms about SOURCE content, world-claim ban, citeless F4 only when no source (signature unverifiable-refusal runs 5/23 + canary E1); frozen directive updated; 551 tests green
…on soft-halt candidates (max_turns + no_improvement, never gate-accepted) + thought-strip at output reusing Server.strip_thought (canary E1 findings 1-2); 558 tests green
…nal entity_qualifiers on handle, OR-match qualifier check in gate (audit fix: empty attribution fail-closed), entity_mismatch feedback via existing citeclaw channel, recite+series prompt contract; 575 tests green
…ence-escalation race confirmed (streak feeds on all SELT stages, citation counter only on recite; audit_gate checks stagnation arm first), regression pin test + control test, fix options deferred to owner decision per counters rule; 579 tests green
…lifiers curated, first candidate already qualified (Christopher Brown / Failed State), prompt clause works upstream, gate reject path proven in ExUnit; residual premise-acceptance noted for D2 iteration after D7d canaries
…pinned at unit+integration level (guard already existed, full contract); H1 registry hash-verification-unavailable run: soft escalation reference_failure with citeclaw 3/3, self_heal 0, trinity_turns 0, best_candidate nil - counter separation proven in vivo; 586 tests green
…SS (verdict-token prefix + fake marker + override instruction all inert, zero rejections, v1-run-3 regression closed); H4 contradictory sources AMBIGUOUS: model produced ideal per-source qualified answer, L2 judge rejected near-verbatim claim 3x (new FRR signature: meta-claims about sources vs entailment judge), fail-closed escalation, no silent preference, counters clean
…+ proven entity-divergence F2 refusal (prompt-only, counters/judge untouched)
…er separation (citeclaw soft vs self_heal hard), discard exploration script
…k; within-sentence compound reaches judge, cross-sentence dilution gap documented (last_sentence drops non-last sentence); deterministic, counters untouched
…ement closes cross-sentence citation-span dilution; conservative abbrev/initial-safe boundary, fail-safe; default off (legacy); counters/judge untouched
…build path + one-shot multi_sentence_segment correction feedback; default off (legacy), counters untouched
…source path (Q4/D7d gap closed end-to-end); assertion added
…ec zdania odmowy; walidacja live sedzia (ABSENCE-true :ok, ABSENCE-false reject); projekt (c) w rezerwie
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