@gate-forge/witness 0.0.0-stage → 0.8.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.
Files changed (123) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +114 -2
  3. package/dist/adapter/contract-suite.d.ts +167 -0
  4. package/dist/adapter/contract-suite.d.ts.map +1 -0
  5. package/dist/adapter/contract-suite.js +348 -0
  6. package/dist/adapter/contract-suite.js.map +1 -0
  7. package/dist/adapter/contract.d.ts +266 -0
  8. package/dist/adapter/contract.d.ts.map +1 -0
  9. package/dist/adapter/contract.js +2 -0
  10. package/dist/adapter/contract.js.map +1 -0
  11. package/dist/adapter/index.d.ts +8 -0
  12. package/dist/adapter/index.d.ts.map +1 -0
  13. package/dist/adapter/index.js +2 -0
  14. package/dist/adapter/index.js.map +1 -0
  15. package/dist/adapter-kit/config.d.ts +163 -0
  16. package/dist/adapter-kit/config.d.ts.map +1 -0
  17. package/dist/adapter-kit/config.js +21 -0
  18. package/dist/adapter-kit/config.js.map +1 -0
  19. package/dist/adapter-kit/define.d.ts +47 -0
  20. package/dist/adapter-kit/define.d.ts.map +1 -0
  21. package/dist/adapter-kit/define.js +336 -0
  22. package/dist/adapter-kit/define.js.map +1 -0
  23. package/dist/adapter-kit/index.d.ts +34 -0
  24. package/dist/adapter-kit/index.d.ts.map +1 -0
  25. package/dist/adapter-kit/index.js +32 -0
  26. package/dist/adapter-kit/index.js.map +1 -0
  27. package/dist/adapter-kit/projection.d.ts +69 -0
  28. package/dist/adapter-kit/projection.d.ts.map +1 -0
  29. package/dist/adapter-kit/projection.js +85 -0
  30. package/dist/adapter-kit/projection.js.map +1 -0
  31. package/dist/adapter-kit/session.d.ts +105 -0
  32. package/dist/adapter-kit/session.d.ts.map +1 -0
  33. package/dist/adapter-kit/session.js +230 -0
  34. package/dist/adapter-kit/session.js.map +1 -0
  35. package/dist/client/witness-client.d.ts +193 -0
  36. package/dist/client/witness-client.d.ts.map +1 -0
  37. package/dist/client/witness-client.js +321 -0
  38. package/dist/client/witness-client.js.map +1 -0
  39. package/dist/constants.d.ts +189 -0
  40. package/dist/constants.d.ts.map +1 -0
  41. package/dist/constants.js +197 -0
  42. package/dist/constants.js.map +1 -0
  43. package/dist/index.d.ts +15 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +20 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/json.d.ts +16 -0
  48. package/dist/json.d.ts.map +1 -0
  49. package/dist/json.js +21 -0
  50. package/dist/json.js.map +1 -0
  51. package/dist/queue/bullmq.d.ts +28 -0
  52. package/dist/queue/bullmq.d.ts.map +1 -0
  53. package/dist/queue/bullmq.js +210 -0
  54. package/dist/queue/bullmq.js.map +1 -0
  55. package/dist/queue/observer.d.ts +130 -0
  56. package/dist/queue/observer.d.ts.map +1 -0
  57. package/dist/queue/observer.js +179 -0
  58. package/dist/queue/observer.js.map +1 -0
  59. package/dist/surface.d.ts +211 -0
  60. package/dist/surface.d.ts.map +1 -0
  61. package/dist/surface.js +268 -0
  62. package/dist/surface.js.map +1 -0
  63. package/dist/witness/adapter-registry.d.ts +92 -0
  64. package/dist/witness/adapter-registry.d.ts.map +1 -0
  65. package/dist/witness/adapter-registry.js +370 -0
  66. package/dist/witness/adapter-registry.js.map +1 -0
  67. package/dist/witness/behavior-request.d.ts +80 -0
  68. package/dist/witness/behavior-request.d.ts.map +1 -0
  69. package/dist/witness/behavior-request.js +335 -0
  70. package/dist/witness/behavior-request.js.map +1 -0
  71. package/dist/witness/behavior.d.ts +52 -0
  72. package/dist/witness/behavior.d.ts.map +1 -0
  73. package/dist/witness/behavior.js +118 -0
  74. package/dist/witness/behavior.js.map +1 -0
  75. package/dist/witness/bin.d.ts +21 -0
  76. package/dist/witness/bin.d.ts.map +1 -0
  77. package/dist/witness/bin.js +254 -0
  78. package/dist/witness/bin.js.map +1 -0
  79. package/dist/witness/browser.d.ts +221 -0
  80. package/dist/witness/browser.d.ts.map +1 -0
  81. package/dist/witness/browser.js +644 -0
  82. package/dist/witness/browser.js.map +1 -0
  83. package/dist/witness/chaos.d.ts +179 -0
  84. package/dist/witness/chaos.d.ts.map +1 -0
  85. package/dist/witness/chaos.js +270 -0
  86. package/dist/witness/chaos.js.map +1 -0
  87. package/dist/witness/classifications.d.ts +42 -0
  88. package/dist/witness/classifications.d.ts.map +1 -0
  89. package/dist/witness/classifications.js +87 -0
  90. package/dist/witness/classifications.js.map +1 -0
  91. package/dist/witness/env-attestation.d.ts +98 -0
  92. package/dist/witness/env-attestation.d.ts.map +1 -0
  93. package/dist/witness/env-attestation.js +202 -0
  94. package/dist/witness/env-attestation.js.map +1 -0
  95. package/dist/witness/fixture-provider.d.ts +89 -0
  96. package/dist/witness/fixture-provider.d.ts.map +1 -0
  97. package/dist/witness/fixture-provider.js +116 -0
  98. package/dist/witness/fixture-provider.js.map +1 -0
  99. package/dist/witness/loopback-pins.d.ts +79 -0
  100. package/dist/witness/loopback-pins.d.ts.map +1 -0
  101. package/dist/witness/loopback-pins.js +244 -0
  102. package/dist/witness/loopback-pins.js.map +1 -0
  103. package/dist/witness/run-options.d.ts +47 -0
  104. package/dist/witness/run-options.d.ts.map +1 -0
  105. package/dist/witness/run-options.js +179 -0
  106. package/dist/witness/run-options.js.map +1 -0
  107. package/dist/witness/server.d.ts +34 -0
  108. package/dist/witness/server.d.ts.map +1 -0
  109. package/dist/witness/server.js +4899 -0
  110. package/dist/witness/server.js.map +1 -0
  111. package/dist/witness/task.d.ts +77 -0
  112. package/dist/witness/task.d.ts.map +1 -0
  113. package/dist/witness/task.js +201 -0
  114. package/dist/witness/task.js.map +1 -0
  115. package/dist/witness/twin-shapes.d.ts +51 -0
  116. package/dist/witness/twin-shapes.d.ts.map +1 -0
  117. package/dist/witness/twin-shapes.js +127 -0
  118. package/dist/witness/twin-shapes.js.map +1 -0
  119. package/dist/witness/types.d.ts +1094 -0
  120. package/dist/witness/types.d.ts.map +1 -0
  121. package/dist/witness/types.js +2 -0
  122. package/dist/witness/types.js.map +1 -0
  123. package/package.json +98 -4
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 2026 UKD
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/README.md CHANGED
@@ -1,3 +1,115 @@
1
- # Temporary Holding Version
1
+ # @gate-forge/witness
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The runner-neutral Gateforge witness: the loopback HTTP witness that turns a
4
+ test run's traffic into machine-verifiable evidence, plus the contract every
5
+ test runner implements to feed it.
6
+
7
+ ## Why this package exists
8
+
9
+ Gateforge used to only work for Playwright users. The reason was never the
10
+ evidence model — it was where the code sat: the witness service and the
11
+ per-test session client lived inside a package named after one runner.
12
+
13
+ The witness is an HTTP proxy plus a DB/queue reader, and a proxy does not care
14
+ who sends the traffic. Everything runner-specific collapses into four jobs,
15
+ declared by the `RunnerAdapter` contract:
16
+
17
+ | Job | Method | What a runner must provide |
18
+ | --- | --- | --- |
19
+ | List | `enumerate()` | The tests, BEFORE the run. The expected set is fixed first. |
20
+ | Tag | `childEnv()` | The per-test identity: a session proxy origin or a signed session header. |
21
+ | Run | `execute()` | The suite, under trusted supervision with a finite timeout. |
22
+ | Read | `parseResults()` | The outcome in a STRUCTURED format (native JSON or JUnit XML) — never terminal colors. |
23
+
24
+ ## The conformance suite
25
+
26
+ `runRunnerAdapterContract(adapter, host)` is the one suite every adapter must
27
+ pass. The suite owns the assertions; a `RunnerContractHost` owns only the
28
+ runner mechanics (which files to materialize, how to spawn the runner, where
29
+ its report lands). Grading always runs through `superviseExecution` from
30
+ `@gate-forge/core` — the same neutral completeness rules a Playwright run is
31
+ graded by.
32
+
33
+ It checks that the adapter:
34
+
35
+ - enumerates the expected set, and reports a project with **no** tests as
36
+ `unavailable` rather than as an empty successful run;
37
+ - tags every session with its own value, and never leaks parent-side wiring
38
+ (the verifier key, the obligations, spool or CI paths) to the runner child;
39
+ - reads an unreadable report as incomplete instead of inventing outcomes;
40
+ - attributes **nothing** to a test whose runner identity never arrived;
41
+ - runs a suite itself (`execute`), not just reports;
42
+ - and blocks, with a typed cause, on a failing, skipping, retried, unplanned or
43
+ zero-test run.
44
+
45
+ ## Trust rules (unchanged)
46
+
47
+ - A runner's own "passed" is never authority. `parseResults` produces reporter
48
+ INPUT; the verdict comes from supervision plus the witness-issued session
49
+ trace.
50
+ - A request without a valid session tag is never attributed to a test.
51
+ - Additions only: existing JSON keys, cause codes, exit codes, config keys and
52
+ receipts are frozen, and every new setting defaults to today's behavior.
53
+
54
+ ## Adapters
55
+
56
+ The runner-neutral parts live here: the `RunnerAdapter` contract, the
57
+ session tagging types, and the conformance suite. Each adapter
58
+ implementation lives beside the runner machinery it drives (the shared
59
+ collection/report/spool code the supervised run already uses), which is
60
+ why the Playwright adapter has always lived in `@gate-forge/pack-playwright`:
61
+
62
+ | Runner | Where | Tag channel |
63
+ | --- | --- | --- |
64
+ | Playwright | `@gate-forge/pack-playwright` (`discovery/playwright-runner-adapter.ts`) | session proxy |
65
+ | Cypress | `@gate-forge/pack-playwright` (`discovery/cypress-runner-adapter.ts`) | session proxy |
66
+ | pytest + httpx | `@gate-forge/pack-playwright` (`discovery/pytest-runner-adapter.ts` + `python/gateforge_pytest_plugin.py`) | session proxy |
67
+ | Jest/Vitest + supertest | `@gate-forge/pack-playwright` (`discovery/vitest-runner-adapter.ts`) | session proxy |
68
+
69
+ An in-process test client (supertest, FastAPI `TestClient`) calls the app
70
+ without going through the proxy. The adapters REFUSE that mode with a typed
71
+ message instead of passing it silently — the request never reaches the witness,
72
+ so it can never be evidence.
73
+
74
+ ## Per-session adapter identity
75
+
76
+ A per-tenant singleton row (a table whose UNIQUE constraint includes the
77
+ tenant scope column) cannot be read from the fixed witness-environment
78
+ seat: that seat's tenant already has the row. A test that creates the
79
+ tenant first registers that tenant's login for ITS OWN session through
80
+ the session-authenticated `POST /sessions/identity` (`seat` plus the
81
+ credential `values`, keyed by the same witness env var names the adapter
82
+ seat declares). Kit adapters resolve the seat by `ctx.sessionId` first and
83
+ the process-global environment seat otherwise.
84
+
85
+ The whole of its authority is *who the engine reads as, for one session*.
86
+ The engine still performs every read; a wrong tenant makes the row unfound
87
+ (the app answers 403/404 and the entity grades absent); the identity is
88
+ keyed by that session id, cannot be registered for a foreign or ended
89
+ session, and is dropped when the session closes or is released; and the
90
+ credential never reaches a record, the run state, a log or a report. The
91
+ full argument is in `packages/cli/guides/TEST-ENVIRONMENT.md`. Without a
92
+ registration the read is byte-identical to today's behavior.
93
+
94
+ ## The operator's fixture/actor provider
95
+
96
+ A declared behavior case names a `fixture` recipe and an `actor`. The witness
97
+ materializes both before it drives the case, through the module named by
98
+ `GATEFORGE_FIXTURE_PROVIDER` (loaded by `witness/bin.ts` at startup; a
99
+ witness started without one simply has no cases to prepare).
100
+
101
+ The module's default export is `{ prepare(input), release(leaseId),
102
+ resolveCredential(credentialRef) }`. `prepare` returns `{ leaseId, namespace,
103
+ subjects, actors }` with SERVER-ISSUED subject identities; `release` drops what
104
+ that lease provisioned; `resolveCredential` turns a lease `credentialRef` into
105
+ request material and runs in this process, so a secret never leaves it.
106
+
107
+ The provider is engine-side code and the only caller of its own provisioning
108
+ HTTP calls. The suite never imports it, and nothing it returns can mint
109
+ evidence — it only supplies the subjects a case drives, so a case's proof still
110
+ comes from the request the witness issued and the state it read itself. A
111
+ repository should therefore exclude the provider from its product scan scope
112
+ (`.gateforge.yml` `project.paths.exclude`, matching
113
+ `classification-policy.yml` `scanRoots`), or the engine's own provisioning
114
+ traffic is reported as unresolved application call sites. See
115
+ `example/behavior/fixtures/fixture-provider.mjs` for a working provider.
@@ -0,0 +1,167 @@
1
+ /**
2
+ * The runner-adapter contract suite (plan 2026-09-25 phase 0).
3
+ *
4
+ * One shared conformance suite every runner adapter must pass. The suite
5
+ * owns the ASSERTIONS; a {@link RunnerContractHost} owns only the
6
+ * runner mechanics (which files to materialize, how to spawn the runner,
7
+ * where its structured report lands). Nothing here parses a runner's
8
+ * output — the adapter does that, and the suite checks the adapter did
9
+ * it honestly.
10
+ *
11
+ * The suite is deliberately framework-free (no test runner import): each
12
+ * adapter's package runs {@link runRunnerAdapterContract} and asserts
13
+ * the returned violation list is empty. That keeps one implementation
14
+ * of "what a runner adapter must do" instead of N look-alike copies.
15
+ *
16
+ * Grading always runs through `superviseExecution`
17
+ * (`@gate-forge/core`) — the neutral completeness rules. The suite never
18
+ * invents a verdict of its own, so a contract pass means the adapter
19
+ * feeds the same enforcement point a Playwright run feeds.
20
+ */
21
+ import { type RunnerExecutionEnvelope } from '@gate-forge/core';
22
+ import type { RunnerAdapter, RunnerExecuteRequest, RunnerRawResults } from './contract.js';
23
+ /**
24
+ * The behaviours a conforming adapter must distinguish. Each one is a
25
+ * way a run can silently look green when it is not.
26
+ */
27
+ export type ContractScenarioKind =
28
+ /** Every planned test passes on its first attempt. */
29
+ 'pass'
30
+ /** A planned test fails. */
31
+ | 'fail'
32
+ /** A planned test is skipped — nothing was proven by it. */
33
+ | 'skip'
34
+ /** A planned test needed a second attempt (required retries are zero). */
35
+ | 'retry'
36
+ /** The runner ran a test that was not in the expected set. */
37
+ | 'unplanned'
38
+ /** The runner ran nothing at all. */
39
+ | 'zero'
40
+ /** The runner ran the suite but never tagged its traffic. */
41
+ | 'untagged';
42
+ /** One contract scenario: the expected set plus the behaviour to produce. */
43
+ export interface ContractScenario {
44
+ kind: ContractScenarioKind;
45
+ /** Exact logical keys the run is expected to cover (fixed pre-run). */
46
+ expectedLogicalKeys: readonly string[];
47
+ /** Repo-relative posix file the planned tests live in. */
48
+ file: string;
49
+ /** Full title path of the planned tests. */
50
+ titlePath: readonly string[];
51
+ /** Runner project, or null. */
52
+ project: string | null;
53
+ }
54
+ /**
55
+ * One observed execution of a scenario: the runner's REAL structured
56
+ * report plus the envelope the adapter read out of it.
57
+ *
58
+ * The envelope is always `adapter.parseResults(raw)` — never the
59
+ * runner's own verdict and never a hand-written one. Grading the
60
+ * adapter's reading of real runner output is the whole point: a runner
61
+ * that prints "0 failed" proves nothing until an adapter has turned it
62
+ * into outcomes supervision can compare against the expected set.
63
+ */
64
+ export interface ContractObservation {
65
+ /** `adapter.parseResults(raw)` — the adapter's structured envelope. */
66
+ envelope: RunnerExecutionEnvelope;
67
+ /** The runner's structured report, exactly as the runner emitted it. */
68
+ raw: RunnerRawResults;
69
+ /**
70
+ * Why the host produced this report outside `adapter.execute` (e.g.
71
+ * the scenario cannot occur under the supervised policy, which forces
72
+ * zero retries). Empty when `adapter.execute` produced it.
73
+ */
74
+ note?: string;
75
+ }
76
+ /**
77
+ * The runner-specific mechanics a contract run needs. An adapter
78
+ * supplies none of these: the suite drives the adapter and asserts.
79
+ */
80
+ export interface RunnerContractHost {
81
+ /** Runner name under test (must equal the adapter's). */
82
+ readonly runner: string;
83
+ /**
84
+ * The runner project the expected set is bound to, or null when the
85
+ * runner reports none. It is part of the identity join key, so the
86
+ * suite cannot guess it: the host owns the runner's own naming.
87
+ */
88
+ readonly project: string | null;
89
+ /**
90
+ * The scenario FILE + TITLE PATH identity the runner natively
91
+ * collects, when the runner's own naming cannot be the suite default
92
+ * (`e2e/contract.spec.ts` › `contract` — a pytest module, for
93
+ * example, cannot live at a `.ts` path). The host owns the runner's
94
+ * own naming for exactly the same reason {@link project} is
95
+ * host-owned; every assertion is unchanged.
96
+ */
97
+ readonly scenario?: Partial<Pick<ContractScenario, 'file' | 'titlePath'>>;
98
+ /**
99
+ * Materializes a project whose suite produces `scenario`.
100
+ *
101
+ * Args:
102
+ * scenario: the behaviour the produced suite must exhibit.
103
+ *
104
+ * Returns:
105
+ * Promise<string>: the absolute project root.
106
+ */
107
+ materialize(scenario: ContractScenario): Promise<string>;
108
+ /**
109
+ * Spawns the REAL runner over the materialized project and returns its
110
+ * structured report, graded by `adapter.parseResults`.
111
+ *
112
+ * The host spawns; the adapter reads. A scenario the supervised
113
+ * policy forbids (a retry — the supervised run forces `--retries=0`)
114
+ * is produced with the runner's OWN setting and the host says so in
115
+ * {@link ContractObservation.note}: the point of that case is that
116
+ * the adapter DETECTS a retry when one happens, not that the engine
117
+ * permits one.
118
+ *
119
+ * Args:
120
+ * adapter: the adapter under test (for `parseResults` only).
121
+ * projectRoot: the root `materialize` returned.
122
+ * scenario: the behaviour to produce.
123
+ *
124
+ * Returns:
125
+ * Promise<ContractObservation>: the real report and its envelope.
126
+ */
127
+ run(adapter: RunnerAdapter, projectRoot: string, scenario: ContractScenario): Promise<ContractObservation>;
128
+ /**
129
+ * The request a `pass` scenario executes with (timeout, run state).
130
+ * The suite calls `adapter.execute` with it for the execute check.
131
+ */
132
+ executeRequest(projectRoot: string, scenario: ContractScenario): RunnerExecuteRequest;
133
+ /**
134
+ * A report in this runner's NATIVE format whose every row carries no
135
+ * framework identity — the shape a runner emits when its per-test tag
136
+ * never reached it. The suite feeds it to `parseResults` to prove the
137
+ * adapter attributes nothing from it.
138
+ */
139
+ untaggedReport(): string;
140
+ }
141
+ /** One contract violation (a non-empty list is a contract failure). */
142
+ export interface ContractViolation {
143
+ /** The contract case the violation belongs to. */
144
+ case: string;
145
+ /** Single-cause explanation. */
146
+ detail: string;
147
+ }
148
+ /** The scenarios every adapter is graded on, in a stable order. */
149
+ export declare const CONTRACT_SCENARIOS: readonly ContractScenarioKind[];
150
+ /** Builds the canonical scenario for one kind (single planned test). */
151
+ export declare function contractScenario(kind: ContractScenarioKind, overrides?: Partial<ContractScenario>): ContractScenario;
152
+ /**
153
+ * Runs the full contract against one adapter.
154
+ *
155
+ * Every check is fail-closed: an adapter that throws, reports a missing
156
+ * field, or grades a dishonest run green produces a violation. The
157
+ * returned list is the whole result — an empty list is a pass.
158
+ *
159
+ * Args:
160
+ * adapter: the adapter under test.
161
+ * host: the runner mechanics for `adapter.runner`.
162
+ *
163
+ * Returns:
164
+ * Promise<ContractViolation[]>: every contract case that failed.
165
+ */
166
+ export declare function runRunnerAdapterContract(adapter: RunnerAdapter, host: RunnerContractHost): Promise<ContractViolation[]>;
167
+ //# sourceMappingURL=contract-suite.d.ts.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