@peer-agent/protocol 0.1.0-rc.38 → 0.1.0-rc.39

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.
@@ -85,6 +85,7 @@ export interface WorkSessionConversationMeta extends SessionQueueFacts {
85
85
  readonly phase?: 'starting' | 'verifying' | 'paused';
86
86
  /** 进程内执行所有权(runtime 采集);缺省表示该入口尚未接入所有权事实。 */
87
87
  readonly executionOwnership?: ExecutionOwnership;
88
+ readonly obligationDisposition?: 'indexed' | 'suspended' | 'current';
88
89
  }
89
90
  export interface WorkSession extends SessionQueueFacts {
90
91
  readonly executionOwnership?: ExecutionOwnership;
@@ -71,6 +71,7 @@ export function projectWorkSession(plan, conversationMeta) {
71
71
  interrupted: plan.interrupted,
72
72
  interruptionOrigin: plan.interruptionOrigin,
73
73
  ...controlPhasesForOrigin(conversationMeta.origin),
74
+ ...(conversationMeta.obligationDisposition ? { obligationDisposition: conversationMeta.obligationDisposition } : {}),
74
75
  ...(conversationMeta.origin.cancellation?.disposition ? { cancellationDisposition: conversationMeta.origin.cancellation.disposition } : {}),
75
76
  ...(!conversationMeta.origin.executionControl && conversationMeta.coordination?.phase === 'awaiting_outcome'
76
77
  ? { takeoverPhase: 'awaiting_outcome' }
@@ -7,7 +7,7 @@ const ownerships = new Set(['live', 'ended', 'unknown']);
7
7
  const owners = new Set(['bot', 'user', 'none']);
8
8
  const reasons = new Set(['settled', 'superseded', 'stop_confirmed', 'user_withdrawn',
9
9
  'stop_unconfirmed', 'human_request', 'awaiting_human_gate', 'technical_block', 'local_persistence_failed', 'awaiting_acceptance_technical',
10
- 'verification_failed', 'live_execution', 'paused', 'unknown_facts']);
10
+ 'verification_failed', 'live_execution', 'paused', 'unknown_facts', 'obligation_indexed']);
11
11
  const hostReasons = new Set(['live_execution', 'stop_unconfirmed', 'unknown_facts', 'local_persistence_failed']);
12
12
  export function runtimeSessionFacts(value) {
13
13
  const row = record(value), origin = record(row.origin), cancellation = record(origin.cancellation);
@@ -30,13 +30,13 @@ export function runtimeSessionFacts(value) {
30
30
  }, executionOwnership);
31
31
  const owner = declared && owners.has(declared.owner) ? declared.owner : fallback?.owner || 'bot';
32
32
  const reason = text(declared?.reason) || fallback?.reason || 'unknown_facts';
33
- const stopping = ['stopping', 'awaiting_outcome'].includes(status)
34
- || status === 'cancelled' && owner !== 'none';
33
+ const stopping = reason !== 'obligation_indexed' && (['stopping', 'awaiting_outcome'].includes(status)
34
+ || status === 'cancelled' && owner !== 'none');
35
35
  const handling = !valid ? 'host' : human || owner === 'user' ? 'user'
36
36
  : executionOwnership === 'live' || stopping || owner === 'bot' && hostReasons.has(reason) ? 'host'
37
37
  : owner === 'none' ? 'none' : 'model';
38
38
  return { sessionId, status, valid, executionOwnership, owner, reason, handling,
39
- pendingManaged: handling === 'host' || handling === 'user' || !['accepted', 'cancelled'].includes(status) };
39
+ pendingManaged: reason === 'obligation_indexed' ? false : handling === 'host' || handling === 'user' || !['accepted', 'cancelled'].includes(status) };
40
40
  }
41
41
  /** Missing/invalid facts remain obligations; a valid public terminal does not invent live ownership. */
