@integraledger/lcp-placements 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # @integraledger/lcp-placements
2
+
3
+ ## 0.9.0
4
+
5
+ First public release.
6
+
7
+ `0.9.0` is deliberate: this is a release candidate for 1.0, not a preview. The implementation is complete
8
+ against LCP v1.38 and certified by the conformance corpus, and the remaining distance to 1.0 is the
9
+ specification's own — the standard is still moving through its steering committee, and this package will not
10
+ claim a stability its protocol has not yet promised.
11
+
12
+ Development before this release happened in a private repository and is not reproduced here; no earlier
13
+ version was ever available to install.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,14 @@
1
+ Integra Protocol
2
+ Copyright 2026 Integra Ledger
3
+
4
+ This product includes software developed by Integra Ledger (https://integraledger.com).
5
+
6
+ "Integra", "Integra Ledger", and the Integra logo are trademarks of Integra Ledger.
7
+ Trademark use is not granted by the Apache License 2.0 (see Section 6).
8
+
9
+ The Legal Context Protocol is co-stewarded by Integra Ledger and AAA-ICDR. This repository is a
10
+ reference implementation of the standard's open layer; the specification itself is published at
11
+ https://legalcontextprotocol.org/standard and is not part of this distribution.
12
+
13
+ The vendored submodule under lib/commerce-payments is Coinbase's AuthCaptureEscrow and carries its own
14
+ MIT licence at lib/commerce-payments/LICENSE.md. It is not covered by the Apache License above.
package/README.md ADDED
@@ -0,0 +1,150 @@
1
+ # @integraledger/lcp-placements
2
+
3
+ **The one place a protocol is registered.** Nine placement packages describe where an LCP reference rides in
4
+ nine protocol documents; this package is the map from a protocol id to the adapter that does it. A caller that
5
+ imports this stops hand-picking protocol packages, and adding a tenth protocol becomes a data edit here rather
6
+ than a change at every call site.
7
+
8
+ ```bash
9
+ npm install @integraledger/lcp-placements
10
+ ```
11
+
12
+ | | |
13
+ |---|---|
14
+ | **Registered** | `x402`, `mpp`, `ap2`, `ack`, `acp`, `ucp`, `visa-tap`, `mastercard-vi`, `a2a` |
15
+ | **Not registered** | `mcp` — a known protocol id that is **not a field placement at all** (see below) |
16
+ | **Tier A** | eight of the nine |
17
+ | **Tier B** | `mastercard-vi` — declared and inert (LCP §8.3, and see that package's README) |
18
+ | **Chain** | none, by rule — `depcruise` holds this package to the same chain-free invariant as the placements it aggregates |
19
+ | **Depends on** | [`@integraledger/lcp-binding-core`](../binding-core#readme) for `ReferencePlacementAdapter`, plus the nine `placement-*` packages |
20
+
21
+ ## The four exports
22
+
23
+ ```ts
24
+ import { placementFor, placementsByTier, PLACEMENTS, supportedProtocols } from "@integraledger/lcp-placements";
25
+
26
+ const acp = placementFor("acp"); // ReferencePlacementAdapter | undefined
27
+ placementFor("mcp"); // undefined — a fact, not a hole to fill with a throwing stub
28
+
29
+ const vi = placementFor("mastercard-vi", { reverseDomain: "com.example" });
30
+ placementFor("mastercard-vi"); // THROWS — see below
31
+
32
+ const { adapters, unconfigured } = placementsByTier("A", { reverseDomain: "com.example" });
33
+ ```
34
+
35
+ `placementFor` is total over the closed `ProtocolId` set and returns `undefined` only where this build
36
+ genuinely has no placement. It consults **own properties only**: `PLACEMENTS` is an object, so a bare index
37
+ would read `PLACEMENTS["toString"]` off `Object.prototype` — a value that is neither `undefined` nor a
38
+ singleton, and so reaches the namespaced arm and asserts a namespace requirement about a protocol that does
39
+ not exist. `ProtocolId` is a compile-time set and this is the dispatch point a counterparty's wire token and
40
+ an MCP tool argument arrive at, so the guard is a runtime one. `supportedProtocols()` enumerates in
41
+ `KNOWN_PROTOCOL_IDS` order — the schema enum's own order, so the list is stable rather than an accident of
42
+ which unit landed first.
43
+
44
+ ## `mcp` is absent because MCP has no field carrier
45
+
46
+ Not a pending `placement-mcp`. LCP v1.37 §C.9 and §10 describe an LCP-aware MCP **server** — tools,
47
+ resources and prompts, plus a `capabilities.extensions` negotiation map keyed by a reverse domain — and no
48
+ document field for a reference to ride in. MCP is a delivery surface, not a placement, so `mcp`'s absence
49
+ from this registry is the correct terminal state. The corpus pins it: `placement.dispatch` asserts that a
50
+ known protocol id with no placement answers the same `unknown-placement-protocol:<id>` port error as a token
51
+ that is not a protocol id at all, and never a throw.
52
+
53
+ ## Two registration shapes, because there are two
54
+
55
+ Eight placements are singletons: the host protocol fixes the carrier completely, so the package exports one
56
+ adapter and the registry holds it. Mastercard VI's carrier is a custom Layer-2 constraint type named under the
57
+ **deployment's own reverse-DNS namespace**, which has no default — so it ships as a factory, and the registry
58
+ holds the factory rather than a pre-built adapter.
59
+
60
+ ```ts
61
+ import type { ReferencePlacementAdapter } from "@integraledger/lcp-binding-core";
62
+
63
+ export type PlacementRegistration =
64
+ | { kind: "singleton"; adapter: ReferencePlacementAdapter }
65
+ | { kind: "namespaced"; build: (reverseDomain: string) => ReferencePlacementAdapter };
66
+ ```
67
+
68
+ Three consequences, each deliberate:
69
+
70
+ 1. **The registry never defaults a namespace.** LCP §8 canonizes no per-protocol integration profile, and a
71
+ default would write *our* reverse domain into a counterparty's signed mandate in every deployment that
72
+ forgot to pass one. `placementFor("mastercard-vi")` with no deployment **throws**, naming what the caller
73
+ owes. It does not answer `undefined`, because `undefined` means "this protocol has no placement" and would
74
+ turn a caller's omission into a fact about the protocol.
75
+
76
+ 2. **The factory's own guards are not bypassed.** The namespace is passed through unexamined: the empty,
77
+ non-reverse-DNS and reserved-`org.legalcontextprotocol` cases are refused by the factory that owns them, and
78
+ a second copy of those rules here could disagree with the first.
79
+
80
+ 3. **One keyed union, not a singleton map beside a factory map.** Two maps admit the same protocol id in both,
81
+ where two callers reach two different adapters for one protocol and neither is wrong. A single key cannot —
82
+ *in the source*. `PLACEMENTS` is also `Readonly` and `Object.freeze`d, because the keyed union says nothing
83
+ about a consumer adding, replacing or deleting a registration after import and changing what `placementFor`
84
+ and `supportedProtocols` answer for everyone else in the process. The type stops that in TypeScript
85
+ (TS2540 on assignment, TS2704 on `delete`); the freeze stops it in plain JavaScript, which is what a
86
+ published package is consumed as. What the freeze guarantees is that the write does not **land** —
87
+ whether it *throws* is the caller's strict-mode setting (an ESM importer gets a `TypeError`, a
88
+ sloppy-mode CommonJS caller gets a silent no-op), and either way the next lookup reads the same registry.
89
+
90
+ ## `placementsByTier` reports what it could not classify
91
+
92
+ A tier is a property of a *built* manifest, so a namespaced registration cannot be classified until its
93
+ namespace arrives. Dropping it would answer "no Tier B placements exist" while one sits registered a namespace
94
+ away — a hole read as a fact. So the selector returns both halves:
95
+
96
+ ```ts
97
+ import { placementsByTier } from "@integraledger/lcp-placements";
98
+
99
+ placementsByTier("B"); // { adapters: [], unconfigured: ["mastercard-vi"] }
100
+ placementsByTier("B", { reverseDomain: "com.example" }); // { adapters: [viAdapter], unconfigured: [] }
101
+ ```
102
+
103
+ Reporting rather than throwing is the point: a caller with no namespace still gets the eight Tier A adapters,
104
+ and is never pushed into inventing a namespace to satisfy a signature.
105
+
106
+ ## The tier selector is what makes "the host governs" operational
107
+
108
+ The host protocol's live rules bind, and LCP's Appendix C is an illustration. A deployment that will only
109
+ ship what works against stock, unmodified implementations asks for `"A"` and gets exactly that — rather than
110
+ reading tiers out of documentation and hoping. Tier B adapters stay constructible; they are simply never
111
+ returned to a Tier-A caller.
112
+
113
+ ## Where the registry sits in the dependency graph
114
+
115
+ Up-tier from every placement package and down-tier from every consumer. `depcruise` enforces both directions,
116
+ and both rules had to be widened to see this package at all — `placement-` does not match `placements/` on the
117
+ hyphen, so the registry escaped the tier discipline and the chain-free invariant until the protocol-surface
118
+ work named it. Both
119
+ widened rules were canary-proven to exit non-zero: a planted `@integraledger/lcp-conformance` import fired
120
+ `domain-tier-no-upward` (exit 1) and a planted `viem` import fired `placement-packages-are-chain-free`
121
+ (exit 2 — `depcruise` exits with the error count).
122
+
123
+ **Re-running those canaries requires a RESOLVABLE import**, and this is the whole recipe. Both rules match on
124
+ `to.path`, which only exists once enhanced-resolve has resolved the specifier; an undeclared bare import is
125
+ reported `couldNotResolve: true, valid: true` and the run exits **0**, and there is no `not-to-unresolvable`
126
+ rule to catch it. Measured both ways: the bare plant exits 0, and the same plant with
127
+ `packages/placements/node_modules/@integraledger/lcp-conformance` symlinked in exits 1 naming the rule. An
128
+ undeclared import is not a hole in the gate — it fails `pnpm -r typecheck` with TS2307 instead — but a canary
129
+ planted without the symlink proves nothing.
130
+
131
+ The conformance harness consumes this package rather than keeping its own map: `InProcessSubject` resolves the
132
+ `placement` class through `placementFor`, so a placement that is registered here is reachable on all three
133
+ conformance doors by construction, and one that is not is unreachable everywhere. The harness supplies
134
+ `com.integraledger` as its own deployment namespace — the value the `mastercard-vi` vectors are written in.
135
+
136
+ ## What this package is not
137
+
138
+ It is not a second place a protocol id is spelled: the keys are `ProtocolId` tokens, hyphens included. It is
139
+ not a settlement registry — a protocol can be registered here *and* carry a settlement binding elsewhere
140
+ (x402 does both), and the two answer different questions. And it holds no protocol logic of its own: every
141
+ rule about a carrier lives in the placement package that owns it, or in `binding-core`'s placement kit.
142
+
143
+ ---
144
+
145
+ **Requires Node >= 24.** Part of the
146
+ [Legal Context Protocol open layer](https://github.com/IntegraLedger/integra-protocol) — see the
147
+ [documentation](https://github.com/IntegraLedger/integra-protocol/blob/main/docs/developer/index.md)
148
+ and the
149
+ [package index](https://github.com/IntegraLedger/integra-protocol/blob/main/docs/developer/reference.md).
150
+ Apache-2.0.
@@ -0,0 +1,3 @@
1
+ export type { PlacementDeployment, PlacementRegistration, TierSelection, } from "./registry.js";
2
+ export { PLACEMENTS, placementFor, placementsByTier, supportedProtocols, } from "./registry.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,mBAAmB,EACnB,qBAAqB,EACrB,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { PLACEMENTS, placementFor, placementsByTier, supportedProtocols, } from "./registry.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,eAAe,CAAC"}
@@ -0,0 +1,116 @@
1
+ import type { PlacementTier, ProtocolId, ReferencePlacementAdapter } from "@integraledger/lcp-binding-core";
2
+ /**
3
+ * What a deployment supplies before the parameterized placements can be built.
4
+ *
5
+ * Config a deployment OWNS, never a constructed adapter: the moment a caller hands the registry an adapter,
6
+ * the registry has stopped being the one place a protocol is registered.
7
+ */
8
+ export type PlacementDeployment = {
9
+ /**
10
+ * The deployment's own reverse-domain namespace.
11
+ *
12
+ * REQUIRED by every `namespaced` registration and defaulted by none. LCP §8 canonizes no per-protocol
13
+ * integration profile, so a default would write OUR domain into a counterparty's signed document in every
14
+ * deployment that forgot to pass one. The receiving factory validates it; the registry does not
15
+ * pre-validate, so its guards are never bypassed or duplicated here.
16
+ */
17
+ readonly reverseDomain: string;
18
+ };
19
+ /**
20
+ * How one protocol's placement is obtained.
21
+ *
22
+ * TWO shapes because the registered placements genuinely have two shapes, and flattening them would cost
23
+ * either correctness or honesty. Eight are singletons whose carrier the host protocol fixes completely.
24
+ * Mastercard VI's carrier is a custom Layer-2 constraint type under the deployment's own reverse-DNS
25
+ * namespace, which has no default — so it ships as a factory, and a map of adapters could only hold it by
26
+ * inventing the namespace.
27
+ *
28
+ * ONE keyed union rather than a singleton map beside a factory map: two maps admit an id in both, where two
29
+ * callers reach two different adapters for one protocol and neither is wrong. A single key cannot.
30
+ */
31
+ export type PlacementRegistration = {
32
+ readonly kind: "singleton";
33
+ readonly adapter: ReferencePlacementAdapter;
34
+ } | {
35
+ readonly kind: "namespaced";
36
+ readonly build: (reverseDomain: string) => ReferencePlacementAdapter;
37
+ };
38
+ /**
39
+ * Every reference placement this build can perform, keyed by `ProtocolId`.
40
+ *
41
+ * THE registry — the one place a protocol is registered, so that adding one is a data edit plus an import and
42
+ * never a change to a caller. The conformance subject, the universal buyer parser and the universal seller
43
+ * surface all dispatch through here rather than each keeping a map that can drift.
44
+ *
45
+ * A `Partial` record on purpose: `mcp` is a known protocol id that is **not a field placement at all**. LCP
46
+ * v1.38 §C.9 and §10 describe an LCP-aware MCP *server* — tools, resources and prompts, plus a
47
+ * `capabilities.extensions` negotiation map — with no document field for a reference to ride in. So its
48
+ * absence is the correct terminal state, not a gap awaiting a `placement-mcp`, and certainly not a hole to
49
+ * fill with a stub that throws. Note that a protocol can be registered here AND carry a settlement binding
50
+ * elsewhere — x402 does both, and the two registrations answer different questions (where the reference
51
+ * rides vs. how the settlement is welded).
52
+ *
53
+ * ORDERED as `KNOWN_PROTOCOL_IDS` orders the closed set, which is the schema enum's order. Registration
54
+ * order is enumeration order, so keeping the two aligned makes `supportedProtocols()` a filter of the closed
55
+ * set rather than an accident of which unit landed first.
56
+ *
57
+ * `Readonly` AND `Object.freeze`, because "the one place a protocol is registered" is the whole argument for
58
+ * the keyed union and an exported mutable object does not make it true. The keyed union rules out a *second*
59
+ * registration in the source; only immutability rules out a consumer adding, replacing or deleting one at
60
+ * runtime and changing what `placementFor` and `supportedProtocols` answer thereafter. The type stops it in
61
+ * TypeScript (assignment TS2540, `delete` TS2704); the freeze stops it in plain JavaScript, which is what a
62
+ * published package is consumed as. Stated precisely, because it was measured both ways: the freeze
63
+ * guarantees the write does not LAND. Whether it throws is the caller's strict-mode setting — ESM importers
64
+ * get a `TypeError`, a sloppy-mode CommonJS caller gets a silent no-op — so the registry the next lookup
65
+ * reads is unchanged either way, which is the property that matters.
66
+ */
67
+ export declare const PLACEMENTS: Readonly<Partial<Record<ProtocolId, PlacementRegistration>>>;
68
+ /**
69
+ * The adapter for a protocol, or `undefined` when this build has no placement for it.
70
+ *
71
+ * TOTAL over the closed protocol set — a caller decides what an absence means, and gets an absence only for a
72
+ * protocol that genuinely has no placement. `deployment` is optional because most protocols need nothing from
73
+ * it; omitting it against a `namespaced` registration throws rather than silently answering `undefined`.
74
+ *
75
+ * OWN properties only. `PLACEMENTS` is an object, so a bare index reads through the prototype chain and
76
+ * `PLACEMENTS["toString"]` answers `Object.prototype.toString` — a value that is not `undefined`, is not
77
+ * `kind: "singleton"`, and therefore reaches the `namespaced` arm, where the registry either asserts a
78
+ * namespace requirement about a protocol that does not exist or throws a raw `TypeError` on
79
+ * `registration.build`. `protocol` is typed `ProtocolId`, but this is the dispatch point a wire token and an
80
+ * MCP tool argument arrive at, and a cast at one caller would be enough. Same guard, same reason, as
81
+ * `binding-core`'s `readAtPath` (the repository's read-path tests — "does not walk prototype keys").
82
+ *
83
+ * ONE guard, not two. `Object.hasOwn` as a separate early return would leave the `=== undefined` check that
84
+ * follows it unreachable — `Partial` admits `undefined` in the value type, but no key here is written with
85
+ * one, so an own key always has a registration. Mutation testing is what says so out loud: with two guards,
86
+ * neutering the second to `if (false)` SURVIVES, which is the instrument reporting a branch no input can take.
87
+ * Folding the own-property test into the lookup leaves exactly one reachable absence and both mutants die.
88
+ */
89
+ export declare function placementFor(protocol: ProtocolId, deployment?: PlacementDeployment): ReferencePlacementAdapter | undefined;
90
+ /** Every protocol this build can place a reference into, in the closed set's own order. */
91
+ export declare function supportedProtocols(): readonly ProtocolId[];
92
+ /**
93
+ * The answer to a tier query: what this deployment can build at that tier, and what it could not classify.
94
+ *
95
+ * `unconfigured` is the load-bearing half. A tier query is a question about a WHOLE set ("everything I can
96
+ * ship against stock implementations"), and a namespaced registration cannot be classified at all until its
97
+ * namespace arrives — the tier is a property of the built manifest. Dropping it would answer "no Tier B
98
+ * placements exist" while one sits registered a namespace away, which is a hole read as a fact. Reporting it
99
+ * instead of throwing keeps the caller from inventing a namespace to satisfy a signature, which is the one
100
+ * outcome worse than the hole.
101
+ */
102
+ export type TierSelection = {
103
+ /** The placements at the requested tier, in registration order. */
104
+ readonly adapters: readonly ReferencePlacementAdapter[];
105
+ /** Registered protocols whose tier is unknown because the deployment supplied nothing they require. */
106
+ readonly unconfigured: readonly ProtocolId[];
107
+ };
108
+ /**
109
+ * The placements at one §8.3 wire-compatibility tier.
110
+ *
111
+ * The selector that makes the host-governs rule operational: a deployment that will only ship what works against stock
112
+ * implementations asks for `"A"` and gets exactly that, rather than reading tiers out of documentation and
113
+ * hoping. Tier B adapters remain constructible — they are simply never returned to a Tier-A caller.
114
+ */
115
+ export declare function placementsByTier(tier: PlacementTier, deployment?: PlacementDeployment): TierSelection;
116
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,yBAAyB,EAC1B,MAAM,iCAAiC,CAAC;AAWzC;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;;;;OAOG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,qBAAqB,GAC7B;IAAE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,yBAAyB,CAAA;CAAE,GAC3E;IACE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,KAAK,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,yBAAyB,CAAC;CACtE,CAAC;AAEN;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,UAAU,EAAE,QAAQ,CAC/B,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,qBAAqB,CAAC,CAAC,CAgBlD,CAAC;AAyCH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,UAAU,EACpB,UAAU,CAAC,EAAE,mBAAmB,GAC/B,yBAAyB,GAAG,SAAS,CAMvC;AAED,2FAA2F;AAC3F,wBAAgB,kBAAkB,IAAI,SAAS,UAAU,EAAE,CAE1D;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,EAAE,SAAS,yBAAyB,EAAE,CAAC;IACxD,uGAAuG;IACvG,QAAQ,CAAC,YAAY,EAAE,SAAS,UAAU,EAAE,CAAC;CAC9C,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,aAAa,EACnB,UAAU,CAAC,EAAE,mBAAmB,GAC/B,aAAa,CAYf"}
@@ -0,0 +1,135 @@
1
+ import { a2aPlacement } from "@integraledger/lcp-placement-a2a";
2
+ import { ackPlacement } from "@integraledger/lcp-placement-ack";
3
+ import { acpPlacement } from "@integraledger/lcp-placement-acp";
4
+ import { ap2Placement } from "@integraledger/lcp-placement-ap2";
5
+ import { makeMastercardViPlacement } from "@integraledger/lcp-placement-mastercard-vi";
6
+ import { mppPlacement } from "@integraledger/lcp-placement-mpp";
7
+ import { ucpPlacement } from "@integraledger/lcp-placement-ucp";
8
+ import { visaTapPlacement } from "@integraledger/lcp-placement-visa-tap";
9
+ import { x402Placement } from "@integraledger/lcp-placement-x402";
10
+ /**
11
+ * Every reference placement this build can perform, keyed by `ProtocolId`.
12
+ *
13
+ * THE registry — the one place a protocol is registered, so that adding one is a data edit plus an import and
14
+ * never a change to a caller. The conformance subject, the universal buyer parser and the universal seller
15
+ * surface all dispatch through here rather than each keeping a map that can drift.
16
+ *
17
+ * A `Partial` record on purpose: `mcp` is a known protocol id that is **not a field placement at all**. LCP
18
+ * v1.38 §C.9 and §10 describe an LCP-aware MCP *server* — tools, resources and prompts, plus a
19
+ * `capabilities.extensions` negotiation map — with no document field for a reference to ride in. So its
20
+ * absence is the correct terminal state, not a gap awaiting a `placement-mcp`, and certainly not a hole to
21
+ * fill with a stub that throws. Note that a protocol can be registered here AND carry a settlement binding
22
+ * elsewhere — x402 does both, and the two registrations answer different questions (where the reference
23
+ * rides vs. how the settlement is welded).
24
+ *
25
+ * ORDERED as `KNOWN_PROTOCOL_IDS` orders the closed set, which is the schema enum's order. Registration
26
+ * order is enumeration order, so keeping the two aligned makes `supportedProtocols()` a filter of the closed
27
+ * set rather than an accident of which unit landed first.
28
+ *
29
+ * `Readonly` AND `Object.freeze`, because "the one place a protocol is registered" is the whole argument for
30
+ * the keyed union and an exported mutable object does not make it true. The keyed union rules out a *second*
31
+ * registration in the source; only immutability rules out a consumer adding, replacing or deleting one at
32
+ * runtime and changing what `placementFor` and `supportedProtocols` answer thereafter. The type stops it in
33
+ * TypeScript (assignment TS2540, `delete` TS2704); the freeze stops it in plain JavaScript, which is what a
34
+ * published package is consumed as. Stated precisely, because it was measured both ways: the freeze
35
+ * guarantees the write does not LAND. Whether it throws is the caller's strict-mode setting — ESM importers
36
+ * get a `TypeError`, a sloppy-mode CommonJS caller gets a silent no-op — so the registry the next lookup
37
+ * reads is unchanged either way, which is the property that matters.
38
+ */
39
+ export const PLACEMENTS = Object.freeze({
40
+ x402: { kind: "singleton", adapter: x402Placement },
41
+ mpp: { kind: "singleton", adapter: mppPlacement },
42
+ ap2: { kind: "singleton", adapter: ap2Placement },
43
+ ack: { kind: "singleton", adapter: ackPlacement },
44
+ acp: { kind: "singleton", adapter: acpPlacement },
45
+ ucp: { kind: "singleton", adapter: ucpPlacement },
46
+ // The key is the LCP protocol id, hyphen included — a camelCased key would be a second spelling of a
47
+ // protocol whose id is closed, and every wire that says `visa-tap` would miss it.
48
+ "visa-tap": { kind: "singleton", adapter: visaTapPlacement },
49
+ // BUILT, not imported: the constraint namespace is the deployment's and has no default. The factory
50
+ // validates it (empty, non-reverse-DNS and the reserved `org.legalcontextprotocol` are all refused), so it
51
+ // is passed through unexamined — a second copy of those rules here could disagree with the first.
52
+ "mastercard-vi": { kind: "namespaced", build: makeMastercardViPlacement },
53
+ a2a: { kind: "singleton", adapter: a2aPlacement },
54
+ });
55
+ /**
56
+ * The registrations as entries, with the key and value narrowed once.
57
+ *
58
+ * `Object.entries` widens the key to `string` and, over an optional-property record, the value to
59
+ * `PlacementRegistration | undefined`. Both are artefacts of the index type rather than shapes that can
60
+ * occur: every key present in `PLACEMENTS` was written with a value. Narrowed here, with the reason, instead
61
+ * of at each use — and never with a `!`, which would say nothing about why.
62
+ */
63
+ function registrations() {
64
+ return Object.entries(PLACEMENTS);
65
+ }
66
+ /**
67
+ * Turn one registration into an adapter, or THROW naming what the caller owes.
68
+ *
69
+ * A namespaced registration with no deployment is a caller defect, not an absence: the placement exists and
70
+ * is reachable the moment a namespace is supplied. Answering `undefined` would report it as "this protocol
71
+ * has no placement", which is the silent hole this package exists to close, and defaulting the namespace
72
+ * would be worse — a signed document carrying a domain nobody chose.
73
+ */
74
+ function buildRegistration(protocol, registration, deployment) {
75
+ if (registration.kind === "singleton")
76
+ return registration.adapter;
77
+ if (deployment === undefined)
78
+ throw new Error(`${protocol} is a namespaced placement: its carrier sits under the deployment's own reverse-domain namespace, which has no default — supply { reverseDomain }`);
79
+ return registration.build(deployment.reverseDomain);
80
+ }
81
+ /**
82
+ * The adapter for a protocol, or `undefined` when this build has no placement for it.
83
+ *
84
+ * TOTAL over the closed protocol set — a caller decides what an absence means, and gets an absence only for a
85
+ * protocol that genuinely has no placement. `deployment` is optional because most protocols need nothing from
86
+ * it; omitting it against a `namespaced` registration throws rather than silently answering `undefined`.
87
+ *
88
+ * OWN properties only. `PLACEMENTS` is an object, so a bare index reads through the prototype chain and
89
+ * `PLACEMENTS["toString"]` answers `Object.prototype.toString` — a value that is not `undefined`, is not
90
+ * `kind: "singleton"`, and therefore reaches the `namespaced` arm, where the registry either asserts a
91
+ * namespace requirement about a protocol that does not exist or throws a raw `TypeError` on
92
+ * `registration.build`. `protocol` is typed `ProtocolId`, but this is the dispatch point a wire token and an
93
+ * MCP tool argument arrive at, and a cast at one caller would be enough. Same guard, same reason, as
94
+ * `binding-core`'s `readAtPath` (the repository's read-path tests — "does not walk prototype keys").
95
+ *
96
+ * ONE guard, not two. `Object.hasOwn` as a separate early return would leave the `=== undefined` check that
97
+ * follows it unreachable — `Partial` admits `undefined` in the value type, but no key here is written with
98
+ * one, so an own key always has a registration. Mutation testing is what says so out loud: with two guards,
99
+ * neutering the second to `if (false)` SURVIVES, which is the instrument reporting a branch no input can take.
100
+ * Folding the own-property test into the lookup leaves exactly one reachable absence and both mutants die.
101
+ */
102
+ export function placementFor(protocol, deployment) {
103
+ const registration = Object.hasOwn(PLACEMENTS, protocol)
104
+ ? PLACEMENTS[protocol]
105
+ : undefined;
106
+ if (registration === undefined)
107
+ return undefined;
108
+ return buildRegistration(protocol, registration, deployment);
109
+ }
110
+ /** Every protocol this build can place a reference into, in the closed set's own order. */
111
+ export function supportedProtocols() {
112
+ return registrations().map(([protocol]) => protocol);
113
+ }
114
+ /**
115
+ * The placements at one §8.3 wire-compatibility tier.
116
+ *
117
+ * The selector that makes the host-governs rule operational: a deployment that will only ship what works against stock
118
+ * implementations asks for `"A"` and gets exactly that, rather than reading tiers out of documentation and
119
+ * hoping. Tier B adapters remain constructible — they are simply never returned to a Tier-A caller.
120
+ */
121
+ export function placementsByTier(tier, deployment) {
122
+ const adapters = [];
123
+ const unconfigured = [];
124
+ for (const [protocol, registration] of registrations()) {
125
+ if (registration.kind === "namespaced" && deployment === undefined) {
126
+ unconfigured.push(protocol);
127
+ continue;
128
+ }
129
+ const adapter = buildRegistration(protocol, registration, deployment);
130
+ if (adapter.manifest.tier === tier)
131
+ adapters.push(adapter);
132
+ }
133
+ return { adapters, unconfigured };
134
+ }
135
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"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"}
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@integraledger/lcp-placements",
3
+ "version": "0.9.0",
4
+ "description": "The LCP placement registry — the one place a protocol is registered.",
5
+ "keywords": [
6
+ "lcp",
7
+ "legal-context-protocol",
8
+ "legal-terms",
9
+ "agentic-commerce",
10
+ "placement",
11
+ "registry"
12
+ ],
13
+ "type": "module",
14
+ "sideEffects": false,
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "./package.json": "./package.json"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "src",
25
+ "CHANGELOG.md",
26
+ "LICENSE",
27
+ "NOTICE"
28
+ ],
29
+ "publishConfig": {
30
+ "registry": "https://registry.npmjs.org",
31
+ "access": "public"
32
+ },
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/IntegraLedger/integra-protocol.git",
36
+ "directory": "packages/placements"
37
+ },
38
+ "bugs": {
39
+ "url": "https://github.com/IntegraLedger/integra-protocol/issues"
40
+ },
41
+ "homepage": "https://github.com/IntegraLedger/integra-protocol/tree/main/packages/placements#readme",
42
+ "dependencies": {
43
+ "@integraledger/lcp-binding-core": "0.9.0",
44
+ "@integraledger/lcp-placement-a2a": "0.9.0",
45
+ "@integraledger/lcp-placement-ack": "0.9.0",
46
+ "@integraledger/lcp-placement-acp": "0.9.0",
47
+ "@integraledger/lcp-placement-ap2": "0.9.0",
48
+ "@integraledger/lcp-placement-mastercard-vi": "0.9.0",
49
+ "@integraledger/lcp-placement-mpp": "0.9.0",
50
+ "@integraledger/lcp-placement-ucp": "0.9.0",
51
+ "@integraledger/lcp-placement-visa-tap": "0.9.0",
52
+ "@integraledger/lcp-placement-x402": "0.9.0"
53
+ },
54
+ "devDependencies": {
55
+ "@types/node": "24.13.3",
56
+ "vitest": "4.1.10"
57
+ },
58
+ "license": "Apache-2.0",
59
+ "engines": {
60
+ "node": ">=24"
61
+ },
62
+ "scripts": {
63
+ "build": "tsc -p tsconfig.build.json",
64
+ "typecheck": "tsc -p tsconfig.json --noEmit",
65
+ "test": "vitest run"
66
+ }
67
+ }
package/src/index.ts ADDED
@@ -0,0 +1,11 @@
1
+ export type {
2
+ PlacementDeployment,
3
+ PlacementRegistration,
4
+ TierSelection,
5
+ } from "./registry.js";
6
+ export {
7
+ PLACEMENTS,
8
+ placementFor,
9
+ placementsByTier,
10
+ supportedProtocols,
11
+ } from "./registry.js";
@@ -0,0 +1,216 @@
1
+ import type {
2
+ PlacementTier,
3
+ ProtocolId,
4
+ ReferencePlacementAdapter,
5
+ } from "@integraledger/lcp-binding-core";
6
+ import { a2aPlacement } from "@integraledger/lcp-placement-a2a";
7
+ import { ackPlacement } from "@integraledger/lcp-placement-ack";
8
+ import { acpPlacement } from "@integraledger/lcp-placement-acp";
9
+ import { ap2Placement } from "@integraledger/lcp-placement-ap2";
10
+ import { makeMastercardViPlacement } from "@integraledger/lcp-placement-mastercard-vi";
11
+ import { mppPlacement } from "@integraledger/lcp-placement-mpp";
12
+ import { ucpPlacement } from "@integraledger/lcp-placement-ucp";
13
+ import { visaTapPlacement } from "@integraledger/lcp-placement-visa-tap";
14
+ import { x402Placement } from "@integraledger/lcp-placement-x402";
15
+
16
+ /**
17
+ * What a deployment supplies before the parameterized placements can be built.
18
+ *
19
+ * Config a deployment OWNS, never a constructed adapter: the moment a caller hands the registry an adapter,
20
+ * the registry has stopped being the one place a protocol is registered.
21
+ */
22
+ export type PlacementDeployment = {
23
+ /**
24
+ * The deployment's own reverse-domain namespace.
25
+ *
26
+ * REQUIRED by every `namespaced` registration and defaulted by none. LCP §8 canonizes no per-protocol
27
+ * integration profile, so a default would write OUR domain into a counterparty's signed document in every
28
+ * deployment that forgot to pass one. The receiving factory validates it; the registry does not
29
+ * pre-validate, so its guards are never bypassed or duplicated here.
30
+ */
31
+ readonly reverseDomain: string;
32
+ };
33
+
34
+ /**
35
+ * How one protocol's placement is obtained.
36
+ *
37
+ * TWO shapes because the registered placements genuinely have two shapes, and flattening them would cost
38
+ * either correctness or honesty. Eight are singletons whose carrier the host protocol fixes completely.
39
+ * Mastercard VI's carrier is a custom Layer-2 constraint type under the deployment's own reverse-DNS
40
+ * namespace, which has no default — so it ships as a factory, and a map of adapters could only hold it by
41
+ * inventing the namespace.
42
+ *
43
+ * ONE keyed union rather than a singleton map beside a factory map: two maps admit an id in both, where two
44
+ * callers reach two different adapters for one protocol and neither is wrong. A single key cannot.
45
+ */
46
+ export type PlacementRegistration =
47
+ | { readonly kind: "singleton"; readonly adapter: ReferencePlacementAdapter }
48
+ | {
49
+ readonly kind: "namespaced";
50
+ readonly build: (reverseDomain: string) => ReferencePlacementAdapter;
51
+ };
52
+
53
+ /**
54
+ * Every reference placement this build can perform, keyed by `ProtocolId`.
55
+ *
56
+ * THE registry — the one place a protocol is registered, so that adding one is a data edit plus an import and
57
+ * never a change to a caller. The conformance subject, the universal buyer parser and the universal seller
58
+ * surface all dispatch through here rather than each keeping a map that can drift.
59
+ *
60
+ * A `Partial` record on purpose: `mcp` is a known protocol id that is **not a field placement at all**. LCP
61
+ * v1.38 §C.9 and §10 describe an LCP-aware MCP *server* — tools, resources and prompts, plus a
62
+ * `capabilities.extensions` negotiation map — with no document field for a reference to ride in. So its
63
+ * absence is the correct terminal state, not a gap awaiting a `placement-mcp`, and certainly not a hole to
64
+ * fill with a stub that throws. Note that a protocol can be registered here AND carry a settlement binding
65
+ * elsewhere — x402 does both, and the two registrations answer different questions (where the reference
66
+ * rides vs. how the settlement is welded).
67
+ *
68
+ * ORDERED as `KNOWN_PROTOCOL_IDS` orders the closed set, which is the schema enum's order. Registration
69
+ * order is enumeration order, so keeping the two aligned makes `supportedProtocols()` a filter of the closed
70
+ * set rather than an accident of which unit landed first.
71
+ *
72
+ * `Readonly` AND `Object.freeze`, because "the one place a protocol is registered" is the whole argument for
73
+ * the keyed union and an exported mutable object does not make it true. The keyed union rules out a *second*
74
+ * registration in the source; only immutability rules out a consumer adding, replacing or deleting one at
75
+ * runtime and changing what `placementFor` and `supportedProtocols` answer thereafter. The type stops it in
76
+ * TypeScript (assignment TS2540, `delete` TS2704); the freeze stops it in plain JavaScript, which is what a
77
+ * published package is consumed as. Stated precisely, because it was measured both ways: the freeze
78
+ * guarantees the write does not LAND. Whether it throws is the caller's strict-mode setting — ESM importers
79
+ * get a `TypeError`, a sloppy-mode CommonJS caller gets a silent no-op — so the registry the next lookup
80
+ * reads is unchanged either way, which is the property that matters.
81
+ */
82
+ export const PLACEMENTS: Readonly<
83
+ Partial<Record<ProtocolId, PlacementRegistration>>
84
+ > = Object.freeze({
85
+ x402: { kind: "singleton", adapter: x402Placement },
86
+ mpp: { kind: "singleton", adapter: mppPlacement },
87
+ ap2: { kind: "singleton", adapter: ap2Placement },
88
+ ack: { kind: "singleton", adapter: ackPlacement },
89
+ acp: { kind: "singleton", adapter: acpPlacement },
90
+ ucp: { kind: "singleton", adapter: ucpPlacement },
91
+ // The key is the LCP protocol id, hyphen included — a camelCased key would be a second spelling of a
92
+ // protocol whose id is closed, and every wire that says `visa-tap` would miss it.
93
+ "visa-tap": { kind: "singleton", adapter: visaTapPlacement },
94
+ // BUILT, not imported: the constraint namespace is the deployment's and has no default. The factory
95
+ // validates it (empty, non-reverse-DNS and the reserved `org.legalcontextprotocol` are all refused), so it
96
+ // is passed through unexamined — a second copy of those rules here could disagree with the first.
97
+ "mastercard-vi": { kind: "namespaced", build: makeMastercardViPlacement },
98
+ a2a: { kind: "singleton", adapter: a2aPlacement },
99
+ });
100
+
101
+ /**
102
+ * The registrations as entries, with the key and value narrowed once.
103
+ *
104
+ * `Object.entries` widens the key to `string` and, over an optional-property record, the value to
105
+ * `PlacementRegistration | undefined`. Both are artefacts of the index type rather than shapes that can
106
+ * occur: every key present in `PLACEMENTS` was written with a value. Narrowed here, with the reason, instead
107
+ * of at each use — and never with a `!`, which would say nothing about why.
108
+ */
109
+ function registrations(): readonly (readonly [
110
+ ProtocolId,
111
+ PlacementRegistration,
112
+ ])[] {
113
+ return Object.entries(PLACEMENTS) as readonly (readonly [
114
+ ProtocolId,
115
+ PlacementRegistration,
116
+ ])[];
117
+ }
118
+
119
+ /**
120
+ * Turn one registration into an adapter, or THROW naming what the caller owes.
121
+ *
122
+ * A namespaced registration with no deployment is a caller defect, not an absence: the placement exists and
123
+ * is reachable the moment a namespace is supplied. Answering `undefined` would report it as "this protocol
124
+ * has no placement", which is the silent hole this package exists to close, and defaulting the namespace
125
+ * would be worse — a signed document carrying a domain nobody chose.
126
+ */
127
+ function buildRegistration(
128
+ protocol: ProtocolId,
129
+ registration: PlacementRegistration,
130
+ deployment: PlacementDeployment | undefined,
131
+ ): ReferencePlacementAdapter {
132
+ if (registration.kind === "singleton") return registration.adapter;
133
+ if (deployment === undefined)
134
+ throw new Error(
135
+ `${protocol} is a namespaced placement: its carrier sits under the deployment's own reverse-domain namespace, which has no default — supply { reverseDomain }`,
136
+ );
137
+ return registration.build(deployment.reverseDomain);
138
+ }
139
+
140
+ /**
141
+ * The adapter for a protocol, or `undefined` when this build has no placement for it.
142
+ *
143
+ * TOTAL over the closed protocol set — a caller decides what an absence means, and gets an absence only for a
144
+ * protocol that genuinely has no placement. `deployment` is optional because most protocols need nothing from
145
+ * it; omitting it against a `namespaced` registration throws rather than silently answering `undefined`.
146
+ *
147
+ * OWN properties only. `PLACEMENTS` is an object, so a bare index reads through the prototype chain and
148
+ * `PLACEMENTS["toString"]` answers `Object.prototype.toString` — a value that is not `undefined`, is not
149
+ * `kind: "singleton"`, and therefore reaches the `namespaced` arm, where the registry either asserts a
150
+ * namespace requirement about a protocol that does not exist or throws a raw `TypeError` on
151
+ * `registration.build`. `protocol` is typed `ProtocolId`, but this is the dispatch point a wire token and an
152
+ * MCP tool argument arrive at, and a cast at one caller would be enough. Same guard, same reason, as
153
+ * `binding-core`'s `readAtPath` (the repository's read-path tests — "does not walk prototype keys").
154
+ *
155
+ * ONE guard, not two. `Object.hasOwn` as a separate early return would leave the `=== undefined` check that
156
+ * follows it unreachable — `Partial` admits `undefined` in the value type, but no key here is written with
157
+ * one, so an own key always has a registration. Mutation testing is what says so out loud: with two guards,
158
+ * neutering the second to `if (false)` SURVIVES, which is the instrument reporting a branch no input can take.
159
+ * Folding the own-property test into the lookup leaves exactly one reachable absence and both mutants die.
160
+ */
161
+ export function placementFor(
162
+ protocol: ProtocolId,
163
+ deployment?: PlacementDeployment,
164
+ ): ReferencePlacementAdapter | undefined {
165
+ const registration = Object.hasOwn(PLACEMENTS, protocol)
166
+ ? PLACEMENTS[protocol]
167
+ : undefined;
168
+ if (registration === undefined) return undefined;
169
+ return buildRegistration(protocol, registration, deployment);
170
+ }
171
+
172
+ /** Every protocol this build can place a reference into, in the closed set's own order. */
173
+ export function supportedProtocols(): readonly ProtocolId[] {
174
+ return registrations().map(([protocol]) => protocol);
175
+ }
176
+
177
+ /**
178
+ * The answer to a tier query: what this deployment can build at that tier, and what it could not classify.
179
+ *
180
+ * `unconfigured` is the load-bearing half. A tier query is a question about a WHOLE set ("everything I can
181
+ * ship against stock implementations"), and a namespaced registration cannot be classified at all until its
182
+ * namespace arrives — the tier is a property of the built manifest. Dropping it would answer "no Tier B
183
+ * placements exist" while one sits registered a namespace away, which is a hole read as a fact. Reporting it
184
+ * instead of throwing keeps the caller from inventing a namespace to satisfy a signature, which is the one
185
+ * outcome worse than the hole.
186
+ */
187
+ export type TierSelection = {
188
+ /** The placements at the requested tier, in registration order. */
189
+ readonly adapters: readonly ReferencePlacementAdapter[];
190
+ /** Registered protocols whose tier is unknown because the deployment supplied nothing they require. */
191
+ readonly unconfigured: readonly ProtocolId[];
192
+ };
193
+
194
+ /**
195
+ * The placements at one §8.3 wire-compatibility tier.
196
+ *
197
+ * The selector that makes the host-governs rule operational: a deployment that will only ship what works against stock
198
+ * implementations asks for `"A"` and gets exactly that, rather than reading tiers out of documentation and
199
+ * hoping. Tier B adapters remain constructible — they are simply never returned to a Tier-A caller.
200
+ */
201
+ export function placementsByTier(
202
+ tier: PlacementTier,
203
+ deployment?: PlacementDeployment,
204
+ ): TierSelection {
205
+ const adapters: ReferencePlacementAdapter[] = [];
206
+ const unconfigured: ProtocolId[] = [];
207
+ for (const [protocol, registration] of registrations()) {
208
+ if (registration.kind === "namespaced" && deployment === undefined) {
209
+ unconfigured.push(protocol);
210
+ continue;
211
+ }
212
+ const adapter = buildRegistration(protocol, registration, deployment);
213
+ if (adapter.manifest.tier === tier) adapters.push(adapter);
214
+ }
215
+ return { adapters, unconfigured };
216
+ }