@tomflow/chatloop-extension 0.4.45 → 0.4.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -33,17 +33,31 @@ if (message?.type === "CHAT_LOOP_APPROVAL_EVIDENCE_V1") {
|
|
|
33
33
|
return null;
|
|
34
34
|
const formId=lines[1].slice('formId:'.length).trim().toLowerCase();
|
|
35
35
|
const traceRef=lines[2].slice('traceRef:'.length).trim().toLowerCase();
|
|
36
|
-
const oldLabel=lines[4].match(/^选项标签:\s*A[||]\s
|
|
36
|
+
const oldLabel=lines[4].match(/^选项标签:\s*A[||]\s*确认(?:当前\s*)?([RP][1-9][0-9]*)\s*(需求|技术与验证方案|技术方案|方案)$/i);
|
|
37
37
|
const modernLabel=lines[3]==='选项值: approve'
|
|
38
38
|
&&/^选项标签:\s*A[||]\s*确认(需求|技术与验证方案|技术方案|方案)$/.exec(lines[4]);
|
|
39
|
+
// The visible "P2 final revision" is a semantic review cycle.
|
|
40
|
+
// The stored document can be P1 V3 after a cancelled V2; only the
|
|
41
|
+
// explicit physical V3 may become the trusted approval version P3.
|
|
42
|
+
const revisionLabel=lines[4].match(
|
|
43
|
+
/^选项标签:\s*A[||]\s*确认(?:当前\s*)?([RP][1-9][0-9]*)\s*V([1-9][0-9]*)[((]\s*([RP][1-9][0-9]*)\s*(?:最终)?修订稿[))]$/i);
|
|
44
|
+
const physical=Number(revisionLabel?.[2]||0);
|
|
45
|
+
const semantic=Number(revisionLabel?.[3]?.slice(1)||0);
|
|
46
|
+
const revised=revisionLabel&&revisionLabel[1].toUpperCase()===type+'1'
|
|
47
|
+
&&physical>=2&&revisionLabel[3][0].toUpperCase()===type
|
|
48
|
+
&&semantic>=2&&semantic<=physical;
|
|
39
49
|
const versions=[...formId.matchAll(/(?:^|[-_])([rp][1-9][0-9]*)(?=[-_]|$)/gi)]
|
|
40
50
|
.map(m=>m[1].toUpperCase());
|
|
41
|
-
const version=oldLabel?.[1]
|
|
51
|
+
const version=oldLabel?.[1]?.toUpperCase()
|
|
52
|
+
||(revised?type+String(physical):null)
|
|
42
53
|
||(modernLabel&&versions.length===1?versions[0]:null);
|
|
43
|
-
const label=oldLabel?.[2]
|
|
54
|
+
const label=oldLabel?.[2]
|
|
55
|
+
||(revised?(type==='R'?'需求':'方案'):modernLabel?.[1]);
|
|
44
56
|
if(!version||version[0]!==type||!label
|
|
45
57
|
||(type==='R')!==(label==='需求')
|
|
46
|
-
||(oldLabel&&versions.
|
|
58
|
+
||(oldLabel&&versions.some(v=>v!==version))
|
|
59
|
+
||revised&&versions.some(v=>v!==type+'1'&&v!==version
|
|
60
|
+
&&v!==revisionLabel[3].toUpperCase())
|
|
47
61
|
||formId===traceRef)return null;
|
|
48
62
|
return {version,formId,traceRef};
|
|
49
63
|
};
|
|
@@ -90,6 +104,17 @@ if (message?.type === "CHAT_LOOP_APPROVAL_EVIDENCE_V1") {
|
|
|
90
104
|
// Prefer an explicit current-version declaration. Historical mentions
|
|
91
105
|
// must not choose a version; ambiguous prose is not approval evidence.
|
|
92
106
|
const versionOf=(value,type)=>{
|
|
107
|
+
// An amended immutable P1/R1 document can be V3 while the human
|
|
108
|
+
// display still calls its review "P2 final revision". Prefer the
|
|
109
|
+
// explicitly marked CURRENT physical version, never the historical
|
|
110
|
+
// P1 V1/V2 recap or the human review-cycle alias.
|
|
111
|
+
const currentRevision=value.match(new RegExp(
|
|
112
|
+
"(?:^|\\n)\\s*当前版本\\s*V([1-9][0-9]*)\\s*[((]\\s*"
|
|
113
|
+
+type+"([1-9][0-9]*)\\s*(?:最终)?修订稿[))]","i"));
|
|
114
|
+
if(currentRevision&&Number(currentRevision[1])>=2
|
|
115
|
+
&&Number(currentRevision[2])>=2
|
|
116
|
+
&&Number(currentRevision[2])<=Number(currentRevision[1]))
|
|
117
|
+
return type+String(Number(currentRevision[1]));
|
|
93
118
|
// Real formal reviews may start with a status recap mentioning an
|
|
94
119
|
// an older plan version before the current issued revision heading.
|
|
95
120
|
// A unique, version-consistent line title outranks historical prose.
|
|
@@ -132,7 +157,9 @@ if (message?.type === "CHAT_LOOP_APPROVAL_EVIDENCE_V1") {
|
|
|
132
157
|
fail("APPROVAL_PLAN_MISSING");return false;
|
|
133
158
|
}
|
|
134
159
|
const pVersion=versionOf(textOf(pAssistant),"P");
|
|
135
|
-
const
|
|
160
|
+
const pUserForm=formApprovalVersion(textOf(pUser),'P');
|
|
161
|
+
const pUserVersion=pUserForm?.version
|
|
162
|
+
||textOf(pUser).match(/\bP[1-9][0-9]*\b/i)?.[0].toUpperCase();
|
|
136
163
|
if(pUserVersion && pVersion!==pUserVersion){
|
|
137
164
|
fail("APPROVAL_PLAN_VERSION_MISMATCH");return false;
|
|
138
165
|
}
|
|
@@ -145,7 +172,7 @@ if (message?.type === "CHAT_LOOP_APPROVAL_EVIDENCE_V1") {
|
|
|
145
172
|
// Context Start lease independently verifies the effective R approval.
|
|
146
173
|
const rUser=rIndex>=0?rows[rIndex]:null;
|
|
147
174
|
const rForm=rUser?formApprovalVersion(textOf(rUser),'R'):null;
|
|
148
|
-
const pForm=
|
|
175
|
+
const pForm=pUserForm;
|
|
149
176
|
if(rForm&&pForm&&(rForm.formId===pForm.formId
|
|
150
177
|
||rForm.traceRef===pForm.traceRef)){
|
|
151
178
|
fail('APPROVAL_FORM_REUSED');return false;
|
|
@@ -231,9 +258,18 @@ if (message?.type === "CHAT_LOOP_APPROVAL_EVIDENCE_V1") {
|
|
|
231
258
|
if(!pVersion||!rVersion||invalidated){
|
|
232
259
|
fail("APPROVAL_REVISED_OR_REVOKED");return false;
|
|
233
260
|
}
|
|
234
|
-
const rUserVersion=
|
|
261
|
+
const rUserVersion=rForm?.version
|
|
262
|
+
||textOf(rUser).match(/\bR[1-9][0-9]*\b/i)?.[0].toUpperCase();
|
|
235
263
|
const referencedR=textOf(pAssistant).match(/\bR[1-9][0-9]*\b/i)?.[0].toUpperCase();
|
|
236
|
-
|
|
264
|
+
// A versioned Form pair is independently reconciled against the
|
|
265
|
+
// immutable Context P.requirementRef and R/P approval records at
|
|
266
|
+
// permit.consume. Some valid revised-plan replies do not repeat R1 in
|
|
267
|
+
// their visible summary. Allow only this same-Chat, two-Form case;
|
|
268
|
+
// native/unscoped prose still requires an explicit R reference.
|
|
269
|
+
const formScopedRequirement=Boolean(explicitFormChat&&rForm&&pForm
|
|
270
|
+
&&rForm.version===rVersion&&pForm.version===pVersion);
|
|
271
|
+
if((!referencedR||referencedR!==rVersion)
|
|
272
|
+
&&!formScopedRequirement){
|
|
237
273
|
fail("APPROVAL_PLAN_REQUIREMENT_MISMATCH");return false;
|
|
238
274
|
}
|
|
239
275
|
if(rUserVersion && rVersion!==rUserVersion){
|
package/extension/manifest.json
CHANGED
|
@@ -83,7 +83,8 @@ async function scopedTaskRecoverCancel(message,sender){
|
|
|
83
83
|
if(fresh.runRevision!==stamped.runRevision
|
|
84
84
|
||fresh.run?.recoveryRequestId!==id)
|
|
85
85
|
throw cancelRecoveryFail('SCOPED_CANCEL_RECOVER_WORKER_CHANGED');
|
|
86
|
-
const
|
|
86
|
+
const {cancelReadSourceLost:historicalSourceFailure,...recoverable}=fresh.run;
|
|
87
|
+
const final={...recoverable,phase:'CANCELLED',
|
|
87
88
|
reason:'SESSION_CANCELLED',terminalAt:Date.now(),
|
|
88
89
|
nativeOwnerRevision:result.nativeOwnerRevision,
|
|
89
90
|
contextBindingRevision:result.contextBindingRevision};
|
|
@@ -6,6 +6,7 @@ async function reconcileScopedCancelled(){
|
|
|
6
6
|
const state=await scopedTaskRuns.read();
|
|
7
7
|
const candidates=Object.values(state.items).filter(({run})=>
|
|
8
8
|
run.phase==='BLOCKED'&&run.reason==='SESSION_CANCEL_PENDING'
|
|
9
|
+
&&!run.cancelReadSourceLost
|
|
9
10
|
&&/^[a-f0-9]{32}$/.test(run.cancelRequestId||''));
|
|
10
11
|
const jobs=candidates.map(({run,revision})=>scopedTaskScheduler.perTask(
|
|
11
12
|
run.projectId,run.taskId,async()=>{
|
|
@@ -14,6 +15,7 @@ async function reconcileScopedCancelled(){
|
|
|
14
15
|
if(current.runRevision!==revision
|
|
15
16
|
||s?.phase!=='BLOCKED'
|
|
16
17
|
||s.reason!=='SESSION_CANCEL_PENDING'
|
|
18
|
+
||s.cancelReadSourceLost
|
|
17
19
|
||s.cancelRequestId!==run.cancelRequestId
|
|
18
20
|
||s.sessionId!==run.sessionId
|
|
19
21
|
||s.generation!==run.generation)return;
|
|
@@ -38,6 +40,19 @@ async function reconcileScopedCancelled(){
|
|
|
38
40
|
expectedBindingRevision:s.contextBindingRevision,
|
|
39
41
|
expectedActiveChatUrl:'https://chatgpt.com'+s.page
|
|
40
42
|
}).catch(()=>null);
|
|
43
|
+
// Only a definitive missing/expired signed source is safe to fence.
|
|
44
|
+
// Never release Native Owner or replay Context cancellation.
|
|
45
|
+
if(verified?.status==='FAILED'
|
|
46
|
+
&&['NO_REQUEST','REQUEST_EXPIRED'].includes(verified.code)){
|
|
47
|
+
const fresh=await scopedTaskRuns.get(s.projectId,s.taskId);
|
|
48
|
+
if(fresh.runRevision!==current.runRevision)return;
|
|
49
|
+
await scopedTaskRuns.put({...s,cancelReadSourceLost:{
|
|
50
|
+
code:verified.code,at:Date.now()}},{
|
|
51
|
+
expectedStoreRevision:fresh.storeRevision,
|
|
52
|
+
expectedRunRevision:fresh.runRevision});
|
|
53
|
+
console.warn('TASK_CANCEL_SOURCE_UNAVAILABLE',verified.code);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
41
56
|
if(verified?.status!=='CONFIRMED'
|
|
42
57
|
||verified.scope!=='TASK_SCOPED_CANCELLED_NOT_DELIVERED'
|
|
43
58
|
||verified.readOnly!==true
|