MergeRuntimeInputs returns the contract arguments with the runtime inputs merged in additively: when both define the same key, the runtime value is appended after the contract value (newline-separated) so file-sourced exemptions add to, rather than replace, contract-declared ones. The input maps are
(with, runtimeInputs map[string]string)
| 95 | // maps are not mutated. Exported so callers assembling runtime inputs (e.g. the |
| 96 | // CLI's --policy-input-from-file handling) reuse the same multi-value encoding. |
| 97 | func MergeRuntimeInputs(with, runtimeInputs map[string]string) map[string]string { |
| 98 | if len(runtimeInputs) == 0 { |
| 99 | return with |
| 100 | } |
| 101 | |
| 102 | merged := make(map[string]string, len(with)+len(runtimeInputs)) |
| 103 | maps.Copy(merged, with) |
| 104 | for k, v := range runtimeInputs { |
| 105 | if existing := merged[k]; existing != "" { |
| 106 | merged[k] = existing + "\n" + v |
| 107 | } else { |
| 108 | merged[k] = v |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | return merged |
| 113 | } |
| 114 | |
| 115 | // scopeTracker records, concurrency-safely, which runtime-input scope keys were |
| 116 | // matched by at least one policy attachment during a material evaluation. |
no outgoing calls