File size: 4,454 Bytes
f24bcdf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://github.com/LucioLiu/handoff-protocol/contracts/dispatch-receipt.schema.json",
  "title": "Dispatch receipt",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "handoff_id",
    "recipient_id",
    "timestamp",
    "status",
    "requested_mode"
  ],
  "properties": {
    "handoff_id": {"type": "string", "minLength": 1},
    "contract_id": {"type": "string", "minLength": 1},
    "dispatch_id": {"type": "string", "minLength": 1},
    "recipient_id": {"type": "string", "minLength": 1},
    "timestamp": {"type": "string", "format": "date-time"},
    "status": {"enum": ["accepted", "undelivered"]},
    "requested_mode": {
      "description": "Requested host execution container, not a persistence claim.",
      "enum": ["bounded_subagent", "independent_task"]
    },
    "effective_mode": {
      "description": "Actual host execution container. Durable file writes do not change bounded_subagent into independent_task.",
      "enum": ["bounded_subagent", "independent_task"]
    },
    "task_id": {"type": "string", "minLength": 1},
    "workspace_receipt": {
      "type": "object",
      "additionalProperties": false,
      "required": ["root_id", "resolved_path", "resolution_evidence"],
      "properties": {
        "root_id": {"type": "string", "minLength": 1},
        "resolved_path": {"type": "string", "minLength": 1},
        "resolution_evidence": {"type": "string", "minLength": 1}
      }
    },
    "degraded_from": {"const": "independent_task"},
    "degradation_reason": {"type": "string", "minLength": 1},
    "provider": {"type": "object", "minProperties": 1},
    "reason": {"type": "string", "minLength": 1}
  },
  "allOf": [
    {
      "if": {
        "properties": {"status": {"const": "accepted"}},
        "required": ["status"]
      },
      "then": {
        "required": ["dispatch_id", "effective_mode", "provider"],
        "not": {"required": ["reason"]},
        "oneOf": [
          {
            "properties": {
              "requested_mode": {"const": "bounded_subagent"},
              "effective_mode": {"const": "bounded_subagent"}
            },
            "required": ["requested_mode", "effective_mode"],
            "not": {
              "anyOf": [
                {"required": ["task_id"]},
                {"required": ["workspace_receipt"]},
                {"required": ["degraded_from"]},
                {"required": ["degradation_reason"]}
              ]
            }
          },
          {
            "properties": {
              "requested_mode": {"const": "independent_task"},
              "effective_mode": {"const": "independent_task"}
            },
            "required": [
              "requested_mode",
              "effective_mode",
              "contract_id",
              "task_id",
              "workspace_receipt"
            ],
            "not": {
              "anyOf": [
                {"required": ["degraded_from"]},
                {"required": ["degradation_reason"]}
              ]
            }
          },
          {
            "properties": {
              "requested_mode": {"const": "independent_task"},
              "effective_mode": {"const": "bounded_subagent"},
              "degraded_from": {"const": "independent_task"}
            },
            "required": [
              "requested_mode",
              "effective_mode",
              "contract_id",
              "degraded_from",
              "degradation_reason"
            ],
            "not": {
              "anyOf": [
                {"required": ["task_id"]},
                {"required": ["workspace_receipt"]}
              ]
            }
          }
        ]
      }
    },
    {
      "if": {
        "properties": {"status": {"const": "undelivered"}},
        "required": ["status"]
      },
      "then": {
        "required": ["reason"],
        "not": {
          "anyOf": [
            {"required": ["dispatch_id"]},
            {"required": ["task_id"]},
            {"required": ["provider"]},
            {"required": ["effective_mode"]},
            {"required": ["workspace_receipt"]},
            {"required": ["degraded_from"]},
            {"required": ["degradation_reason"]}
          ]
        }
      }
    }
  ]
}