package exec

import "reflect"

type contractLeafKey struct {
	typ  reflect.Type
	path string
}

var approvedDynamicContractLeaves = map[contractLeafKey]struct{}{
	// agentOptionalString is a closed null|string leaf used only by Agent
	// update so Desktop preserves absent/null/string without accepting generic
	// model-authored JSON.
	{typ: reflect.TypeOf(agentOptionalString{}), path: "agentUpdateRequest.Description"}:     {},
	{typ: reflect.TypeOf(agentOptionalString{}), path: "agentUpdateRequest.Model"}:           {},
	{typ: reflect.TypeOf(agentOptionalString{}), path: "agentUpdateRequest.ReasoningEffort"}: {},
	{typ: reflect.TypeOf(agentOptionalString{}), path: "agentUpdateRequest.ModelProfileID"}:  {},

	{typ: reflect.TypeOf(workflowObject{}), path: "workflowPlanRequest.Layout"}:                    {},
	{typ: reflect.TypeOf(workflowObject{}), path: "workflowTriggerRequest.Source.Schedule.Inputs"}: {},
	{typ: reflect.TypeOf(workflowObject{}), path: "workflowTriggerRequest.InputPolicy.Defaults"}:   {},
	{typ: reflect.TypeOf(workflowObject{}), path: "workflowTriggerRequest.InputPolicy.Constants"}:  {},
	{typ: reflect.TypeOf(workflowObject{}), path: "workflowRunRequest.Input"}:                      {},
	{typ: reflect.TypeOf(workflowObject{}), path: "workflowStepCommand.Output"}:                    {},

	{typ: reflect.TypeOf(workflowObject{}), path: "workflowTriggerMutationResponse.Revision.Source.Schedule.Inputs"}:    {},
	{typ: reflect.TypeOf(workflowObject{}), path: "workflowTriggerShowResponse.Revision.Source.Schedule.Inputs"}:        {},
	{typ: reflect.TypeOf(workflowObject{}), path: "workflowTriggerRevisionResponse.Source.Schedule.Inputs"}:             {},
	{typ: reflect.TypeOf(workflowObject{}), path: "workflowTriggerRevisionListResponse.Items[].Source.Schedule.Inputs"}: {},

	{typ: reflect.TypeOf(workflowNullableObject{}), path: "workflowTriggerMutationResponse.Revision.InputPolicy.Defaults"}:     {},
	{typ: reflect.TypeOf(workflowNullableObject{}), path: "workflowTriggerMutationResponse.Revision.InputPolicy.Constants"}:    {},
	{typ: reflect.TypeOf(workflowNullableObject{}), path: "workflowTriggerShowResponse.Revision.InputPolicy.Defaults"}:         {},
	{typ: reflect.TypeOf(workflowNullableObject{}), path: "workflowTriggerShowResponse.Revision.InputPolicy.Constants"}:        {},
	{typ: reflect.TypeOf(workflowNullableObject{}), path: "workflowTriggerRevisionResponse.InputPolicy.Defaults"}:              {},
	{typ: reflect.TypeOf(workflowNullableObject{}), path: "workflowTriggerRevisionResponse.InputPolicy.Constants"}:             {},
	{typ: reflect.TypeOf(workflowNullableObject{}), path: "workflowTriggerRevisionListResponse.Items[].InputPolicy.Defaults"}:  {},
	{typ: reflect.TypeOf(workflowNullableObject{}), path: "workflowTriggerRevisionListResponse.Items[].InputPolicy.Constants"}: {},

	{typ: reflect.TypeOf(workflowValue{}), path: "workflowPlanCreateResponse.Draft.Layout"}:                    {},
	{typ: reflect.TypeOf(workflowValue{}), path: "workflowPlanDraftResponse.Layout"}:                           {},
	{typ: reflect.TypeOf(workflowValue{}), path: "workflowPlanPublishResponse.Version.Layout"}:                 {},
	{typ: reflect.TypeOf(workflowValue{}), path: "workflowPlanVersionResponse.Layout"}:                         {},
	{typ: reflect.TypeOf(workflowValue{}), path: "workflowRunResponse.Input"}:                                  {},
	{typ: reflect.TypeOf(workflowValue{}), path: "workflowRunResponse.Output"}:                                 {},
	{typ: reflect.TypeOf(workflowValue{}), path: "workflowRunShowResponse.Run.Input"}:                          {},
	{typ: reflect.TypeOf(workflowValue{}), path: "workflowRunShowResponse.Run.State"}:                          {},
	{typ: reflect.TypeOf(workflowValue{}), path: "workflowRunShowResponse.Run.Output"}:                         {},
	{typ: reflect.TypeOf(workflowValue{}), path: "workflowRunListResponse.Items[].Input"}:                      {},
	{typ: reflect.TypeOf(workflowValue{}), path: "workflowRunListResponse.Items[].State"}:                      {},
	{typ: reflect.TypeOf(workflowValue{}), path: "workflowRunListResponse.Items[].Output"}:                     {},
	{typ: reflect.TypeOf(workflowValue{}), path: "workflowRunCancelResponse.Run.Input"}:                        {},
	{typ: reflect.TypeOf(workflowValue{}), path: "workflowRunCancelResponse.Run.State"}:                        {},
	{typ: reflect.TypeOf(workflowValue{}), path: "workflowRunCancelResponse.Run.Output"}:                       {},
	{typ: reflect.TypeOf(workflowValue{}), path: "workflowStepView.Input"}:                                     {},
	{typ: reflect.TypeOf(workflowValue{}), path: "workflowStepView.OutputContract"}:                            {},
	{typ: reflect.TypeOf(workflowValue{}), path: "workflowStepView.WorkItemsContract.DependencyValueContract"}: {},
	// This leaf is the closed WorkItem responder union: a fixed agent string or
	// an ordered {selectOne: [...]} candidate pool. It is custom so the proxy
	// preserves the union on the wire without pinning the responder to a single
	// agent; runtime normalize enforces allowedResponders membership and the
	// safe upper bound.
	{typ: reflect.TypeOf(workflowWorkItemResponderInput{}), path: "workflowStepCommand.WorkItems[].Responder"}: {},
	// This leaf is a closed nullable scope schema, not arbitrary JSON. It is
	// custom only so the proxy can retain omitted (legacy) versus explicit
	// null (Agent-selected collaboration work scope) on the wire.
	{typ: reflect.TypeOf(workflowNullableMessageScopeResponse{}), path: "workflowStepView.WorkScope"}: {},

	{typ: reflect.TypeOf(workflowOperationalJSON{}), path: "workflowRunResponse.Error"}:                 {},
	{typ: reflect.TypeOf(workflowOperationalJSON{}), path: "workflowRunListResponse.Items[].Error"}:     {},
	{typ: reflect.TypeOf(workflowOperationalJSON{}), path: "workflowRunCancelResponse.Run.Error"}:       {},
	{typ: reflect.TypeOf(workflowOperationalJSON{}), path: "workflowRunShowResponse.Run.Error"}:         {},
	{typ: reflect.TypeOf(workflowOperationalJSON{}), path: "workflowRunShowResponse.CurrentStep.Error"}: {},
	{typ: reflect.TypeOf(workflowOperationalJSON{}), path: "workflowRunLogsResponse.Items[].Details"}:   {},
}
