From cef3a6c917b4d500bef3e92adf03fd69b880e97d Mon Sep 17 00:00:00 2001 From: Zhenhao Liu <176368005+LikC1606@users.noreply.github.com> Date: Tue, 1 Dec 2026 15:25:34 +0800 Subject: [PATCH 1/2] Check native team proof routes before assigning helpers Have Lead prove sufficiency and record independent review before delegating a helper. Reuse the conditional proof for assembly and include short Lean-checked signatures in delivery notices. --- research/PROTOCOL.md | 4 +- .../0011-native-proof-route-design.md | 14 +++++++ scripts/test-codex-backend.ts | 6 +-- skills/theoremos-research/SKILL.md | 40 ++++++------------- .../references/parallel-work.md | 6 +-- .../references/portfolio.md | 22 +++++++--- .../references/team-roles.md | 32 ++------------- src/runtime/codexSession.ts | 18 ++++----- src/solver/agentTeam.ts | 8 +++- src/solver/agentTeamContext.ts | 33 ++++++--------- src/solver/agentTeamProfiles.ts | 7 +--- src/solver/skillResearchContext.ts | 29 ++++++-------- tests/agentTeamContextContract.test.ts | 3 ++ tests/agentTeamNativeLifecycle.test.ts | 2 +- tests/agentTeamNativeTools.test.ts | 4 +- tests/codexSessionAgentControl.test.ts | 6 +-- tests/codexSessionInstructions.test.ts | 12 ++---- tests/skillContextContinuation.test.ts | 2 +- 18 files changed, 111 insertions(+), 137 deletions(-) create mode 100644 research/decisions/0011-native-proof-route-design.md diff --git a/research/PROTOCOL.md b/research/PROTOCOL.md index 38e540ce..9c6fa6a8 100644 --- a/research/PROTOCOL.md +++ b/research/PROTOCOL.md @@ -2,7 +2,7 @@ Version: v1 Status: Implemented(隔离分支的本地功能验收;未启用真实求解) -Updated: 2026-11-27 +Updated: 2026-12-01 ## 已确认的目标 @@ -33,6 +33,8 @@ Updated: 2026-11-27 默认协作取向是围绕当前共同证明路线解决互补缺口,必要时短时探索备选路线;Lead 根据实际证据自主改变分解和路线。这不规定证明方法、固定专家顺序或每题必须启动的成员数。成员默认不独立重复研究整个原题;每项工作的价值在于其结果能改变研究判断、补足所需输入或推进原始目标。 +需要拆解的原题,由 Lead 从冻结目标倒推,在 `RESEARCH.md` 保存证明蓝图及关键缺口,并让未参与该步骤设计的原生成员独立复核。蓝图标出每条拟议引理的用途、假设、适用范围和待证条件。条件检查核对这些条件能否推出原题,条件本身仍须证明。复核未能决定路线时可以继续探索。有清楚的直接证明时可直接验算。路线判断由原生团队负责,整题通过仍由宿主独立验收。见[决策 0011](decisions/0011-native-proof-route-design.md)。 + 这一取向现已进入固定 Skill 的协作和工作职责指引;运行时保留 Lead 专属派工/采纳和成员直接消息,并加入共同研究摘要、固定版本研究成果引用及单任务撤销/替换。指引和接口的存在不证明模型已能合理分解、互补选角、去重或调整路线,预算、并发值和效果评测标准继续按既有约定。 ## 已确认的下一轮改进目标(待实现) diff --git a/research/decisions/0011-native-proof-route-design.md b/research/decisions/0011-native-proof-route-design.md new file mode 100644 index 00000000..f8bd784d --- /dev/null +++ b/research/decisions/0011-native-proof-route-design.md @@ -0,0 +1,14 @@ +--- +id: "0011" +title: 需要拆解的证明先由原生团队设计路线并复核 +status: accepted +date: "2026-12-01" +decided_by: 用户(路线设计 Q1) +related: + - research/PROTOCOL.md + - research/decisions/0010-native-team-runtime-only.md +--- + +# 0011 — 需要拆解的证明先由原生团队设计路线并复核 + +用户选择把证明蓝图和独立复核放进原生团队的 Lead 工作流程。对需要拆解的原题,Lead 先确认关键引理的精确条件、应用位置及其如何推出冻结目标,并由另一位成员复核最脆弱的推论,再派正式引理任务。结论未定时继续研究关键缺口,直接证明已清楚时可以直接验算。路线可行性需要数学判断,由团队根据证据调整。宿主继续根据冻结原题和固定源码验收最终证明。 diff --git a/scripts/test-codex-backend.ts b/scripts/test-codex-backend.ts index b3102edd..10cd71a2 100644 --- a/scripts/test-codex-backend.ts +++ b/scripts/test-codex-backend.ts @@ -183,9 +183,9 @@ const server = createServer(async (request, response) => { 'A cold resume or full-history fork must not inherit Lead authority as its current mode.'); } else { assert.match(mode, /You are the Lead of an explicitly requested flat team\./u); - assert.match(mode, /Proactively delegate useful complementary work/u); - assert.match(mode, /concrete gaps with a consumer and first usable result/u); - assert.match(mode, /instead of competing for the same deliverable/u); + assert.match(mode, /Use native delegation for distinct gaps/u); + assert.match(mode, /Follow the pinned Lead charter for scouting, review and formal assignments/u); + assert.match(mode, /Only Lead dispatches or interrupts members/u); } const modeChecks = observations.modeChecks ??= {}; modeChecks[member ?? 'lead'] = (modeChecks[member ?? 'lead'] ?? 0) + 1; diff --git a/skills/theoremos-research/SKILL.md b/skills/theoremos-research/SKILL.md index 258502d3..85436573 100644 --- a/skills/theoremos-research/SKILL.md +++ b/skills/theoremos-research/SKILL.md @@ -5,36 +5,20 @@ description: Conduct sustained mathematical research in a TheoremOS workspace, u # TheoremOS research -Work toward the frozen original statement. Choose the mathematical approach, research decomposition and next experiment from the evidence available. Read the actual owned sources and relevant definitions early. Once a claim or library application can be tested, save a focused Lean probe and inspect its result before building more work on it. +Work toward the frozen original statement. Read owned sources and relevant definitions early. Use focused Lean probes to test claims or library applications before relying on them. Find commands and delivery formats in `.scratch/theoremos-help.md`. -The current host assignment fixes your role, owned paths and available tools. Use native editing, shell and search within its permissions; delegation also requires an exposed, permitted tool. Choose a tool when its answer would change the next step. A direct proof can go straight to the supplied Lean check. For an experiment, look up the relevant command in this run's `.scratch/theoremos-help.md`, which also gives the delivery interface. +Follow the host's role and file permissions. Preserve original declarations and add independent helpers only in editable Lean files. Keep experiments in the documented scratch paths. In `RESEARCH.md`, save established results, assumptions, evidence, and the first open step so another session can continue. -Use the native collaboration tools for spawn, followup, messaging, waiting, listing and interruption. Use `theoremos_team` for mathematical evidence, source handoffs and adoption. If the host requires route approval, Lead calls `publish_plan` with a goal for each original target, then returns so the owner can review it. +Use native collaboration for assignments, messages and turn control, and `theoremos_team` for mathematical evidence, handoffs and adoption. Lead follows the injected [charter](references/team-roles.md#lead--organize-and-connect-the-work). If the host requires route approval, call `publish_plan` with a goal for each original target and return for review. -When `theoremos_team` is exposed, Lead organizes a flat team using the [Lead charter](references/team-roles.md#lead--organize-and-connect-the-work), which the host injects into Lead's stable instructions at startup and continuation. Assign concrete gaps with usable outputs and keep one owner per active obligation, including Lead's own work. While a member owns a gap, Lead advances its consumer or another gap and integrates findings. Follow [parallel-work.md](references/parallel-work.md) for the current operation contracts. +Members send the first usable finding, probe or blocker through `send_message` with the exact claim, assumptions and evidence. Save sources and notes, then `submit` for checking or `yield` for a dependency and return. Lead saves before requesting adoption. Preserve provenance when using peer results. Only independent host checks accept proofs or admit library results. Use the host's feedback to continue. -Choose expertise for the specific missing concept, assumption or formal interface. Use the [assignment format](references/parallel-work.md#identity-and-assignments) to select a member profile or tag work by route when useful. The host loads profile material for reading on demand. Give the member its gap, known inputs, intended consumer and first useful result. Say what work remains with you. The member chooses its proof approach. +Work without budgets by default and respect configured shared limits. Avoid fixed reporting intervals, task quotas and Lead reserves. Read the references relevant to the next step. -Members send the first usable finding, probe result or blocker through `send_message`, with the exact claim or question, assumptions and available evidence. Do not wait for every subgoal before reporting. Private reasoning is not a team update. These are research milestones, without fixed polling intervals, message counts or task quotas. - -Use native `followup_task` for further instructions and `interrupt_agent` to stop a turn; drafts and history persist. Name the specific loaded knowledge and its application when relevant; loading evidence and reported use are distinct. Inspection and adoption retain peer-result provenance; describe reused and assembled proofs accurately. Read [parallel-work.md](references/parallel-work.md) for the operation contracts. - -Frozen original declarations retain their statements, hypotheses and permitted source structure. Add independent helpers inside the exact editable Lean paths supplied by the host; the same filename in different members' worktrees denotes separate copies. Lead describes mathematical work while the host supplies file and delivery rules. Keep scratch experiments under the documented scratch paths; transfer useful helpers through the current owned-file delivery interface. Helpers may be checked while unrelated original goals remain open, but cannot depend on those holes or new axioms. - -Members write in their own workspaces and retain their native threads for follow-up assignments. When a helper answers the assignment, save sources and RESEARCH.md, `submit` and return. The host checks the declarations and notifies Lead. A dependency can instead require saving and `yield` so Lead can arrange adoption and resume the same task. Lead saves before adoption and returns after saving the complete original proof for independent checking. Work without budgets by default: do not invent task quotas or a Lead reserve. Respect explicitly configured shared run limits and actual host deadlines. - -Use these references when the work calls for them: - -- [Literature](references/literature.md): when a proof idea or missing result may be found in external sources. -- [Lean work](references/lean.md): when finding, testing or delivering formal declarations. -- [Continuation](references/continuation.md): when starting from saved work or preparing durable research artifacts. -- [Portfolio exploration](references/portfolio.md) describes bounded route scouting and falsification before proof work. -- [HuggingMath](references/huggingmath.md): when asked to export a completed result or transfer it into private Hub drafts. -- [Parallel work](references/parallel-work.md): when `theoremos_team` is exposed or an independent investigation can usefully run alongside the current task. -- [Domain experts](references/domain-experts.md): when a question calls for specialized mathematical knowledge. The subject index and subject-boundary table route to theories, concrete examples, counterexamples and connections with neighboring domains; read the selected profile and its relevant reading notes. -- [Domain materials](references/domain-materials.md): when a specialist needs subject background. Collected author and university sources have precise reading locations, original knowledge summaries and coverage limits; each domain profile links its relevant notes. -- [Team roles](references/team-roles.md): when choosing work responsibilities such as Researcher, Lean Prover, Engineer or Reviewer, or supporting expertise. Combine these with domain knowledge as useful and read only the selected details. - -Keep reproducible sources, citations and concise research notes that connect established results, assumptions and remaining gaps to their evidence. Save enough for another session to continue without a private conversation. - -The host independently checks fixed sources and environment for proof acceptance and reusable-library admission. Local diagnostics, review verdicts, completion messages and historical receipts do not grant current acceptance. Deliver through the current assignment and use its feedback. +- [Lean work](references/lean.md) for formal interfaces, diagnostics and delivery. +- [Route design](references/portfolio.md#design-the-route) for proof blueprints and tests of fragile steps. +- [Parallel work](references/parallel-work.md) for assignments, collaboration and source handoffs. +- [Team roles](references/team-roles.md), [domain experts](references/domain-experts.md), and [domain materials](references/domain-materials.md) for expertise and source reading. +- [Literature](references/literature.md) for permitted external results. +- [Continuation](references/continuation.md) for saved work and durable research artifacts. +- [HuggingMath](references/huggingmath.md) for requested export or transfer of completed results. diff --git a/skills/theoremos-research/references/parallel-work.md b/skills/theoremos-research/references/parallel-work.md index 8505d27f..896af928 100644 --- a/skills/theoremos-research/references/parallel-work.md +++ b/skills/theoremos-research/references/parallel-work.md @@ -22,7 +22,7 @@ Native followup supplies further instructions to a busy member, resumes a yielde ### Start and reassess -Use the [Lead charter](team-roles.md#lead--organize-and-connect-the-work) to identify useful complementary work from the statement and necessary definitions, before deriving the complete solution. Assign a concrete gap with an intended consumer and first usable output; the complete proof route or exact helper type need not be known. Identify what Lead retains so ownership includes Lead's own work. Use `spawn_agent` with a self-contained assignment. A catalogue survey is not a prerequisite. +Use the [Lead charter](team-roles.md#lead--organize-and-connect-the-work) to identify complementary work from the statement and definitions. Scouting and review can start while the route and helper types are open. For formal helper proofs, follow the charter's route check and review, then give the exact type. Name the consumer, the first usable output and the work Lead retains. Use `spawn_agent` with a self-contained assignment. When no useful assignment is ready, inspect the relevant definitions, run a focused probe or check an already clear direct proof. Reconsider ownership when a finding, failed check, blocker or new gap creates a useful question. An accepted dispatch records delegation; whether the work is complementary depends on its question and intended consumer. Lead chooses the route, timing and team size within host capacity. @@ -94,7 +94,7 @@ After an executed task's writer has stopped, the host saves a stable `sourceComm ### Source checking and adoption -Adopt by delivery ID when the checked interface fits. For a source review, `inspect` can page through a long frozen declaration using the same `deliveryId` and `changeIndex` with each `nextOffset`. +Adopt by delivery ID when the host notice confirms the expected signature from the assigned member. Use `inspect` if the signature is absent or you need to examine other changes. For a source review, page through a long frozen declaration with `deliveryId`, `changeIndex` and each `nextOffset`. For a new auxiliary `def` or `abbrev`, add `"kind":"definition"` to that declaration in `submit`. Supply its full closed type and name in the existing editable file; omit `kind` for theorem/lemma declarations. A consumer adopts the checked implementation. Submit claims about its behavior as separate theorems. This does not allow replacing an existing definition or transferring new files, structures or instances. @@ -106,7 +106,7 @@ A child submitting Lean work supplies 1–32 declarations, each with `file`, ful Draft sources from a deferred or rejected delivery remain part of the next submission. List their changed declarations as well as the new corrections; only a successful delivery advances this source baseline. A stopped child may receive a checked peer adoption while retaining its own unfinished draft. The host preserves that draft and its delivery baseline, rechecks the integration and reports conflicts. Later submissions still list all of the child's own unpublished changes; adopted peer declarations are already tracked by the host and need not be manually resubmitted as new work. -For adoption into Lead, save current sources and RESEARCH.md, call `adopt` and return. A queued adoption also triggers an automatic handoff before the next model request: the current paid response and its tools finish, the writer stops, and only then does the host freeze sources, recheck and integrate the selected delivery. It continues the saved Lead thread with feedback; no polling for this integration or additional request is needed before the handoff. This scheduling step imposes no token, time or turn allowance. Adoption into a child requires that target to be idle, with no active writer, and returns a queued request. The host completes pending integration before dispatching its follow-up work, so Lead may send the consumer instructions after requesting adoption. Read the adoption status and feedback before treating the declarations as available. Native messages and interruption remain available while the host checks that adoption. A conflict or failed recheck is reported to Lead. Do not copy a peer's mutable files or edit another worktree or host state to bypass this protocol. +Before adopting into Lead, save current sources and record the consumer's next edit and draft path in RESEARCH.md. Call `adopt` and return. A queued adoption triggers an automatic handoff before the next model request. The current paid response and its tools finish, the writer stops, and the host freezes sources, rechecks and integrates the delivery. On confirmed adoption, resume from the saved draft and integrated source and check the completed proof. If the host reports a failure, address that diagnostic. Adoption into a child requires an idle target with no active writer. The host finishes the integration before dispatching the child's follow-up. Do not copy a peer's mutable files or edit another worktree or host state to bypass adoption. Keep organizing useful work while children are active. On host recovery, an interrupted assignment retains its sources and thread but needs an explicit new assignment to continue. Pending checking and adoption retain their saved identities. An unconfirmed writer stop prevents further writing or acceptance in that workspace. diff --git a/skills/theoremos-research/references/portfolio.md b/skills/theoremos-research/references/portfolio.md index e43cb13a..befd7c50 100644 --- a/skills/theoremos-research/references/portfolio.md +++ b/skills/theoremos-research/references/portfolio.md @@ -1,11 +1,21 @@ # Portfolio exploration -Use this stage when the host assigns bounded scouting before formal proof work. Read the frozen statement and record a route that makes its hardest inference smaller. Save a short blueprint, key transformations, and exact candidate interfaces for small shared lemmas. Keep Lean sources unchanged. Use scratch files for reproducible calculations and small Lean API probes. +## Design the route -- `structural-symmetry` looks for invariant quantities, coordinate changes, symmetries, convexity, and monotone reductions. -- `explicit-constructive` looks for formulas, rational bounds, witnesses, and direct constructions. -- `falsification-obstruction` tests fragile intermediate claims, aiming for explicit counterexamples, degeneracy, or combinatorial blowup. Use a focused Python, PARI/GP, SymPy, or finite constraint probe when it can decide a step. +In `RESEARCH.md`, name the route and frozen target. Work backward through the implications. Mark inputs as Lean-checked, justified on paper, or open. State the hardest claim with exact hypotheses, quantifiers, cases and bounds. For each helper, identify its consumer and what makes it easier. Cite applicable checked results, pinned Mathlib declarations or permitted literature and match their hypotheses. Keep stronger assumptions and restated gaps open. -Report `proposed` for a viable blueprint, `refuted` when you can name the exact failed claim and provide a concrete witness or obstruction, and `inconclusive` when an experiment or search has not settled it. Include the assumptions, reproduction command, result, and saved probe references. State which route ID the evidence concerns. Numerical approximations may motivate a test. Give exact bounds or a reproducible witness before retiring a route. +Use one hole-free Lean probe under `.scratch/tmp` as both the sufficiency check and the draft for assembly. Run it with the pinned project environment, for example `lake env lean --root=../.. ../../.scratch/tmp/Route.lean` from `generated/problem` in a standard task worktree. Supply the exact open inputs as hypotheses and derive the frozen conclusion, or record the scope and remaining gap of a partial check. Reuse a suitable existing probe and record its residual hypotheses. If Lean setup blocks the test, save the paper derivation with its hypotheses and verification status. The inputs still need proofs. -The gate selects a primary route and may keep one backup. Start proof work with the primary route's shared foundation lemmas and mark the consumer of each. Keep the persisted reasons and evidence for retired routes available to the team. Reconsider a dead end only when new evidence addresses its recorded obstruction. All scout reports and gate decisions are advisory. The host verifies every proof against the frozen Lean problem. +Start independent review once the helper claim, intended application and a question that could change the route are clear. Give the reviewer the exact assumptions and relevant evidence as it becomes available. Review the risky premise or application with a focused argument or probe. Send the reasoned verdict or blocker as soon as it is ready, then save the supporting note and return once the review question is settled. Reuse the conditional proof for the steps it already checks. A search without counterexamples settles a claim only if it exhausts a justified finite reduction. Save revised claims, changed evidence and remaining gaps. + +## Scout a route + +For host-assigned scouting, leave Lean sources unchanged. Save a short blueprint, key transformations and exact candidate lemma interfaces. Use scratch files for reproducible calculations and Lean probes. + +- `structural-symmetry` looks for invariants, coordinate changes, symmetries, convexity and monotone reductions. +- `explicit-constructive` looks for formulas, rational bounds, witnesses and constructions. +- `falsification-obstruction` tests fragile claims for counterexamples, degeneracy or combinatorial blowup. + +Report the route ID, assumptions, reproduction command, result and probe references. Use `proposed` for a viable blueprint, `refuted` for an exact failed claim with a witness or obstruction, and `inconclusive` otherwise. Use exact bounds or a reproducible witness to support retirement. + +The gate selects a primary route and may keep one backup. Prove the primary route's shared lemmas with named consumers. Preserve retirement evidence and reopen only when new evidence addresses the obstruction. The host verifies proofs independently of scout reports and gate decisions. diff --git a/skills/theoremos-research/references/team-roles.md b/skills/theoremos-research/references/team-roles.md index 9990c3d3..8acca4d3 100644 --- a/skills/theoremos-research/references/team-roles.md +++ b/skills/theoremos-research/references/team-roles.md @@ -46,37 +46,13 @@ A member reads the selected sections and the current assignment before working. ### Lead — organize and connect the work -Own a connected proof effort that closes the frozen original targets. Divide work by the mathematical result or formal interface needed, not by agent names, tactics or coordinate systems. Keep one owner per active proof obligation, including your own work. Use specialist results as inputs to the shared proof; your own research and Lean work advances their consumer, the connecting argument or another unassigned gap. +Read the frozen targets and relevant definitions. Check a clear direct proof in Lean when delegation is optional. When a helper route is clear, Lead develops it. Scout only a named uncertainty that could change the route. Reuse existing findings and give the conditional proof one owner. -If several goals share a measure change, algebraic construction, or comparison estimate, commission independent, small typed lemmas for that foundation first. Land and reuse them before you dispatch the large consumer proofs. Delegate exploratory computation and use the planning turn to review evidence, choose a route, and publish assignments. Tag work by route when it helps track alternatives. When concrete evidence refutes a route, use `retire_route` with its ID, scoped reason, and evidence references so its unfinished work stops immediately. +For a helper route, fix the exact interfaces and ask an independent native reviewer to challenge its riskiest premise while you check that the helpers imply the target. As soon as both checks support the same route, record the probe and the reviewer's reasoned verdict briefly in `RESEARCH.md` and dispatch the formal proof. A substantive native verdict is enough for this decision. Retrieve the archived report later if needed. Resolve objections and revisit only the checks affected by a route change. Follow the [route design guide](portfolio.md#design-the-route). -Lead and members can call `route_summary` for a compact snapshot before changing direction or reusing a result. Pass `routeId` to focus the assignments and checked deliveries, or set `includeRetired: false` to hide retired branches. The snapshot includes shared landed helper signatures. Use `history` for full task text and `inspect` for exact declarations and proof evidence. +Give each obligation one owner, including the original proof. At dispatch give the helper's exact name, type, consumer and relevant evidence. Keep the checked conditional proof in scratch as the assembly draft. While the helper is being proved, finish any remaining assembly there. If the task requires a member proof, leave the dependent target open in `Submission.lean` until you adopt the checked helper, then apply the draft. Checking a complete submission can end the run. Follow the [assignment and handoff guide](parallel-work.md). -Look for useful complementary work after reading the statement and necessary definitions, before deriving the complete solution; see [start and reassess](parallel-work.md#start-and-reassess). A missing argument, library application, boundary claim or route-discriminating question is enough to assign; an exact helper type can be negotiated with the member. Avoid solving a gap merely to make it assignable. If a direct proof is already clear and no useful independent question remains, check it without filling agent slots. Reassess ownership when a failed probe, library-interface uncertainty or substantial new gap creates useful work. No opening acknowledgment or fixed sequence of collaboration decisions is required. - -A useful split might give the member one existence lemma while you show how its witness implies the original conclusion. Send the hypotheses and expected output, identify the inference you retain, and let the member choose its proof. Ask for the first usable finding, probe result or blocker as soon as it is available. Independent declarations that answer the assignment should be saved, submitted and returned for host checking before optional extensions. An investigation can instead return an advisory finding, exact interface or blocker. - -An assignment can be as short as this. - -```text -Profiles: prover -Prove the extension lemma with the current finiteness hypothesis. I will use it in the final existence argument. -Send the smallest usable Lean type or the first extra hypothesis the extension needs. -``` - -For a short alternate route investigation, name the test that will decide the route. For example, ask whether a library theorem applies with the exact hypotheses of the current consumer. If it needs a stronger hypothesis, send that hypothesis and the failed application. Lead decides whether to keep the current route or assign the missing bridge. - -When a missing witness, suspected counterexample or unclear boundary motivates a calculation, give the member the mathematical question, assumptions and intended consumer. Leave the choice of tool to the member. A finite search or picture can suggest where to look; ask for the witness, failed assumption or testable claim the consumer can use. If the result affects the proof, use it in a check or say how it changes the assignment. - -When you commission a Lean helper, agree on its qualified name, type and where the consumer will use it. Write that call in your owned proof draft while the member proves the helper. The name can remain unresolved until adoption. To test the surrounding argument earlier, use a scratch example that takes the proposed type as a hypothesis. Leave the helper definition to its owner, including any equivalent local `have`; a same-name placeholder can also conflict with the delivered declaration. If the route changes, tell the member before taking over. - -Before spawning, decide who will write the original proof. If you intend to write it, give the member a named input you will use. If you hand it over, tell the member both sides of the assignment, for example: “You own the original proof; I will test whether this library lemma supplies the hypothesis you need and send you the result.” Do that work in your own workspace and leave the original proof to the member. A spare slot, a backup proof, or your duty to inspect the finished work does not supply a second task. With no separate question, continue on your own. If independent reconstruction is itself required evidence, name the decision that needs two independent proofs and preserve that independence. - -On a checked delivery, compare its type with the call in your draft. If they match and the route still needs it, save the draft and notes, request `adopt` into the consumer workspace and return. The host integrates the declaration before checking the combined source; you do not need a standalone proof before adopting. If the type differs, change the call or ask for a revision. If the route no longer needs the result, continue without adopting it. Treat findings and blockers on their merits and resolve a yielded member's dependency before continuing its task. - -When a counterexample, missing hypothesis or failed application challenges a step someone is using, check the precise claim against the evidence. Tell the affected members which step changes, what evidence resolves the objection, or which specific result would let you decide. Leave that decision and its evidence reference in a message or RESEARCH.md so the next turn can pick it up. A failed search alone does not refute a claim; routine updates need no acknowledgment. - -Member claims, native completion and local checks are advisory. Formal adoption requires a delivery ID produced after save/submit/return, confirmed writer shutdown and independent host checking. Helpers still need their application to every original target. Preserve provenance and use host feedback for final acceptance. Choose team size freely within host capacity; invent no quotas or reserves. +Record refutations in `RESEARCH.md`. For a refuted route with assigned work, notify affected members and call `retire_route` with scoped evidence. ## Member profiles diff --git a/src/runtime/codexSession.ts b/src/runtime/codexSession.ts index 4b84bdfc..a736b91f 100644 --- a/src/runtime/codexSession.ts +++ b/src/runtime/codexSession.ts @@ -520,10 +520,11 @@ export async function createCodexMathSession(options: MathAgentOptions): Promise ? 'You are a member of an explicitly requested flat team. Carry out the Lead assignment and exchange findings through native messages. ' + 'Send the first usable finding, probe result or blocker without waiting for a complete proof. ' + 'Do not spawn sub-agents or dispatch, redirect or interrupt other members. Ask Lead when responsibility or a dependency needs to change.' - : 'You are the Lead of an explicitly requested flat team. Proactively delegate useful complementary work through the native collaboration tools and connect the results to your own work. ' + - 'Follow the pinned Lead charter: assign concrete gaps with a consumer and first usable result. Say in the assignment what you will work on. If a member takes the original target, hand over its proof and work on that separate question instead of competing for the same deliverable. ' + - 'The team request authorizes you to spawn and direct members without asking again. Only Lead dispatches or interrupts members; members may communicate directly. ' + - 'Choose tasks and team size for the work within the host\'s capacity.', + : 'You are the Lead of an explicitly requested flat team. Use native delegation for distinct gaps. ' + + 'Follow the pinned Lead charter for scouting, review and formal assignments. Give one author the conditional proof and review the riskiest premise in parallel. ' + + 'Once the sufficiency check and independent verdict support the same route, record both and dispatch the helper proof promptly. Reuse the checked scratch proof for assembly. ' + + 'If the task requires a member proof, leave the dependent target incomplete in Submission.lean until you adopt the checked helper. ' + + 'Only Lead dispatches or interrupts members. Members may message one another.', } as const : {}) }, }; let closing: Promise | undefined; @@ -835,13 +836,8 @@ export async function createCodexMathSession(options: MathAgentOptions): Promise approvalPolicy: 'never', ...(isolated ? { sandbox: 'danger-full-access' } : {}), ...(isolated ? { baseInstructions: formalizationBaseInstructions } : {}), developerInstructions: options.instructions + '\n\n' + - 'Shell execution: login shells are disabled to preserve the prepared proof environment. ' + - 'For every exec_command call, explicitly set "login": false; do not use login: true or rely on the default. ' + - 'Omit both justification and sandbox_permissions, including empty or default values; this session already has its permission policy. ' + - 'If the tool explicitly rejects a call before execution because login shells are disabled or the arguments are invalid ' + - '(for example, justification requires sandbox_permissions), the command did not execute: ' + - 'retry the same command with "login": false and without justification or sandbox_permissions, then continue the task. ' + - 'Do not replay a command merely because it exited with an error or its execution result is unclear; inspect that result first.', + 'For every exec_command call, explicitly set "login": false. Omit justification and sandbox_permissions entirely. ' + + 'If the tool rejects the arguments before execution, retry with corrected arguments. Inspect exit errors and unclear results before deciding whether to retry.', config: { mcp_servers: disabled, 'features.apps': false, diff --git a/src/solver/agentTeam.ts b/src/solver/agentTeam.ts index f253ed0b..53eebc68 100644 --- a/src/solver/agentTeam.ts +++ b/src/solver/agentTeam.ts @@ -1182,8 +1182,14 @@ export class AgentResearchTeam { worker.pendingDelivery = undefined; worker.pendingSourceBase = undefined; worker.pendingPeerDeliveries = undefined; const ready = delivery.declarations.slice(0, 8).map(item => item.name).join(', '); const more = delivery.declarations.length - 8; + const checkedType = delivery.declarations.length === 1 + ? delivery.artifacts[0]?.proof.verification.results[0]?.elaboratedDeclarationType + : undefined; + const signature = checkedType && Buffer.byteLength(checkedType, 'utf8') <= 512 + ? '\nLean signature: ' + checkedType + : ''; const checked = 'Lean checked ' + ready + (more > 0 ? ' and ' + more + ' more' : '') + - '. Use this deliveryId to adopt into the workspace that needs the declarations. Inspect it for exact types or evidence as needed.'; + '.' + signature + '\nUse this deliveryId to adopt into the workspace that needs the declarations. Inspect when you need more evidence.'; this.event(worker.id, 'lead', 'delivery', checked + (task.summary ? '\n' + task.summary : ''), { taskId: task.id, deliveryId: delivery.id, researchArtifactId: task.researchArtifactId }); } catch (error) { diff --git a/src/solver/agentTeamContext.ts b/src/solver/agentTeamContext.ts index f768701d..20fd9a77 100644 --- a/src/solver/agentTeamContext.ts +++ b/src/solver/agentTeamContext.ts @@ -7,27 +7,20 @@ export type AgentTeamAssignment = Readonly<{ taskId: string; message: string; so /** Stable authority and identity; professional profiles live in the pinned skill and current assignment. */ export function agentTeamInstructions(role: AgentTeamRole, maxAgents: number): string { - const shared = 'This run uses native AgentControl collaboration with isolated writer workspaces. ' + + const shared = 'Use native AgentControl in isolated worktrees. ' + 'Call collaboration tools directly in their exposed namespace, not through functions.exec. A child\'s final answer is automatically delivered to its parent. ' + - 'Native tools target canonical agent paths or native thread IDs. Mathematical host operations use the workspace member IDs in the team observation. ' + - 'The pinned Skill and selected profiles supply mathematical knowledge and team methods. ' + - 'Source files, notes and native thread persist across assignments. Only write in your own permitted workspace. ' + - 'The theoremos_team tool handles source handoffs and fixed evidence. Findings, native final answers and local checks are advisory; ' + - 'only stopped-writer host checks publish checked delivery IDs, and independent checks of every frozen original target accept the original problem.\n'; - if (role.role === 'lead') return 'You are the Lead of a flat mathematical research team; your workspace member ID is lead and your native path is /root. ' + - 'This team run explicitly authorizes you to spawn and coordinate useful child agents through the native collaboration tools. ' + - `At most ${maxAgents} agents including you may be available. ` + - 'As soon as you identify a proof step you can advance, work on it in your Lean files. Keep writing the consuming argument or another unassigned gap while members work. ' + - 'Use native spawn_agent for concrete independent gaps found in the frozen statement. ' + - 'Omit model and reasoning_effort when calling spawn_agent so members inherit the frozen run configuration. ' + - 'If several goals share a mathematical foundation, assign and check its small Lean interfaces before dispatching the consuming goals. ' + - 'For a native spawn or followup, put an optional Route: ROUTE_ID line first, then an optional Profiles: line of comma-separated IDs or slugs, then the assignment. Use theoremos_team retire_route with the obstruction and evidence refs to stop a refuted route. ' + - 'Idle members still occupy their places. Use native followup_task to reuse a member for another gap or specialty; interrupt_agent stops its turn and preserves its place and work. ' + - 'If a member is handing off sources or waiting for a host check, continue other work until it finishes. ' + - 'When resuming a paused draft, adopt the missing result or give a concrete next step based on new evidence. ' + - 'Only Lead dispatches, interrupts and adopts; members can exchange findings directly. ' + - 'Adopt a checked delivery when its interface fits. Use inspect for exact declarations and evidence when needed. For adoption into your own workspace, save sources and notes, request adoption and return. ' + - 'Save all original proofs and return for independent host checking. Use finish to request early handoff.\n' + shared; + 'Use canonical agent paths or thread IDs with native tools and the observed workspace member IDs with theoremos_team. ' + + 'Write only in your permitted workspace. Sources, notes and threads persist across assignments. ' + + 'Use theoremos_team for handoffs and fixed evidence. Only host checks after writer shutdown publish checked delivery IDs.\n'; + if (role.role === 'lead') return 'You are the Lead of a flat mathematical research team (member ID lead, native path /root). ' + + `You may delegate using the native collaboration tools. At most ${maxAgents} agents including you may be available. ` + + 'Use spawn_agent for concrete independent gaps. Omit model and reasoning_effort to inherit the frozen configuration. ' + + 'Put optional Route: then Profiles: headers before the assignment. Use member profiles such as reviewer or prover. The lead profile is reserved for you.\n' + + 'Only Lead dispatches, interrupts and adopts. Members may message peers. Idle members still occupy slots. ' + + 'Reuse them with followup_task. Use interrupt_agent to stop a turn and keep its draft and slot. ' + + 'Resolve dependencies or give a concrete next step before resuming a paused member.\n' + + 'Use the checked delivery notice to match the expected signature and adopt by ID. Inspect if the notice leaves compatibility unclear. Save before adoption into Lead, then return. On resume, apply the saved draft to the adopted source. ' + + 'Save all original proofs and return for host checking. Use finish for early handoff.\n' + shared; return `You are a mathematical researcher and Lean proof writer; your workspace member ID is ${JSON.stringify(role.id)} and your coordinator is /root (lead). ` + 'Carry out the current Lead assignment; the frozen original problem supplies background and source constraints. ' + 'Use native send_message for the first usable finding, probe result or blocker without waiting for the complete proof. Include the exact claim, assumptions and available evidence. ' + diff --git a/src/solver/agentTeamProfiles.ts b/src/solver/agentTeamProfiles.ts index 95cb0f8d..3a8cd64c 100644 --- a/src/solver/agentTeamProfiles.ts +++ b/src/solver/agentTeamProfiles.ts @@ -162,11 +162,8 @@ function resolveProfiles(skill: MathAgentSkill, selected: string[], coordinator: (selected.length ? '' : 'No catalogue profile was selected. Read references/domain-experts.md and references/team-roles.md for relevant knowledge; clarify a missing specialization with Lead.\n') + (unresolved.includes('lead') ? 'The lead profile is reserved for your coordinator. Continue as a member on your assigned question.\n' : '') + (unresolved.some(name => name !== 'lead') ? 'Unresolved names may describe custom expertise. Use the assignment to clarify that knowledge; do not claim a catalogue passage was loaded for them.\n' : '') + - 'Use relevant definitions, assumptions and distinctions from the injected profile; choose your own proof approach. ' + - 'Read linked material only when it addresses a concrete missing concept. Sources marked available-on-demand are locators, not loaded text. ' + - 'This record distinguishes supplied knowledge from available reading. When useful, report knowledge actually used with its source anchor and application. ' + - 'The source locators identify collected notes, not a new external-source read ' + - 'or proof acceptance.\n' + passages.join('\n\n') }; + 'Read on-demand sources for concrete gaps. Use loading labels to distinguish injected passages from optional reading. Cite the source anchor and application for profile knowledge used.\n' + + passages.join('\n\n') }; return { section: context, evidence }; } diff --git a/src/solver/skillResearchContext.ts b/src/solver/skillResearchContext.ts index 51c9f0ce..4828311b 100644 --- a/src/solver/skillResearchContext.ts +++ b/src/solver/skillResearchContext.ts @@ -93,16 +93,13 @@ export function buildSkillResearchContext(problem: SolverProblem, state: Readonl // Coordinator identity comes from the host, never from an assignment's Profiles line. const leadProfile = team && !teamWorker ? resolveAgentTeamLeadProfile(skill).section : undefined; const cards = state.researchDelegation?.mode === 'team' ? state.researchDelegation.personalExperts?.cards : undefined; - const cardCatalogue = !teamWorker && cards?.length ? 'User-selected professional knowledge available for member assignments. ' + - 'When a card fits a concrete gap, put its exact ID on the first Profiles: line of spawn or followup. ' + - 'Only the assigned member receives its advisory text. Catalogue: ' + + const cardCatalogue = !teamWorker && cards?.length ? 'User expert cards: select a relevant ID with Profiles:. Only its assigned member receives the card text. ' + JSON.stringify(cards.map(({ assetId, name, version, summary }) => ({ id: 'asset:' + assetId, name, version, summary }))) + '\n\n' : ''; const preferred = !teamWorker && state.researchDelegation?.mode === 'team' ? state.researchDelegation.preferredProfiles : undefined; const preferenceInstruction = preferred?.length ? 'User-preferred member profiles: ' + eligibleAgentTeamProfiles(path.dirname(skill.path)).filter(profile => preferred.includes(profile.id)) .map(profile => profile.id + ' (' + profile.name + ')').join(', ') + '. ' + - 'Consider these when they fit a concrete gap. You choose whether to delegate and may use any other catalogued specialty. ' + - 'To give a member profile knowledge, put its ID on the Profiles: line of that assignment.\n\n' : ''; + 'Select these or other relevant catalogue IDs with Profiles:.\n\n' : ''; const instructions = (state.researchDelegation?.mode === 'team' ? agentTeamInstructions(access.teamRole ?? { id: 'lead', role: 'lead' }, state.researchDelegation.maxAgents) : '') + (leadProfile ? leadProfile.text + '\n\n' : '') + preferenceInstruction + cardCatalogue + @@ -110,19 +107,19 @@ export function buildSkillResearchContext(problem: SolverProblem, state: Readonl 'The frozen original problem is background and source constraints; the assignment defines the result you own.\n' : 'Research the fixed original mathematics problem in this isolated worktree using the pinned theoremos-research skill.\n') + `Lean project: ${project}. Editable Lean paths relative to it: ${JSON.stringify(editable)}. ` + - 'Only these paths may contain submitted Lean source; add helpers inside them instead of creating another Lean file. ' + - (team ? 'Every member has a separate worktree. Identical relative filenames belong to different copies; Lead does not own the member\'s copy. ' : '') + - `Public research notes: ${path.join(access.worktree, 'RESEARCH.md')}. Temporary experiments and requests belong in .scratch/tmp or the documented .scratch paths.\n` + - 'For original declarations, keep kinds, names, types, hypotheses, options and scopes fixed. Edit only permitted proof/definition bodies. ' + - 'You may add independent helper declarations inside the editable owned Lean files; the original-declaration restriction does not prohibit these additions. ' + - 'Preserve trusted files, frozen definitions and all existing imports. In a Mathlib project, you may add import Mathlib or any pinned Mathlib.* import in editable files without creating import cycles. ' + - 'Accepted proofs cannot use sorry, admit, native_decide, unsafe or new axioms. Independent helpers may be submitted while other goals remain unfinished. ' + - 'Do not read external candidate solutions. Do not edit the pinned skill, host help, configuration or receipts. ' + - 'A message, local diagnostic or historical receipt is never acceptance. The host freezes sources after writer shutdown and checks every original target. ' + - 'There is no host task graph in this mode. Execution-limit observations describe any stage and hard deadlines. ' + + 'Submit Lean code, including new helpers, only in these files. ' + + (team ? 'Each member has a separate worktree and its own copy of these paths. ' : '') + + `Save public notes in ${path.join(access.worktree, 'RESEARCH.md')} and experiments or requests under the documented .scratch paths.\n` + + 'Edit only permitted bodies of original declarations. Keep their kinds, names, types, hypotheses, options and scopes fixed. ' + + 'Preserve trusted files, frozen definitions and existing imports. In a Mathlib project, editable files may import pinned Mathlib or Mathlib.* without cycles. ' + + 'Proofs must be free of sorry, admit, native_decide, unsafe and new axioms. You may submit standalone helpers while unrelated goals remain open.\n' + + 'Do not read external candidate solutions. Leave the pinned Skill, host help, configuration and receipts unchanged. ' + + 'Only independent host checks of every frozen original target after writer shutdown establish acceptance. ' + + 'Choose your own decomposition. Follow reported execution limits.\n' + (team ? '' : 'Native child delegation is disabled in this run.\n') + (leanCheckCommand ? `Lean check for an editable file (run from any directory):\n${leanCheckCommand}\n` : '') + - toolSummary + longCommandSummary + help.instruction(access.worktree) + mathematicsRuntimeInstruction(access.environment.DEEPSCIENTIST_MATH_ENV_FILE); + toolSummary + (leadProfile ? '' : longCommandSummary) + help.instruction(access.worktree) + + mathematicsRuntimeInstruction(access.environment.DEEPSCIENTIST_MATH_ENV_FILE); const originalProblem: ContextSection = { id: 'original-problem', kind: 'problem', text: (teamWorker ? 'Frozen original problem (background for your current Lead assignment):\n' : '') + access.taskText + '\n\n' + JSON.stringify({ problemReceiptDigest: problem.receiptDigest, environmentDigest: state.environmentDigest, diff --git a/tests/agentTeamContextContract.test.ts b/tests/agentTeamContextContract.test.ts index 9e940e87..3a20efb7 100644 --- a/tests/agentTeamContextContract.test.ts +++ b/tests/agentTeamContextContract.test.ts @@ -86,6 +86,7 @@ describe('native team context contract', () => { expect(agentTeamOperationAllowed('lead', request.operation)).toBe(false); expect(leadHelp).toContain('operation submit'); expect(leadHelp).toContain('only for your own Lead worktree'); + expect(leadHelp).toContain('## long-commands'); expect(memberHelp).toContain('operation submit'); expect(memberHelp).not.toContain('declaration-submission.json'); for (const context of [lead, member]) { @@ -119,6 +120,8 @@ describe('native team context contract', () => { expect(full.instructions).toContain('Lead of a flat mathematical research team'); expect(full.instructions).toContain('Call collaboration tools directly in their exposed namespace, not through functions.exec.'); expect(full.instructions).toContain('A child\'s final answer is automatically delivered to its parent.'); + expect(full.instructions).toContain('.scratch/theoremos-help.md'); + expect(full.instructions).not.toContain('Read local tool-help section "long-commands"'); } expect(agentTeamOperationAllowed('member', 'poll')).toBe(false); } diff --git a/tests/agentTeamNativeLifecycle.test.ts b/tests/agentTeamNativeLifecycle.test.ts index 595ccfac..9a388a1f 100644 --- a/tests/agentTeamNativeLifecycle.test.ts +++ b/tests/agentTeamNativeLifecycle.test.ts @@ -596,7 +596,7 @@ describe('native AgentControl preserves the mathematical team lifecycle', () => expect(worker.tasks[1].deliveryId).toBe(f.state.agentTeam!.deliveries[0].id); expect(f.state.agentTeam!.events.find(event => event.kind === 'delivery')).toMatchObject({ deliveryId: worker.tasks[1].deliveryId, - text: expect.stringContaining('Lean checked NativeTeam.reusable.'), + text: expect.stringContaining('Lean signature: NativeTeam.reusable (n : Nat) : n = n'), }); expect(f.state.phase).toBe('running'); }, 70_000); diff --git a/tests/agentTeamNativeTools.test.ts b/tests/agentTeamNativeTools.test.ts index dcecbe6c..52079407 100644 --- a/tests/agentTeamNativeTools.test.ts +++ b/tests/agentTeamNativeTools.test.ts @@ -372,11 +372,11 @@ describe.skipIf(!nativeAvailable || !process.env.THEOREMOS_TEST_CODEX_EXECUTABLE if (child) { expect(mode).toContain('You are a member of an explicitly requested flat team.'); expect(mode).toContain('Do not spawn sub-agents or dispatch, redirect or interrupt other members.'); - expect(mode).not.toContain('Proactively delegate useful complementary work'); + expect(mode).not.toContain('Use native delegation for distinct gaps.'); modes.member.add(mode!); } else { expect(mode).toContain('You are the Lead of an explicitly requested flat team.'); - expect(mode).toContain('Proactively delegate useful complementary work'); + expect(mode).toContain('Use native delegation for distinct gaps.'); modes.lead.add(mode!); } let item: Json; diff --git a/tests/codexSessionAgentControl.test.ts b/tests/codexSessionAgentControl.test.ts index 5db3b80d..384d23d3 100644 --- a/tests/codexSessionAgentControl.test.ts +++ b/tests/codexSessionAgentControl.test.ts @@ -154,7 +154,7 @@ describe('native AgentControl stdio integration without model calls', () => { const start = calls().find(call => call.method === 'thread/start').params; expect(start.config).toMatchObject({ 'features.multi_agent': true, 'features.multi_agent_v2': { enabled: true, root_agent_usage_hint_text: '', subagent_usage_hint_text: '', - multi_agent_mode_hint_text: expect.stringContaining('Proactively delegate useful complementary work') }, + multi_agent_mode_hint_text: expect.stringContaining('Use native delegation for distinct gaps.') }, 'features.defer_mailbox_preemption': true, 'skills.include_instructions': false, 'agents.enabled': true }); expect(session.nativeConfiguration).toEqual({ source: 'thread-start-overrides', overrides: { includeSkillInstructions: false, deferMailboxPreemption: true, rootAgentUsageHintText: '', subagentUsageHintText: '', @@ -220,8 +220,8 @@ describe('native AgentControl stdio integration without model calls', () => { expect(delegation).toContain('first usable finding, probe result or blocker'); expect(delegation).toContain('without waiting for a complete proof'); } else { - expect(delegation).toContain('concrete gaps with a consumer and first usable result'); - expect(delegation).toContain('instead of competing for the same deliverable'); + expect(delegation).toContain('Follow the pinned Lead charter for scouting, review and formal assignments'); + expect(delegation).toContain('Only Lead dispatches or interrupts members'); } expect(calls().some(call => call.method === 'skills/list')).toBe(true); const input = calls().find(call => ['turn/start', 'theoremos/agentControl/input'].includes(call.method)).params; diff --git a/tests/codexSessionInstructions.test.ts b/tests/codexSessionInstructions.test.ts index a5f69038..4ee4096b 100644 --- a/tests/codexSessionInstructions.test.ts +++ b/tests/codexSessionInstructions.test.ts @@ -57,14 +57,10 @@ describe('base instructions for isolated formalization sessions', () => { const message = 'Review the complete frozen INPUT.json and OUTPUT.schema.json.\nDo not omit either conclusion.'; const calls = () => fs.readFileSync(traceFile, 'utf8').trim().split('\n').map(line => JSON.parse(line)); const expectShellCallContract = (text: string) => { - expect(text).toContain('login shells are disabled'); - expect(text).toContain('"login": false'); - expect(text).toContain('Omit both justification and sandbox_permissions, including empty or default values'); - expect(text).toContain('this session already has its permission policy'); - expect(text).toContain('explicitly rejects a call before execution'); - expect(text).toContain('justification requires sandbox_permissions'); - expect(text).toContain('retry the same command with "login": false and without justification or sandbox_permissions'); - expect(text).toContain('Do not replay a command merely because it exited with an error or its execution result is unclear'); + expect(text).toContain('explicitly set "login": false'); + expect(text).toContain('Omit justification and sandbox_permissions entirely'); + expect(text).toContain('rejects the arguments before execution, retry with corrected arguments'); + expect(text).toContain('Inspect exit errors and unclear results before deciding whether to retry'); }; const options = (isolated: boolean, resume: boolean): MathAgentOptions => ({ executable, profile, workspace: root, model: 'gpt-6.1-sol', effort: 'max', instructions, onUsage: vi.fn(), diff --git a/tests/skillContextContinuation.test.ts b/tests/skillContextContinuation.test.ts index 07298ba9..2ded84d4 100644 --- a/tests/skillContextContinuation.test.ts +++ b/tests/skillContextContinuation.test.ts @@ -182,7 +182,7 @@ describe.each([{ common: false, mode: 'standalone skill' }, { common: true, mode expect(continued.message).toContain('declaration-feedback.json'); expect(continued.message).toContain('RESEARCH.md'); expect(continued.instructions).toBe(full.instructions); - expect(continued.instructions).toContain('Accepted proofs cannot use sorry'); + expect(continued.instructions).toMatch(/(?:Accepted proofs cannot use|Proofs must be free of) sorry, admit, native_decide, unsafe (?:or|and) new axioms/u); expect(Buffer.byteLength(continued.message)).toBeLessThan(Buffer.byteLength(full.message)); expect(continued.manifest?.included.some(item => item.id === 'original-problem')).toBe(false); expect(continued.manifest?.included.some(item => item.kind === 'feedback')).toBe(true); From 99dde53e2dd98539afaae8f87b6795f0a854c849 Mon Sep 17 00:00:00 2001 From: Zhenhao Liu <3100378030@qq.com> Date: Tue, 1 Dec 2026 17:03:06 +0800 Subject: [PATCH 2/2] Clarify native Lead route prompts (#83) Name the Lead's hole-free scratch file the route probe and use that term in the Lead hint, charter and route design guide. Lead owns the probe and uses it as the assembly draft while an independent reviewer challenges the riskiest premise. Restore short rules for delivery signature mismatches, objections and counterexamples, same-name placeholders, advisory member claims and route_summary. Tell route-feasibility reviewers to send their verdict promptly. Update a test that still asserted removed Lead text. Co-authored-by: Zhenhao Liu <176368005+LikC1606@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 --- skills/theoremos-research/references/portfolio.md | 4 ++-- skills/theoremos-research/references/team-roles.md | 10 ++++++---- src/runtime/codexSession.ts | 6 +++--- src/solver/agentTeamContext.ts | 2 +- tests/solverSoftSliceCompaction.test.ts | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/skills/theoremos-research/references/portfolio.md b/skills/theoremos-research/references/portfolio.md index befd7c50..4f3147ac 100644 --- a/skills/theoremos-research/references/portfolio.md +++ b/skills/theoremos-research/references/portfolio.md @@ -4,9 +4,9 @@ In `RESEARCH.md`, name the route and frozen target. Work backward through the implications. Mark inputs as Lean-checked, justified on paper, or open. State the hardest claim with exact hypotheses, quantifiers, cases and bounds. For each helper, identify its consumer and what makes it easier. Cite applicable checked results, pinned Mathlib declarations or permitted literature and match their hypotheses. Keep stronger assumptions and restated gaps open. -Use one hole-free Lean probe under `.scratch/tmp` as both the sufficiency check and the draft for assembly. Run it with the pinned project environment, for example `lake env lean --root=../.. ../../.scratch/tmp/Route.lean` from `generated/problem` in a standard task worktree. Supply the exact open inputs as hypotheses and derive the frozen conclusion, or record the scope and remaining gap of a partial check. Reuse a suitable existing probe and record its residual hypotheses. If Lean setup blocks the test, save the paper derivation with its hypotheses and verification status. The inputs still need proofs. +Write one hole-free route probe under `.scratch/tmp`. It is both the sufficiency check and the assembly draft. Run it with the pinned project environment, for example `lake env lean --root=../.. ../../.scratch/tmp/Route.lean` from `generated/problem` in a standard task worktree. Supply the exact open inputs as hypotheses and derive the frozen conclusion, or record the scope and remaining gap of a partial check. Reuse a suitable existing probe and record its residual hypotheses. If Lean setup blocks the test, save the paper derivation with its hypotheses and verification status. The inputs still need proofs. -Start independent review once the helper claim, intended application and a question that could change the route are clear. Give the reviewer the exact assumptions and relevant evidence as it becomes available. Review the risky premise or application with a focused argument or probe. Send the reasoned verdict or blocker as soon as it is ready, then save the supporting note and return once the review question is settled. Reuse the conditional proof for the steps it already checks. A search without counterexamples settles a claim only if it exhausts a justified finite reduction. Save revised claims, changed evidence and remaining gaps. +Lead starts independent review once the helper claim, its application and a question that could change the route are clear, and gives the reviewer the exact assumptions and evidence as they become available. The reviewer tests the risky premise or application with a focused argument or probe, sends the reasoned verdict or blocker as soon as it is ready, then saves the supporting note and returns. Steps the route probe already checks need no second review. A search without counterexamples settles a claim only if it exhausts a justified finite reduction. Save revised claims, changed evidence and remaining gaps. ## Scout a route diff --git a/skills/theoremos-research/references/team-roles.md b/skills/theoremos-research/references/team-roles.md index 8acca4d3..d4943d64 100644 --- a/skills/theoremos-research/references/team-roles.md +++ b/skills/theoremos-research/references/team-roles.md @@ -46,11 +46,13 @@ A member reads the selected sections and the current assignment before working. ### Lead — organize and connect the work -Read the frozen targets and relevant definitions. Check a clear direct proof in Lean when delegation is optional. When a helper route is clear, Lead develops it. Scout only a named uncertainty that could change the route. Reuse existing findings and give the conditional proof one owner. +Read the frozen targets and relevant definitions. If a direct proof is clear, check it in Lean yourself without delegating. Otherwise design the route yourself with the [route design guide](portfolio.md#design-the-route). Reuse existing findings first; `route_summary` shows assignments, checked helpers and recent deliveries. Scout only a named uncertainty that could change the route. -For a helper route, fix the exact interfaces and ask an independent native reviewer to challenge its riskiest premise while you check that the helpers imply the target. As soon as both checks support the same route, record the probe and the reviewer's reasoned verdict briefly in `RESEARCH.md` and dispatch the formal proof. A substantive native verdict is enough for this decision. Retrieve the archived report later if needed. Resolve objections and revisit only the checks affected by a route change. Follow the [route design guide](portfolio.md#design-the-route). +For a helper route, fix each helper's exact name and type. You own the route probe: one hole-free scratch file that takes the helpers as hypotheses and derives the frozen target. In parallel, ask an independent `reviewer` member to challenge the riskiest premise. When the probe passes and the reviewer's reasoned verdict supports the route, record both briefly in `RESEARCH.md` and dispatch the helper proofs. The reviewer's native message is enough for this decision; do not wait for its saved report. If the reviewer or another member reports an objection, counterexample or failed application, check the precise claim, tell affected members which step changes and record the decision in `RESEARCH.md`. Redo only the checks the change affects. -Give each obligation one owner, including the original proof. At dispatch give the helper's exact name, type, consumer and relevant evidence. Keep the checked conditional proof in scratch as the assembly draft. While the helper is being proved, finish any remaining assembly there. If the task requires a member proof, leave the dependent target open in `Submission.lean` until you adopt the checked helper, then apply the draft. Checking a complete submission can end the run. Follow the [assignment and handoff guide](parallel-work.md). +Give each obligation one owner, including the original proof. At dispatch give the helper's exact name, type, consumer and relevant evidence. The route probe is also your assembly draft: finish the remaining assembly there while helpers are proved. Do not define a helper or a same-name placeholder yourself; it conflicts with the delivered declaration. If the task requires a member to prove a helper, keep the dependent target open in `Submission.lean` until you adopt that helper, because a host check of a complete submission can end the run. Follow the [assignment and handoff guide](parallel-work.md). + +On a checked delivery, compare its Lean signature with the call in your draft. If they match and the route still needs it, adopt it and then apply the draft. If they differ, change the call or ask for a revision. If the route no longer needs it, continue without adopting. Member claims, native completion and local checks are advisory; only host checks accept proofs. Record refutations in `RESEARCH.md`. For a refuted route with assigned work, notify affected members and call `retire_route` with scoped evidence. @@ -122,7 +124,7 @@ Deliver reproducible outputs, candidate witnesses or patterns, their verified sc Check the thread's history when discussing independence. `inspected` records a direct tool read; `possible-via-parent` means the parent had inspected a delivery before this member inherited its conversation. It does not show which source the reviewer actually read. `adopted` records source made available through adoption. An unknown fork history or an empty exposure list does not establish a blind review. -Choose a review scope that can change a decision. For **route feasibility**, challenge the hardest premise and whether its proposed inputs suffice for the consumer; identify whether the difficulty merely moved into an assumption. For **statement meaning**, independently explain the formal statement from its definitions before comparing it with the intended informal question. For **candidate proof**, compare fixed declarations, assumptions and proof evidence with the original targets and inspect any concrete discrepancy. +Choose a review scope that can change a decision. For **route feasibility**, challenge the hardest premise and whether its proposed inputs suffice for the consumer; identify whether the difficulty merely moved into an assumption. Send Lead the reasoned verdict or blocker with `send_message` as soon as it is ready; Lead may dispatch on it before your saved report. For **statement meaning**, independently explain the formal statement from its definitions before comparing it with the intended informal question. For **candidate proof**, compare fixed declarations, assumptions and proof evidence with the original targets and inspect any concrete discrepancy. Lead should select a member who did not author or substantially develop the reviewed artifact. Use a fresh child when available if prior participation prevents independence; a role change in the same producing thread does not erase that history. Supply the fixed claim, definitions, source version and evidence without prescribing the verdict. A team child receives the frozen original problem, including any supplied informal statement; a fresh thread alone therefore does not provide a blind meaning review. Record your own reading before comparing it with the intended question, and call the comparison blind only if the host actually withheld the expected reading. If no independent member is available, label the check as non-independent and preserve that limitation. diff --git a/src/runtime/codexSession.ts b/src/runtime/codexSession.ts index a736b91f..60ca6d38 100644 --- a/src/runtime/codexSession.ts +++ b/src/runtime/codexSession.ts @@ -521,9 +521,9 @@ export async function createCodexMathSession(options: MathAgentOptions): Promise 'Send the first usable finding, probe result or blocker without waiting for a complete proof. ' + 'Do not spawn sub-agents or dispatch, redirect or interrupt other members. Ask Lead when responsibility or a dependency needs to change.' : 'You are the Lead of an explicitly requested flat team. Use native delegation for distinct gaps. ' + - 'Follow the pinned Lead charter for scouting, review and formal assignments. Give one author the conditional proof and review the riskiest premise in parallel. ' + - 'Once the sufficiency check and independent verdict support the same route, record both and dispatch the helper proof promptly. Reuse the checked scratch proof for assembly. ' + - 'If the task requires a member proof, leave the dependent target incomplete in Submission.lean until you adopt the checked helper. ' + + 'Follow the pinned Lead charter for scouting, review and formal assignments. For a helper route, check your route probe while an independent reviewer challenges its riskiest premise. ' + + 'Once both support the route, record them and dispatch the exact helper types promptly. The route probe is your assembly draft. ' + + 'If the task requires a member to prove a helper, keep the dependent target open in Submission.lean until you adopt it. ' + 'Only Lead dispatches or interrupts members. Members may message one another.', } as const : {}) }, }; diff --git a/src/solver/agentTeamContext.ts b/src/solver/agentTeamContext.ts index 20fd9a77..9c66cca9 100644 --- a/src/solver/agentTeamContext.ts +++ b/src/solver/agentTeamContext.ts @@ -19,7 +19,7 @@ export function agentTeamInstructions(role: AgentTeamRole, maxAgents: number): s 'Only Lead dispatches, interrupts and adopts. Members may message peers. Idle members still occupy slots. ' + 'Reuse them with followup_task. Use interrupt_agent to stop a turn and keep its draft and slot. ' + 'Resolve dependencies or give a concrete next step before resuming a paused member.\n' + - 'Use the checked delivery notice to match the expected signature and adopt by ID. Inspect if the notice leaves compatibility unclear. Save before adoption into Lead, then return. On resume, apply the saved draft to the adopted source. ' + + 'Compare the Lean signature in a checked delivery notice with the call in your draft and adopt by ID. Use inspect if the notice has no signature or leaves compatibility unclear. Save before adoption into Lead, then return. On resume, apply the saved draft to the adopted source. ' + 'Save all original proofs and return for host checking. Use finish for early handoff.\n' + shared; return `You are a mathematical researcher and Lean proof writer; your workspace member ID is ${JSON.stringify(role.id)} and your coordinator is /root (lead). ` + 'Carry out the current Lead assignment; the frozen original problem supplies background and source constraints. ' + diff --git a/tests/solverSoftSliceCompaction.test.ts b/tests/solverSoftSliceCompaction.test.ts index bdfa4d7a..5ac1b692 100644 --- a/tests/solverSoftSliceCompaction.test.ts +++ b/tests/solverSoftSliceCompaction.test.ts @@ -80,7 +80,7 @@ describe('soft research milestones', () => { : /standalone helper.*fewer than 20 lines.*RESEARCH\.md/u; expect(notify.mock.calls).toEqual([[expect.stringMatching(notice), { mode: 'advisory' }]]); if (trigger === 'team') { - expect(options.instructions).toContain('spawn and coordinate useful child agents'); + expect(options.instructions).toContain('You may delegate using the native collaboration tools'); expect(notify.mock.calls.flat()).not.toContainEqual(expect.stringContaining('declaration-submission.json')); // This file is handled after the turn, outside the whole-proof diagnostics watcher. expect(options.completedOutput?.file).toMatch(/lean-diagnostics-latest\.json$/u);