@abubakarsiddiik/compiler 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/README.md +207 -2
- package/dist/compile.d.ts +35 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +120 -0
- package/dist/compile.js.map +1 -0
- package/dist/http.d.ts +28 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +176 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/lift.d.ts +27 -0
- package/dist/lift.d.ts.map +1 -0
- package/dist/lift.js +72 -0
- package/dist/lift.js.map +1 -0
- package/dist/parameterize.d.ts +57 -0
- package/dist/parameterize.d.ts.map +1 -0
- package/dist/parameterize.js +330 -0
- package/dist/parameterize.js.map +1 -0
- package/dist/publish.d.ts +45 -0
- package/dist/publish.d.ts.map +1 -0
- package/dist/publish.js +89 -0
- package/dist/publish.js.map +1 -0
- package/dist/repair-loop.d.ts +51 -0
- package/dist/repair-loop.d.ts.map +1 -0
- package/dist/repair-loop.js +96 -0
- package/dist/repair-loop.js.map +1 -0
- package/dist/repair.d.ts +68 -0
- package/dist/repair.d.ts.map +1 -0
- package/dist/repair.js +235 -0
- package/dist/repair.js.map +1 -0
- package/dist/returns.d.ts +45 -0
- package/dist/returns.d.ts.map +1 -0
- package/dist/returns.js +444 -0
- package/dist/returns.js.map +1 -0
- package/dist/segment.d.ts +70 -0
- package/dist/segment.d.ts.map +1 -0
- package/dist/segment.js +195 -0
- package/dist/segment.js.map +1 -0
- package/dist/ui.d.ts +21 -0
- package/dist/ui.d.ts.map +1 -0
- package/dist/ui.js +46 -0
- package/dist/ui.js.map +1 -0
- package/dist/verify.d.ts +49 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +205 -0
- package/dist/verify.js.map +1 -0
- package/package.json +41 -3
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/README.md
CHANGED
|
@@ -1,3 +1,208 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @abubakarsiddiik/compiler
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
From traces to verified ops. The compiler starts with the repair agent, because
|
|
4
|
+
the first traces come from finishing an intent that no op could serve.
|
|
5
|
+
|
|
6
|
+
## Repair agent
|
|
7
|
+
|
|
8
|
+
`repairIntent` completes one intent with the substrate verbs and a model over
|
|
9
|
+
`ModelPort`:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
const result = await repairIntent({
|
|
13
|
+
model,
|
|
14
|
+
substrate,
|
|
15
|
+
goal: "Search the catalog for socks and open the Merino Socks product page.",
|
|
16
|
+
effect: "read",
|
|
17
|
+
maxSteps: 12,
|
|
18
|
+
check: async (view) => isOnProductPage(view),
|
|
19
|
+
});
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The loop:
|
|
23
|
+
|
|
24
|
+
1. `view` captures the page and ranks affordances with refs.
|
|
25
|
+
2. The model returns one `act`, `view`, `read`, or `done`.
|
|
26
|
+
3. `act` resolves the ref, dispatches, and records effects and a delta.
|
|
27
|
+
4. `done` is accepted only when the optional `check` agrees.
|
|
28
|
+
|
|
29
|
+
The result carries the same `Trace` shape as a fallback scope: every view, act,
|
|
30
|
+
and read, with the locator, value, document and mutation counters, URL, state
|
|
31
|
+
before and after, effects, and delta. The compiler can treat a headless repair
|
|
32
|
+
exactly like a recorded run.
|
|
33
|
+
|
|
34
|
+
A failed act is fed back to the model but not recorded: a stale ref is a retry,
|
|
35
|
+
not a step in the intent.
|
|
36
|
+
|
|
37
|
+
## Segmenter
|
|
38
|
+
|
|
39
|
+
`segmentTrace(trace, map)` cuts a run at state and URL changes, then merges
|
|
40
|
+
pieces that belong to one op according to the map's `from`/`to` sets:
|
|
41
|
+
|
|
42
|
+
- **Store:** the five UI pieces map to `search`, `get_product`, `add_to_cart`,
|
|
43
|
+
`open_checkout`, and `checkout`.
|
|
44
|
+
- **Wizard:** three step changes merge into one `submit_application`, because
|
|
45
|
+
that op runs from `step1` to `done`.
|
|
46
|
+
- **Portal:** login and a same-state filter stay separate; the filter changes
|
|
47
|
+
the URL even though the state stays `invoices`.
|
|
48
|
+
|
|
49
|
+
A candidate is only chosen when the from/to match is unique. When several ops
|
|
50
|
+
share the same boundaries, the segment is marked ambiguous and left for the
|
|
51
|
+
model.
|
|
52
|
+
|
|
53
|
+
`labelSegments({ model, map, segments })` asks the model once for a label per
|
|
54
|
+
segment: `reuse` an existing op, `extend` one, or `propose` a new one. The
|
|
55
|
+
deterministic candidate is a hint, not an answer.
|
|
56
|
+
|
|
57
|
+
## Parameterizer
|
|
58
|
+
|
|
59
|
+
`parameterizeTrace({ trace, params?, labels? }, map)` turns a segment into
|
|
60
|
+
params and constants:
|
|
61
|
+
|
|
62
|
+
- **A segment that matches an op** is parameterized against that op's
|
|
63
|
+
signature. A typed value that fills a named param becomes a param; so does a
|
|
64
|
+
URL path or query piece. Everything else stays a constant.
|
|
65
|
+
- **A segment with no op** is parameterized by its label and the task values.
|
|
66
|
+
- **`parameterizeTraces(inputs, map)`** diffs several traces of the same op. A
|
|
67
|
+
value that changes between runs becomes a param, even when the first pass
|
|
68
|
+
called it a constant.
|
|
69
|
+
|
|
70
|
+
The result carries `params`, `constants`, `missing` (required op params no
|
|
71
|
+
binding covered), and an inferred JSON Schema.
|
|
72
|
+
|
|
73
|
+
On the dev fixtures, the store's five ops and the portal's two ops match their
|
|
74
|
+
oracle signatures exactly. The wizard reports `file_path` as missing, because
|
|
75
|
+
the substrate cannot upload yet.
|
|
76
|
+
|
|
77
|
+
## Returns inference
|
|
78
|
+
|
|
79
|
+
`inferReturns(view)` reads the post-state and builds an extractor plus a JSON
|
|
80
|
+
Schema:
|
|
81
|
+
|
|
82
|
+
- **Rows first.** A repeated test id inside a table or grid is stronger
|
|
83
|
+
evidence than a handful of scalar nodes. Table columns come from the header
|
|
84
|
+
row; a `data-*` attribute on a cell is carried into the locator. Card rows
|
|
85
|
+
group their descendants by role.
|
|
86
|
+
- **Fields next.** A node with a stable test id and a value becomes a field,
|
|
87
|
+
e.g. `order-id` -> `order_id`.
|
|
88
|
+
- **None last.** A page with no data region returns `{ kind: "none" }`.
|
|
89
|
+
|
|
90
|
+
The inferred extractor is run against the same view before it is returned, so
|
|
91
|
+
an inference that does not extract is discarded.
|
|
92
|
+
|
|
93
|
+
`validateInferredReturns(inferred, view)` extracts and validates against the
|
|
94
|
+
schema. On the fixtures, store search rows and portal filter rows validate on
|
|
95
|
+
a held-back run with different data.
|
|
96
|
+
|
|
97
|
+
`nameReturns({ model, inferred })` asks the model to rename the keys. Names
|
|
98
|
+
must be unique snake_case and must exist in the inference; anything else is
|
|
99
|
+
rejected.
|
|
100
|
+
|
|
101
|
+
## URL lift
|
|
102
|
+
|
|
103
|
+
`liftUrl({ segment, returns })` builds a route from the post-state URL:
|
|
104
|
+
|
|
105
|
+
- A query value or path segment that equals a bound param becomes `{name}`.
|
|
106
|
+
- Empty query params are dropped, so a filter form's `q=` and `category=` do
|
|
107
|
+
not end up in the route.
|
|
108
|
+
- A segment whose params never appear in the URL does not lift.
|
|
109
|
+
|
|
110
|
+
`withUrlLift(op, lift, returns)` replaces the op's `url` impl with the lifted
|
|
111
|
+
route and extractor. The store search lifts to `/search?q={query}` and the
|
|
112
|
+
portal filter to `/?status={status}`; both are run with a new param in the
|
|
113
|
+
bench test, not just compared as strings.
|
|
114
|
+
|
|
115
|
+
## HTTP lift
|
|
116
|
+
|
|
117
|
+
`liftHttp({ segment, returns, outcomeCheck })` rebuilds the non-GET requests
|
|
118
|
+
the trace captured:
|
|
119
|
+
|
|
120
|
+
- **Every 2xx write request** becomes a step with the same method, path, and
|
|
121
|
+
body.
|
|
122
|
+
- **A bound param's value** becomes `{name}` in the URL and body.
|
|
123
|
+
- **A value from an earlier response that appears in a later request** becomes
|
|
124
|
+
a `bind`, so a token or id can reach the next step.
|
|
125
|
+
|
|
126
|
+
`withHttpLift(op, lift, returns, outcomeCheck)` replaces the op's `http` impl
|
|
127
|
+
and records the check. The store add-to-cart lifts to
|
|
128
|
+
`POST /api/cart/items` with `view_cart` as `outcome_check`. The bench test
|
|
129
|
+
sends the request, loses the response, reconciles with `view_cart`, and
|
|
130
|
+
asserts the cart still has one item and the executor ran once.
|
|
131
|
+
|
|
132
|
+
## Verifier
|
|
133
|
+
|
|
134
|
+
`verifyOp({ map, op, paramSets, baseUrl })` runs every impl of an op on a
|
|
135
|
+
fresh browser context per param set:
|
|
136
|
+
|
|
137
|
+
- **At least three param sets.** Fewer is rejected before a browser starts.
|
|
138
|
+
- **Params are validated** against the op's schema.
|
|
139
|
+
- **The tier runs**: `url`, `http`, or `ui`. The `http` tier's post checks run
|
|
140
|
+
against the page after the fetch, because a fetch does not navigate.
|
|
141
|
+
- **An `outcome_check`** runs after a write and must succeed.
|
|
142
|
+
- **The report is per impl**: each run's params, result, state, URL, and
|
|
143
|
+
failure message. An op is verified when at least one impl passes every set.
|
|
144
|
+
|
|
145
|
+
On the fixtures, store search verifies on three fresh sessions, a wrong post
|
|
146
|
+
state is rejected with the run that broke, and a lifted `http` add-to-cart
|
|
147
|
+
verifies on three fresh carts with `view_cart` as its outcome check.
|
|
148
|
+
|
|
149
|
+
## Publisher
|
|
150
|
+
|
|
151
|
+
`publishMap({ dir, map, candidates })` writes the next `v<n>.json`:
|
|
152
|
+
|
|
153
|
+
- **A verified candidate** replaces an op of the same name or adds a new one.
|
|
154
|
+
- **An unverified candidate** is rejected and never written.
|
|
155
|
+
- **An irreversible op without `reviewed: true`** is held: it goes to
|
|
156
|
+
`review/v<n>.json` and does not enter the map.
|
|
157
|
+
- **`compiled_from`** records only the traces that reached the map;
|
|
158
|
+
`verified_at` is the publish time.
|
|
159
|
+
|
|
160
|
+
The new map is parsed with the same loader the runtime uses before it is
|
|
161
|
+
written, so the publisher cannot create a map the server will reject. The
|
|
162
|
+
result carries the version, path, map, diff, and review path.
|
|
163
|
+
|
|
164
|
+
## UI lift
|
|
165
|
+
|
|
166
|
+
A segment with no cheaper tier lifts to a `ui` program. The trace already
|
|
167
|
+
carries the semantic locator of every action, so the steps are those actions
|
|
168
|
+
with bound values replaced by `{name}` placeholders. A file input is a `fill`
|
|
169
|
+
with a path; the engine turns that into `DOM.setFileInputFiles`.
|
|
170
|
+
|
|
171
|
+
The wizard's `submit_application` compiles this way and verifies on three fresh
|
|
172
|
+
sessions with the attachment. The parameterizer maps the attachment label to
|
|
173
|
+
`file_path`.
|
|
174
|
+
|
|
175
|
+
## Repair loop
|
|
176
|
+
|
|
177
|
+
`repairOp({ map, op, intent, params, paramSets, repair, capture, dir })` repairs
|
|
178
|
+
one degraded op without a hand edit:
|
|
179
|
+
|
|
180
|
+
1. **The repair run** finishes the op's intent with the substrate and returns
|
|
181
|
+
its trace.
|
|
182
|
+
2. **The last segment** is labelled with the broken op; earlier segments are
|
|
183
|
+
labelled from their candidate, so a login setup stays a setup.
|
|
184
|
+
3. **The compiler** turns the segment into a candidate, using the cheaper tier
|
|
185
|
+
the trace supports.
|
|
186
|
+
4. **The verifier** runs it on fresh sessions with every param set.
|
|
187
|
+
5. **The publisher** writes the next map version.
|
|
188
|
+
|
|
189
|
+
`post` can override the op's post checks when the route moved with the drift;
|
|
190
|
+
the v2 store search does that. An irreversible repair verifies but is held for
|
|
191
|
+
review, not published.
|
|
192
|
+
|
|
193
|
+
On the v2 store, the loop repairs `search` to `/catalog?q={query}` and
|
|
194
|
+
`add_to_cart` to an `http` POST with `view_cart` as its outcome check, then
|
|
195
|
+
publishes v2 and v3.
|
|
196
|
+
|
|
197
|
+
## Local models
|
|
198
|
+
|
|
199
|
+
The repair role is provider-agnostic. Any OpenAI-compatible endpoint works:
|
|
200
|
+
|
|
201
|
+
```sh
|
|
202
|
+
PORTOLAN_LOCAL_BASE_URL=http://127.0.0.1:11434/v1 \
|
|
203
|
+
PORTOLAN_LOCAL_MODEL=qwen2.5:7b-instruct \
|
|
204
|
+
pnpm vitest run bench/repair/repair.test.ts
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
Without those variables the live test skips and the scripted test still proves
|
|
208
|
+
the loop.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Extractor, OpDef, SiteMap } from "@abubakarsiddiik/protocol";
|
|
2
|
+
import type { Trace } from "@abubakarsiddiik/runtime";
|
|
3
|
+
import type { SubstrateView } from "@abubakarsiddiik/substrate";
|
|
4
|
+
import { type ParameterizedSegment } from "./parameterize.js";
|
|
5
|
+
import type { SegmentLabel } from "./segment.js";
|
|
6
|
+
export type CompileTrace = {
|
|
7
|
+
trace: Trace;
|
|
8
|
+
labels?: SegmentLabel[];
|
|
9
|
+
source?: string;
|
|
10
|
+
};
|
|
11
|
+
export type CompileOptions = {
|
|
12
|
+
map: SiteMap;
|
|
13
|
+
traces: CompileTrace[];
|
|
14
|
+
/** Capture the post-state of a url segment. Return undefined if it is gone. */
|
|
15
|
+
capture: (url: string) => Promise<SubstrateView | undefined>;
|
|
16
|
+
/** Read op that proves a write, keyed by op name. */
|
|
17
|
+
outcomeChecks?: Record<string, string>;
|
|
18
|
+
};
|
|
19
|
+
export type CompiledCandidate = {
|
|
20
|
+
op: OpDef;
|
|
21
|
+
segment: ParameterizedSegment;
|
|
22
|
+
tier: "url" | "http" | "ui";
|
|
23
|
+
source?: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Compile traces into candidate ops.
|
|
27
|
+
*
|
|
28
|
+
* A segment with a successful non-GET request lifts to `http`; otherwise a
|
|
29
|
+
* segment with a URL lifts to `url`. The candidate keeps the oracle op's
|
|
30
|
+
* params, from/to, and effect when the map already names it, and takes its
|
|
31
|
+
* returns from the response body or the captured post-state.
|
|
32
|
+
*/
|
|
33
|
+
export declare function compileCandidates(options: CompileOptions): Promise<CompiledCandidate[]>;
|
|
34
|
+
export type { Extractor };
|
|
35
|
+
//# sourceMappingURL=compile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../src/compile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAQ,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AACjF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,EAAyB,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAIvF,OAAO,EAAE,KAAK,oBAAoB,EAAqB,MAAM,mBAAmB,CAAC;AAEjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,GAAG,EAAE,OAAO,CAAC;IACb,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,+EAA+E;IAC/E,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAAC;IAC7D,qDAAqD;IACrD,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,EAAE,KAAK,CAAC;IACV,OAAO,EAAE,oBAAoB,CAAC;IAC9B,IAAI,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAIF;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAyF7F;AA2CD,YAAY,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/compile.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { liftHttp } from "./http.js";
|
|
2
|
+
import { liftUrl } from "./lift.js";
|
|
3
|
+
import { parameterizeTrace } from "./parameterize.js";
|
|
4
|
+
import { inferJsonReturns, inferReturns } from "./returns.js";
|
|
5
|
+
import { liftUi } from "./ui.js";
|
|
6
|
+
const EMPTY_SCHEMA = { type: "object", properties: {}, additionalProperties: false };
|
|
7
|
+
/**
|
|
8
|
+
* Compile traces into candidate ops.
|
|
9
|
+
*
|
|
10
|
+
* A segment with a successful non-GET request lifts to `http`; otherwise a
|
|
11
|
+
* segment with a URL lifts to `url`. The candidate keeps the oracle op's
|
|
12
|
+
* params, from/to, and effect when the map already names it, and takes its
|
|
13
|
+
* returns from the response body or the captured post-state.
|
|
14
|
+
*/
|
|
15
|
+
export async function compileCandidates(options) {
|
|
16
|
+
const candidates = [];
|
|
17
|
+
const seen = new Set();
|
|
18
|
+
for (const input of options.traces) {
|
|
19
|
+
const labels = new Map((input.labels ?? []).map((label) => [label.index, label]));
|
|
20
|
+
const parameterized = parameterizeTrace({ trace: input.trace, ...(input.labels !== undefined ? { labels: input.labels } : {}) }, options.map);
|
|
21
|
+
for (const segment of parameterized.segments) {
|
|
22
|
+
const label = labels.get(segment.segment.index);
|
|
23
|
+
const name = label?.op ?? segment.segment.candidate;
|
|
24
|
+
if (name === undefined || seen.has(name))
|
|
25
|
+
continue;
|
|
26
|
+
const write = segment.segment.actions.flatMap((action) => action.effects).find(isWriteEffect);
|
|
27
|
+
let tier;
|
|
28
|
+
let returns;
|
|
29
|
+
let impl;
|
|
30
|
+
if (write !== undefined) {
|
|
31
|
+
tier = "http";
|
|
32
|
+
returns = inferJsonReturns(write.response_body);
|
|
33
|
+
const lift = liftHttp({
|
|
34
|
+
segment,
|
|
35
|
+
returns,
|
|
36
|
+
...(options.outcomeChecks?.[name] !== undefined
|
|
37
|
+
? { outcomeCheck: options.outcomeChecks[name] }
|
|
38
|
+
: {}),
|
|
39
|
+
});
|
|
40
|
+
if (lift === undefined)
|
|
41
|
+
continue;
|
|
42
|
+
impl = { tier: "http", steps: lift.steps, extract: lift.extract };
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
returns =
|
|
46
|
+
segment.segment.url === undefined
|
|
47
|
+
? noneReturns()
|
|
48
|
+
: await captureReturns(options.capture, segment.segment.url);
|
|
49
|
+
const urlLift = segment.segment.url === undefined ? undefined : liftUrl({ segment, returns });
|
|
50
|
+
if (urlLift !== undefined) {
|
|
51
|
+
tier = "url";
|
|
52
|
+
impl = { tier: "url", route: urlLift.route, extract: urlLift.extract };
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const uiLift = liftUi({ segment, returns });
|
|
56
|
+
if (uiLift === undefined)
|
|
57
|
+
continue;
|
|
58
|
+
tier = "ui";
|
|
59
|
+
impl = { tier: "ui", steps: uiLift.steps, extract: uiLift.extract };
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const oracle = options.map.ops.find((op) => op.name === name);
|
|
63
|
+
const op = {
|
|
64
|
+
name,
|
|
65
|
+
version: oracle?.version ?? 1,
|
|
66
|
+
summary: oracle?.summary ?? `Compiled ${name}.`,
|
|
67
|
+
params: oracle?.params ?? (isEmptySchema(segment.schema) ? EMPTY_SCHEMA : segment.schema),
|
|
68
|
+
returns: returns.schema,
|
|
69
|
+
from: oracle?.from ?? [segment.segment.from ?? "unknown"],
|
|
70
|
+
to: oracle?.to ?? [segment.segment.to ?? "unknown"],
|
|
71
|
+
post: tier === "http" ? [] : (oracle?.post ?? []),
|
|
72
|
+
effect: oracle?.effect ?? (tier === "http" ? "write" : "read"),
|
|
73
|
+
status: "verified",
|
|
74
|
+
...(options.outcomeChecks?.[name] !== undefined
|
|
75
|
+
? { outcome_check: options.outcomeChecks[name] }
|
|
76
|
+
: oracle?.outcome_check !== undefined
|
|
77
|
+
? { outcome_check: oracle.outcome_check }
|
|
78
|
+
: {}),
|
|
79
|
+
impls: [impl],
|
|
80
|
+
};
|
|
81
|
+
candidates.push({
|
|
82
|
+
op,
|
|
83
|
+
segment,
|
|
84
|
+
tier,
|
|
85
|
+
...(input.source !== undefined ? { source: input.source } : {}),
|
|
86
|
+
});
|
|
87
|
+
seen.add(name);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return candidates;
|
|
91
|
+
}
|
|
92
|
+
async function captureReturns(capture, url) {
|
|
93
|
+
const view = await capture(url);
|
|
94
|
+
return view === undefined ? noneReturns() : inferReturns(view);
|
|
95
|
+
}
|
|
96
|
+
function noneReturns() {
|
|
97
|
+
return {
|
|
98
|
+
kind: "none",
|
|
99
|
+
extractor: { kind: "none" },
|
|
100
|
+
value: {},
|
|
101
|
+
schema: EMPTY_SCHEMA,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function isWriteEffect(effect) {
|
|
105
|
+
return (effect.kind === "network" &&
|
|
106
|
+
effect.method !== undefined &&
|
|
107
|
+
effect.method !== "GET" &&
|
|
108
|
+
effect.method !== "HEAD" &&
|
|
109
|
+
effect.status !== undefined &&
|
|
110
|
+
effect.status >= 200 &&
|
|
111
|
+
effect.status < 300 &&
|
|
112
|
+
effect.request_body !== undefined);
|
|
113
|
+
}
|
|
114
|
+
function isEmptySchema(schema) {
|
|
115
|
+
if (typeof schema !== "object" || schema === null)
|
|
116
|
+
return true;
|
|
117
|
+
const properties = schema.properties;
|
|
118
|
+
return (typeof properties !== "object" || properties === null || Object.keys(properties).length === 0);
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=comp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AC,CAAC;IAChC,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;AACjE,CAAC;AAED,SAAS,WAAW;IAClB,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;QAC3B,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,YAAY;KACrB,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CACpB,MAAc;IAEd,OAAO,CACL,MAAM,CAAC,IAAI,KAAK,SAAS;QACzB,MAAM,CAAC,MAAM,KAAK,SAAS;QAC3B,MAAM,CAAC,MAAM,KAAK,KAAK;QACvB,MAAM,CAAC,MAAM,KAAK,MAAM;QACxB,MAAM,CAAC,MAAM,KAAK,SAAS;QAC3B,MAAM,CAAC,MAAM,IAAI,GAAG;QACpB,MAAM,CAAC,MAAM,GAAG,GAAG;QACnB,MAAM,CAAC,YAAY,KAAK,SAAS,CAClC,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,MAAe;IACpC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/D,MAAM,UAAU,GAAI,MAAmC,CAAC,UAAU,CAAC;IACnE,OAAO,CACL,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,KAAK,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,KAAK,CAAC,CAC9F,CAAC;AACJ,CAAC"}
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Extractor, HttpStep, JsonSchema, OpDef } from "@abubakarsiddiik/protocol";
|
|
2
|
+
import type { ParameterizedSegment } from "./parameterize.js";
|
|
3
|
+
import type { InferredReturns } from "./returns.js";
|
|
4
|
+
export type HttpLift = {
|
|
5
|
+
steps: HttpStep[];
|
|
6
|
+
extract: Extractor;
|
|
7
|
+
params: string[];
|
|
8
|
+
outcome_check?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Lift a write segment to the site's own HTTP calls.
|
|
12
|
+
*
|
|
13
|
+
* The trace already captured the request and response bodies per action
|
|
14
|
+
* (T3.03). This finds the non-GET requests that succeeded, rebuilds them as
|
|
15
|
+
* steps, and replaces every bound param's value with a `{name}` placeholder.
|
|
16
|
+
*
|
|
17
|
+
* A value from an earlier response that appears in a later request becomes a
|
|
18
|
+
* `bind`, which is how a token or id reaches the second step. The dev fixtures
|
|
19
|
+
* have no such token; the unit test covers the inference.
|
|
20
|
+
*/
|
|
21
|
+
export declare function liftHttp(input: {
|
|
22
|
+
segment: ParameterizedSegment;
|
|
23
|
+
returns: InferredReturns;
|
|
24
|
+
outcomeCheck?: string;
|
|
25
|
+
}): HttpLift | undefined;
|
|
26
|
+
/** Apply a lifted HTTP impl and returns schema to an op. */
|
|
27
|
+
export declare function withHttpLift(op: OpDef, lift: HttpLift, returns: JsonSchema, outcomeCheck?: string): OpDef;
|
|
28
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EAGT,QAAQ,EACR,UAAU,EACV,KAAK,EACN,MAAM,2BAA2B,CAAC;AAGnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE;IAC9B,OAAO,EAAE,oBAAoB,CAAC;IAC9B,OAAO,EAAE,eAAe,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,QAAQ,GAAG,SAAS,CAsCvB;AAED,4DAA4D;AAC5D,wBAAgB,YAAY,CAC1B,EAAE,EAAE,KAAK,EACT,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,UAAU,EACnB,YAAY,CAAC,EAAE,MAAM,GACpB,KAAK,CAeP"}
|