BigPizzaV3/CodexPlusPlus · error
本批改变了共同目标根节点
Error message
本批改变了共同目标根节点
What it means
mergeBatch enforces a single shared root node (parent===null). If state already has a root and the merged node set's root differs from it, the whole batch is rejected. This prevents the model from replacing the conversation's common goal root mid-job.
Solutions
- Keep the original root node with parent:null unchanged in every batch
- Nest all changes under the existing root instead of creating a new one
- If a new goal is truly needed, restart organizeLong rather than mutating the root mid-run
- Instruct the model that the root id is immutable
Example fix
// before
{ id: 'new-goal', parent: null }
// after
{ id: 'existing-root-id', parent: null, summary: updatedSummary } Defensive patterns
Strategy: validation
Validate before calling
if (oldRoot && upserts.some(n => n.parent === null && n.id !== oldRoot.id)) throw new Error('root change attempted'); Try / catch
try { mergeBatch(...) } catch (e) { if (e.message === '本批改变了共同目标根节点') { rejectRootChange(); } else throw e; } Prevention
- Treat the root node id as immutable across batches
- Nest updates under the existing root
- Never emit a second parent:null node
- Document the root invariant in the task prompt
When it happens
Trigger: An upsert changes the existing root's parent, or a new node with parent:null is introduced while an old root exists (e.g. old root re-parented under a new node).
Common situations: Model tries to 're-organize' around a new goal node; resume flow where the model rewrites the hierarchy from scratch.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/05203ec85735668a.
Report an issue: GitHub.
Appendix: source
Thrown at tools/conversation-canvas/long-organizer.mjs:101
for(const n of value.upserts){
if(!n||typeof n.id!=='string'||patch.has(n.id)||(!allowed.has(n.id)&&(!n.id.startsWith(prefix)||old.has(n.id))))throw Error('本批节点 ID 无效或覆盖了未提供的节点');
if(!Array.isArray(n.sources)||!n.sources.length||!n.sources.every(id=>parts.has(id)))throw Error('本批引用了不存在的消息片段');
for(const field of ['title','summary','description','status'])if(typeof n[field]!=='string'||n[field].length>3000)throw Error('本批节点描述过长或无效');
const previous=old.get(n.id),evidence=[...(previous?.evidence||[])];
for(const id of new Set(n.sources)){covered.add(id);const {messageId,start,end,digest}=parts.get(id);evidence.push({messageId,start,end,digest});}
const revisions=[...(previous?.revisions||[])];
if(previous&&['summary','description','status'].some(k=>previous[k]!==n[k]))revisions.push({batch:state.batchCount,summary:previous.summary,description:previous.description,status:previous.status});
patch.set(n.id,{...n,sources:[...new Set([...(previous?.sources||[]),...n.sources.map(id=>parts.get(id).messageId)])],evidence,revisions});
}
if(covered.size!==batch.length){
const error=new Error('本批仍有未归入任务树的消息片段,进度未提交');
error.missingPartIds=batch.filter(part=>!covered.has(part.partId)).map(part=>part.partId);
throw error;
}
for(const n of patch.values())if(n.parent!==null&&!allowed.has(n.parent)&&!patch.has(n.parent)&&old.get(n.id)?.parent!==n.parent)throw Error('本批父节点未提供或不存在');
const nodes=state.nodes.map(n=>patch.get(n.id)||n);for(const [id,n] of patch)if(!old.has(id))nodes.push(n);
const oldRoot=state.nodes.find(n=>n.parent===null);
if(oldRoot&&nodes.find(n=>n.parent===null)?.id!==oldRoot.id)throw Error('本批改变了共同目标根节点');
const currentNodeId=value.currentNodeId??state.currentNodeId??null;
validateOrganization({requestId,nodes,currentNodeId},[...new Set(nodes.flatMap(n=>n.sources))].map(id=>({id})),requestId);
return {...state,schemaVersion:2,nodes,currentNodeId,batchCount:state.batchCount+1,done:{...state.done,...Object.fromEntries(batch.map(p=>[p.partId,true]))}};
}
// Save is an atomic durable checkpoint. A failed model call never commits its
// coverage; a restart can resume its pending side-chat turn before resubmitting.
export async function organizeLong({messages,record,save,run,signal,progress=()=>{},onGraph=()=>{},compact=false}){
const history=await prepareHistory(messages,signal);
const partIndex=new Map(history.parts.map(part=>[part.partId,part]));
const previous=record?.published;
let job=record?.job;
if(!job||!compatible(job.state.manifest,history.manifest)){
const incremental=previous?.done&&compatible(previous.manifest,history.manifest);
const state=incremental?{...previous,manifest:history.manifest}:{schemaVersion:2,nodes:[],currentNodeId:null,batchCount:0,done:{},manifest:history.manifest};
job={kind:incremental||!previous?.nodes?.length?'incremental':'rebuild',state,session:{},pending:null};
}else job={...job,state:{...job.state,manifest:history.manifest}};
let document={version:3,published:previous??null,job};View on GitHub (pinned to b1ed92e5e4)