34 lines
2.1 KiB
TypeScript
34 lines
2.1 KiB
TypeScript
/** Historical proposal retained for review compatibility only. Production and
|
|
* current owned acceptance use numbered 0040; never execute this after it. */
|
|
export const ROUTING_RESERVATION_PROPOSAL_DDL = `
|
|
CREATE TABLE mcp_routing_reservations (
|
|
id uuid PRIMARY KEY,
|
|
source_plan_id uuid NOT NULL REFERENCES mcp_plans(id),
|
|
source_operation_id uuid NOT NULL REFERENCES mcp_operations(id),
|
|
source_step_index integer NOT NULL CHECK(source_step_index=0),
|
|
profile_id uuid NOT NULL REFERENCES mcp_routing_profiles(id),
|
|
connection_id uuid NOT NULL REFERENCES mcp_connections(id),
|
|
binding_sealed text NOT NULL,binding_proof text NOT NULL,
|
|
state_sealed text NOT NULL,state_proof text NOT NULL,revision integer NOT NULL CHECK(revision>=1),
|
|
deadline timestamptz NOT NULL,created_at timestamptz NOT NULL DEFAULT now(),
|
|
UNIQUE(source_operation_id,source_step_index)
|
|
);
|
|
CREATE TABLE mcp_routing_reservation_slots (
|
|
reservation_id uuid NOT NULL REFERENCES mcp_routing_reservations(id),
|
|
profile_id uuid NOT NULL REFERENCES mcp_routing_profiles(id),
|
|
lane text NOT NULL CHECK(lane IN ('forward','inverse')),
|
|
state text NOT NULL CHECK(state IN ('held','spent','proven-unused','unknown')),
|
|
created_at timestamptz NOT NULL DEFAULT now(),PRIMARY KEY(reservation_id,lane)
|
|
);
|
|
CREATE INDEX mcp_routing_reservation_slots_window ON mcp_routing_reservation_slots(profile_id,created_at);
|
|
ALTER TABLE mcp_scoped_recovery_intents ADD COLUMN reservation_id uuid REFERENCES mcp_routing_reservations(id);
|
|
ALTER TABLE mcp_scoped_recovery_intents ADD COLUMN slot_phase text NOT NULL DEFAULT 'recovery-intent';
|
|
ALTER TABLE mcp_scoped_recovery_intents ALTER COLUMN source_configuration_proof DROP NOT NULL;
|
|
ALTER TABLE mcp_scoped_recovery_intents ADD CONSTRAINT scoped_reservation_slot_shape CHECK (
|
|
(mode='manual' AND reservation_id IS NULL AND slot_phase='recovery-intent' AND source_configuration_proof IS NOT NULL)
|
|
OR (mode='reserved' AND reservation_id IS NOT NULL AND
|
|
((slot_phase='reservation-held' AND source_configuration_proof IS NULL)
|
|
OR (slot_phase IN ('reservation-bound','reserved-attempt') AND source_configuration_proof IS NOT NULL)))
|
|
);
|
|
`
|