feat: add reporting governance preflight contract
This commit is contained in:
@@ -15,6 +15,10 @@ const baseCapabilityDescriptor = {
|
||||
escalate: { supported: true, level: 'full' }
|
||||
},
|
||||
notification_path: {
|
||||
queue_items: { supported: true, level: 'full' },
|
||||
spool_handoff: { supported: true, level: 'full' },
|
||||
sender_binding: { supported: true, level: 'full' },
|
||||
direct_send: { supported: true, level: 'partial' },
|
||||
truth_model: {
|
||||
delivery_states: ['prepared', 'queued', 'dispatched', 'pending_external_send', 'acked', 'blocked'],
|
||||
ack_requires_proven_send: true,
|
||||
@@ -53,6 +57,39 @@ test('planDecisionExecution produces runtime-adapter dispatch intent for force_c
|
||||
assert.ok(result.receipt.notes.some((note) => note.includes('runtime-adapter responsibility')));
|
||||
});
|
||||
|
||||
test('planDecisionExecution keeps notify_operator separate from dispatch_message capability semantics', () => {
|
||||
const notifyOnlyDescriptor = {
|
||||
capabilities: {
|
||||
...baseCapabilityDescriptor.capabilities,
|
||||
notification_path: {
|
||||
...baseCapabilityDescriptor.capabilities.notification_path,
|
||||
sender_binding: { supported: false, level: 'none' },
|
||||
direct_send: { supported: false, level: 'none' }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const result = planDecisionExecution({
|
||||
decision: {
|
||||
decision: 'force_checkpoint',
|
||||
policy_id: 'no-silence.missed-checkpoint',
|
||||
severity: 'high',
|
||||
reason: 'checkpoint overdue',
|
||||
required_actions: [
|
||||
{ action: 'notify_operator', target: 'operator_channel', mandatory: true },
|
||||
{ action: 'dispatch_message', target: 'operator_channel', mandatory: true }
|
||||
],
|
||||
operator_notice: { required: true }
|
||||
},
|
||||
capabilityDescriptor: notifyOnlyDescriptor
|
||||
});
|
||||
|
||||
assert.deepEqual(result.enforcement_intent.runtime_adapter_required, ['notify_operator']);
|
||||
assert.equal(result.enforcement_intent.planned_actions[0].execution_mode, 'runtime_adapter_dispatch_deferred');
|
||||
assert.equal(result.enforcement_intent.blocked_actions[0].action, 'dispatch_message');
|
||||
assert.ok(result.receipt.notes.some((note) => note.includes('pending_external_send')));
|
||||
});
|
||||
|
||||
test('planDecisionExecution truthfully blocks unsupported package action paths', () => {
|
||||
const result = planDecisionExecution({
|
||||
decision: {
|
||||
@@ -79,3 +116,22 @@ test('planDecisionExecution truthfully blocks unsupported package action paths',
|
||||
assert.equal(result.enforcement_intent.planned_actions.length, 0);
|
||||
assert.equal(result.enforcement_intent.blocked_actions[0].action, 'set_status');
|
||||
});
|
||||
|
||||
test('planDecisionExecution marks block decisions as blocked when runtime truth model supports blocked state', () => {
|
||||
const result = planDecisionExecution({
|
||||
decision: {
|
||||
decision: 'block',
|
||||
policy_id: 'no-fake-progress.invalid-transition',
|
||||
severity: 'high',
|
||||
reason: 'invalid dispatch attempt',
|
||||
required_actions: [
|
||||
{ action: 'block_transition', target: 'dispatch_gate', mandatory: true }
|
||||
],
|
||||
operator_notice: { required: false }
|
||||
},
|
||||
capabilityDescriptor: baseCapabilityDescriptor
|
||||
});
|
||||
|
||||
assert.equal(result.receipt.delivery_state, 'blocked');
|
||||
assert.deepEqual(result.enforcement_intent.package_core_actions, ['block_transition']);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user