42
42
  export function hasPendingRuntimeSessions(sessions, expectedIds = []) {
@@ -38,6 +38,15 @@ export interface SessionControlOperation {
38
38
  readonly kind: 'pause' | 'cancel' | 'takeover' | 'resume';
39
39
  readonly authorityRef: string;
40
40
  readonly hostEpoch?: string;
41
+ /** Pid of the process that recorded the operation. By itself this is not a death proof. */
42
+ readonly hostPid?: number;
43
+ readonly recorder?: {
44
+ readonly bootId: string;
45
+ readonly pid: number;
46
+ readonly pidStart: string;
47
+ readonly hostId: string;
48
+ readonly acquiredAt: string;
49
+ };
41
50
  readonly unproven?: boolean;
42
51
  readonly recoveryFactsDigest?: string;
43
52
  readonly priorStopReceiptId?: string;
@@ -17,7 +17,13 @@ export function controlPhasesForOrigin(origin) {
17
17
  const control = origin.executionControl;
18
18
  if (!control)
19
19
  return { cancellationPhase: origin.cancellation?.phase, takeoverPhase: origin.takeover?.phase };
20
- const stopping = control.phase === 'reconciling' && control.stopReceipt?.unknownCalls.length ? 'awaiting_outcome' : 'stopping';
20
+ // A barrier that has already recorded why it cannot confirm the stop is not still stopping.
21
+ // Draining remains the in-progress label. This does not turn the refusal into a completed stop.
22
+ const refused = control.phase === 'reconciling' && (Boolean(control.stopReceipt?.unknownCalls.length)
23
+ || control.nextAction === 'execution_stop_unconfirmed'
24
+ || control.nextAction === 'execution_outcome_unknown'
25
+ || control.nextAction === 'reconcile_execution_outcome');
26
+ const stopping = refused ? 'awaiting_outcome' : 'stopping';
21
27
  return {
22
28
  cancellationPhase: control.kind === 'cancel'
23
29
  ? control.phase === 'settled' && control.outcome === 'applied' ? 'completed' : stopping
@@ -410,6 +410,7 @@ export interface LifecycleFacts {
410
410
  readonly blockedReason?: string;
411
411
  readonly cancellationPhase?: string;
412
412
  readonly cancellationDisposition?: 'user_withdrawn';
413
+ readonly obligationDisposition?: 'indexed' | 'suspended' | 'current';
413
414
  readonly takeoverPhase?: string;
414
415
  readonly coordinationPhase?: string;
415
416
  }
@@ -426,7 +427,7 @@ export interface LifecycleCoreDecision extends ProjectionDecision {
426
427
  * `inCurrentList` 是派生事实,不允许消费端各自按 status 再判一次。
427
428
  */
428
429
  export type FollowUpOwner = 'bot' | 'user' | 'none';
429
- export type FollowUpReason = 'settled' | 'superseded' | 'stop_confirmed' | 'user_withdrawn' | 'stop_unconfirmed' | 'human_request' | 'awaiting_human_gate' | 'technical_block' | 'local_persistence_failed' | 'awaiting_acceptance_technical' | 'verification_failed' | 'live_execution' | 'paused' | 'unknown_facts';
430
+ export type FollowUpReason = 'settled' | 'superseded' | 'stop_confirmed' | 'user_withdrawn' | 'stop_unconfirmed' | 'human_request' | 'awaiting_human_gate' | 'technical_block' | 'local_persistence_failed' | 'awaiting_acceptance_technical' | 'verification_failed' | 'live_execution' | 'paused' | 'unknown_facts' | 'obligation_indexed';
430
431
  export interface FollowUpProjection {
431
432
  readonly owner: FollowUpOwner;
432
433
  readonly inCurrentList: boolean;
@@ -25,6 +25,9 @@ export function decideFollowUp(decision, facts = {}, ownership = 'unknown') {
25
25
  }
26
26
  if (live)
27
27
  return followUpOf('bot', 'live_execution');
28
+ // An authorized follow-up retirement leaves the current list without claiming the stop succeeded.
29
+ if (facts.obligationDisposition === 'indexed')
30
+ return followUpOf('none', 'obligation_indexed');
28
31
  if (stopPending)
29
32
  return followUpOf('bot', 'stop_unconfirmed');
30
33
  if (stopStatus && facts.cancellationDisposition === 'user_withdrawn')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peer-agent/protocol",
3
- "version": "0.1.0-rc.38",
3
+ "version": "0.1.0-rc.39",
4
4
  "description": "Shared host-neutral protocol contracts for Peer Agent runtimes and clients.",
5
5
  "type": "module",
6
6
  "license": "MIT",