@reticlehq/terminal 0.0.0-stage → 3.11.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/NOTICE +12 -0
- package/README.md +15 -2
- package/bin/drive.mjs +222 -0
- package/dist/channels.d.ts +51 -0
- package/dist/channels.js +51 -0
- package/dist/detect.d.ts +8 -0
- package/dist/detect.js +176 -0
- package/dist/hud/frame.d.ts +47 -0
- package/dist/hud/frame.js +70 -0
- package/dist/hud/live.d.ts +56 -0
- package/dist/hud/live.js +92 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +19 -0
- package/dist/manifest.d.ts +60 -0
- package/dist/manifest.js +15 -0
- package/dist/net/proxy.d.ts +48 -0
- package/dist/net/proxy.js +75 -0
- package/dist/process/node-supervisor.d.ts +73 -0
- package/dist/process/node-supervisor.js +150 -0
- package/dist/process/supervisor.d.ts +103 -0
- package/dist/process/supervisor.js +13 -0
- package/dist/report.d.ts +47 -0
- package/dist/report.js +67 -0
- package/dist/run.d.ts +46 -0
- package/dist/run.js +71 -0
- package/dist/state-contract.d.ts +36 -0
- package/dist/state-contract.js +57 -0
- package/dist/terminal-realm.d.ts +161 -0
- package/dist/terminal-realm.js +647 -0
- package/dist/workspace/port.d.ts +34 -0
- package/dist/workspace/port.js +10 -0
- package/dist/workspace/snapshot.d.ts +73 -0
- package/dist/workspace/snapshot.js +145 -0
- package/package.json +54 -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 2026 Reticle Labs
|
|
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,12 @@
|
|
|
1
|
+
Reticle
|
|
2
|
+
Copyright 2026 Reticle Labs
|
|
3
|
+
|
|
4
|
+
This product includes software developed at Reticle Labs.
|
|
5
|
+
Licensed under the Apache License, Version 2.0.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
Heroicons (presenter HUD)
|
|
10
|
+
Copyright (c) Tailwind Labs, Inc.
|
|
11
|
+
Licensed under the MIT License.
|
|
12
|
+
https://github.com/tailwindlabs/heroicons
|
package/README.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @reticlehq/terminal
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Reticle realm for the terminal. It runs a command-line program, watches what it prints and what it does to the filesystem, and gives a verdict on a claim. The program needs no change.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx -p @reticlehq/terminal reticle-terminal --expect "dist/index.js is written" --path dist/index.js -- npm run build
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
- **The claim comes first.** `--expect` says what should become true, and `--path` names the file that shows it.
|
|
10
|
+
- **The evidence is what happened.** The output, the exit code, and each file that was added, changed or removed, from a snapshot of the folder before and after the command.
|
|
11
|
+
- **The verdict is `yes`, `no` or `unknown`.** An exit code of 0 is not a pass by itself: the file that the claim names must show the change.
|
|
12
|
+
- `--json` prints the record for an agent. `--cwd <dir>` runs the command in another folder.
|
|
13
|
+
|
|
14
|
+
`@reticlehq/computer` uses the same file snapshot to report the files that a desktop action wrote.
|
|
15
|
+
|
|
16
|
+
[Reticle](https://github.com/reticlehq/reticle) · Apache-2.0
|
package/bin/drive.mjs
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Drive one command and WATCH it prove itself.
|
|
3
|
+
//
|
|
4
|
+
// reticle-terminal --expect "<what should become true>" --path <file> -- <command> [args...]
|
|
5
|
+
//
|
|
6
|
+
// The point of this binary is that verification is something you can SEE happening rather than a
|
|
7
|
+
// paragraph you read afterwards. It paints a live pane: the claim first, the channels being
|
|
8
|
+
// watched, output and filesystem changes as they land, and a verdict that is honestly absent
|
|
9
|
+
// until the window closes.
|
|
10
|
+
//
|
|
11
|
+
// Everything it prints is the same record the adjudicator reasons over. A human and an agent
|
|
12
|
+
// looking at different evidence and disagreeing about what happened is the failure this is shaped
|
|
13
|
+
// to prevent.
|
|
14
|
+
|
|
15
|
+
import { dirname, join, resolve } from 'node:path';
|
|
16
|
+
import { fileURLToPath } from 'node:url';
|
|
17
|
+
|
|
18
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
19
|
+
const {
|
|
20
|
+
TerminalRealm,
|
|
21
|
+
NodeSupervisor,
|
|
22
|
+
nodeWorkspace,
|
|
23
|
+
createLiveHud,
|
|
24
|
+
renderReport,
|
|
25
|
+
EXCLUDED_BY_DEFAULT,
|
|
26
|
+
} = await import(join(HERE, '..', 'dist', 'index.js'));
|
|
27
|
+
const { adjudicate, Declaration, assertionsHeldUnder } = await import('open-verification');
|
|
28
|
+
|
|
29
|
+
const argv = process.argv.slice(2);
|
|
30
|
+
const sep = argv.indexOf('--');
|
|
31
|
+
const flag = (name) => {
|
|
32
|
+
const i = argv.indexOf(name);
|
|
33
|
+
return i === -1 || i > (sep === -1 ? argv.length : sep) ? undefined : argv[i + 1];
|
|
34
|
+
};
|
|
35
|
+
const expectation = flag('--expect');
|
|
36
|
+
const expectPath = flag('--path');
|
|
37
|
+
const root = resolve(flag('--cwd') ?? process.cwd());
|
|
38
|
+
const command = sep === -1 ? [] : argv.slice(sep + 1);
|
|
39
|
+
|
|
40
|
+
if (expectation === undefined || expectPath === undefined || command.length === 0) {
|
|
41
|
+
process.stderr.write(
|
|
42
|
+
'usage: reticle-terminal --expect "<claim>" --path <file> [--cwd <dir>] [--json] -- <command> [args...]\n\n' +
|
|
43
|
+
'The claim and the path are required and are declared BEFORE the command runs. That ordering\n' +
|
|
44
|
+
'is the method: an expectation written after the result can be talked into agreeing with it.\n',
|
|
45
|
+
);
|
|
46
|
+
process.exit(2);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const supervisor = new NodeSupervisor({
|
|
50
|
+
executable: command[0],
|
|
51
|
+
workspaceRoot: root,
|
|
52
|
+
tool: { id: command[0], version: 'unknown', workspace: root },
|
|
53
|
+
now: () => Date.now(),
|
|
54
|
+
});
|
|
55
|
+
/*
|
|
56
|
+
* Never exclude the thing you were asked to watch.
|
|
57
|
+
*
|
|
58
|
+
* `dist` is in the default exclusion list -- it is somebody else's build output and hashing it
|
|
59
|
+
* twice a window is expensive -- and `dist/` is also the single commonest place a CLI writes. So a
|
|
60
|
+
* caller naming `--path dist/index.js` got a snapshot that structurally could not see it, an empty
|
|
61
|
+
* diff, and a confident `no` about a build that had worked. A FALSE POSITIVE, which costs more
|
|
62
|
+
* than a miss, because a check that cries wolf stops being read.
|
|
63
|
+
*
|
|
64
|
+
* Found by an agent driving this against a healthy build and refusing to believe the verdict. It
|
|
65
|
+
* had to read this package's source to work out why, which is the part that makes it serious: the
|
|
66
|
+
* JSON handed it a contradicted verdict and no hint that the target was invisible.
|
|
67
|
+
*
|
|
68
|
+
* A default exclusion is a cost-saving guess. A path the caller named is not a guess, so it wins.
|
|
69
|
+
*/
|
|
70
|
+
const declaredRoot = expectPath.split('/')[0];
|
|
71
|
+
const exclude = EXCLUDED_BY_DEFAULT.filter((dir) => dir !== declaredRoot);
|
|
72
|
+
|
|
73
|
+
const realm = new TerminalRealm({
|
|
74
|
+
supervisor,
|
|
75
|
+
manifest: {
|
|
76
|
+
workspaceRoot: root,
|
|
77
|
+
commands: [{ name: command[0], meaning: expectation, mutating: true, argv: command.slice(1) }],
|
|
78
|
+
},
|
|
79
|
+
workspace: nodeWorkspace([root], { exclude }),
|
|
80
|
+
now: () => Date.now(),
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const hud = createLiveHud({
|
|
84
|
+
expectation,
|
|
85
|
+
workspaceRoot: root,
|
|
86
|
+
now: () => Date.now(),
|
|
87
|
+
// Only paint when somebody is watching. Piped into a file or a CI log, the pane would be
|
|
88
|
+
// thousands of repaint frames, so a non-interactive run stays silent and prints the report.
|
|
89
|
+
...(process.stderr.isTTY === true ? { write: (f) => process.stderr.write(f) } : {}),
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const claim = {
|
|
93
|
+
id: 'c1',
|
|
94
|
+
statement: expectation,
|
|
95
|
+
declaredAt: Declaration.BEFORE_ACTION,
|
|
96
|
+
assertions: [
|
|
97
|
+
{
|
|
98
|
+
id: 'a1',
|
|
99
|
+
predicate: {
|
|
100
|
+
kind: 'present',
|
|
101
|
+
match: { channel: 'x-artifact', summary: 'cli.fs.written', valueContains: expectPath },
|
|
102
|
+
},
|
|
103
|
+
reads: `${expectPath} was written`,
|
|
104
|
+
channels: ['x-artifact'],
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
hud.send({
|
|
110
|
+
kind: 'started',
|
|
111
|
+
command: command[0],
|
|
112
|
+
argv: command.slice(1),
|
|
113
|
+
watching: realm.channels().map((c) => c.id),
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const window = realm.openWindow(600_000);
|
|
117
|
+
await supervisor.run(command[0], command.slice(1), 600_000, {
|
|
118
|
+
onStdout: (text) => hud.send({ kind: 'stdout', text }),
|
|
119
|
+
onStderr: (text) => hud.send({ kind: 'stderr', text }),
|
|
120
|
+
});
|
|
121
|
+
const closed = realm.closeWindow(window);
|
|
122
|
+
const observed = await realm.observe(closed);
|
|
123
|
+
const coverage = await realm.coverage(closed);
|
|
124
|
+
const changes = realm.changesIn(closed);
|
|
125
|
+
hud.send({ kind: 'changed', changes });
|
|
126
|
+
hud.send({ kind: 'ended', exit: undefined });
|
|
127
|
+
|
|
128
|
+
const decided = adjudicate({
|
|
129
|
+
claim,
|
|
130
|
+
window: closed,
|
|
131
|
+
channels: realm.channels(),
|
|
132
|
+
evidence: observed
|
|
133
|
+
.filter((o) => o.channel === 'x-artifact')
|
|
134
|
+
.map((o) => ({
|
|
135
|
+
observation: o,
|
|
136
|
+
provenance: {
|
|
137
|
+
class: 'observed',
|
|
138
|
+
source: '@reticlehq/terminal',
|
|
139
|
+
method: 'filesystem snapshot, before and after',
|
|
140
|
+
subject: realm.identity(),
|
|
141
|
+
at: Date.now(),
|
|
142
|
+
},
|
|
143
|
+
independence: 'independent',
|
|
144
|
+
grade: 'consequence',
|
|
145
|
+
})),
|
|
146
|
+
coverage,
|
|
147
|
+
anomalies: await realm.detect(closed, observed),
|
|
148
|
+
assertionsHeld: assertionsHeldUnder(claim.assertions, observed, coverage),
|
|
149
|
+
consequenceHeldBefore: undefined,
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
hud.send({
|
|
153
|
+
kind: 'verdict',
|
|
154
|
+
verdict: {
|
|
155
|
+
verdict: decided.verdict,
|
|
156
|
+
ground: decided.ground,
|
|
157
|
+
boughtBy: decided.verdict === 'yes' ? 'x-artifact' : undefined,
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
hud.stop();
|
|
161
|
+
|
|
162
|
+
/*
|
|
163
|
+
* Machine-readable, because the whole argument for a binary over an MCP tool is that an agent can
|
|
164
|
+
* run it -- and an agent parsing a rendered report to decide what to do next is absurd. This is
|
|
165
|
+
* the shape a caller branches on: the verdict, WHAT BOUGHT IT, what changed, and what was not
|
|
166
|
+
* seen. The blind spots travel with it deliberately: a caller deciding from a verdict without
|
|
167
|
+
* knowing what the verifier could not see is making the decision this project exists to improve,
|
|
168
|
+
* with better manners.
|
|
169
|
+
*/
|
|
170
|
+
if (argv.includes('--json')) {
|
|
171
|
+
const exit = observed.find((o) => o.summary === 'cli.exit.code');
|
|
172
|
+
process.stdout.write(
|
|
173
|
+
JSON.stringify(
|
|
174
|
+
{
|
|
175
|
+
verdict: decided.verdict,
|
|
176
|
+
ground: decided.ground,
|
|
177
|
+
grade: decided.grade ?? null,
|
|
178
|
+
boughtBy: decided.verdict === 'yes' ? 'x-artifact' : null,
|
|
179
|
+
proved: decided.verdict === 'yes',
|
|
180
|
+
expectation,
|
|
181
|
+
command: { name: command[0], argv: command.slice(1) },
|
|
182
|
+
// Present and visibly NOT what decided, for the same reason the rendered pane shows it.
|
|
183
|
+
exit: exit?.value ?? null,
|
|
184
|
+
durationMs: Number(observed.find((o) => o.summary === 'cli.duration.ms')?.value ?? 0),
|
|
185
|
+
changes: changes.map((c) => ({
|
|
186
|
+
path: c.path.startsWith(root) ? `.${c.path.slice(root.length)}` : c.path,
|
|
187
|
+
kind: c.kind,
|
|
188
|
+
})),
|
|
189
|
+
blindSpots: coverage.blindSpots.map((s) => ({
|
|
190
|
+
kind: s.kind,
|
|
191
|
+
detail: s.detail,
|
|
192
|
+
impeaching: s.impeaching,
|
|
193
|
+
})),
|
|
194
|
+
reasons: decided.reasons,
|
|
195
|
+
},
|
|
196
|
+
null,
|
|
197
|
+
2,
|
|
198
|
+
) + '\n',
|
|
199
|
+
);
|
|
200
|
+
} else if (process.stderr.isTTY !== true) {
|
|
201
|
+
const exit = observed.find((o) => o.summary === 'cli.exit.code');
|
|
202
|
+
process.stderr.write(
|
|
203
|
+
renderReport({
|
|
204
|
+
expectation,
|
|
205
|
+
command: command[0],
|
|
206
|
+
argv: command.slice(1),
|
|
207
|
+
durationMs: Number(observed.find((o) => o.summary === 'cli.duration.ms')?.value ?? 0),
|
|
208
|
+
exit: { code: exit?.value, signal: undefined, wasSignalled: false },
|
|
209
|
+
changes,
|
|
210
|
+
blindSpots: coverage.blindSpots,
|
|
211
|
+
adjudication: decided,
|
|
212
|
+
declaredAt: claim.declaredAt,
|
|
213
|
+
boughtBy: decided.verdict === 'yes' ? 'x-artifact' : undefined,
|
|
214
|
+
workspaceRoot: root,
|
|
215
|
+
}) + '\n',
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// A drive that did not PROVE its claim exits non-zero, so this composes into a script. `unknown`
|
|
220
|
+
// is not success: it is the verifier saying it could not tell, and a pipeline that treats that as
|
|
221
|
+
// a pass has reinvented the exit code this whole thing exists to distrust.
|
|
222
|
+
process.exit(decided.verdict === 'yes' ? 0 : 1);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a command-line subject can be watched on, named for what it IS here.
|
|
3
|
+
*
|
|
4
|
+
* Two of these are the protocol's own channels under a local name, and two are extensions. The
|
|
5
|
+
* local names exist because the mapping is not obvious and a reader should not have to rediscover
|
|
6
|
+
* it: a CLI's exit code travels on the protocol's `signal` channel, because an exit status is the
|
|
7
|
+
* subject announcing something about itself, which is exactly what that channel means.
|
|
8
|
+
*
|
|
9
|
+
* The extensions follow the `x-` rule. Neither is proposed as a named member of the protocol: that
|
|
10
|
+
* needs two INDEPENDENT implementations agreeing on the meaning, and both of the ones that exist
|
|
11
|
+
* today share an author.
|
|
12
|
+
*/
|
|
13
|
+
export declare const TerminalChannel: {
|
|
14
|
+
/** stdout and stderr. A CLI's output is deliberate, so see `CLI_CHANNELS` for the downgrade. */
|
|
15
|
+
readonly LOG: "log";
|
|
16
|
+
/** The exit code the tool CHOSE. The subject announcing something about itself. */
|
|
17
|
+
readonly EXIT_STATUS: "signal";
|
|
18
|
+
/** How long it took, and whether it was still running. */
|
|
19
|
+
readonly TIME: "time";
|
|
20
|
+
/**
|
|
21
|
+
* Hosts the tool dialled, when a proxy is watching. Never what it said to them.
|
|
22
|
+
*
|
|
23
|
+
* Named here with the others rather than reached for as `ChannelId.NET` at each use, so this
|
|
24
|
+
* file stays the one place a reader learns what this realm can see.
|
|
25
|
+
*/
|
|
26
|
+
readonly NET: "net";
|
|
27
|
+
/**
|
|
28
|
+
* Termination imposed from OUTSIDE the process: a signal, an OOM kill, a supervisor.
|
|
29
|
+
*
|
|
30
|
+
* A separate channel from `EXIT_STATUS` and not a field on it, which is OVP-CHAN-5 applied to
|
|
31
|
+
* the realm that produced the rule. The two carry opposite provenance -- one the tool chose, one
|
|
32
|
+
* the kernel imposed -- and a single declaration would have to lie about one of them.
|
|
33
|
+
*/
|
|
34
|
+
readonly PROCESS: "x-proc";
|
|
35
|
+
/**
|
|
36
|
+
* That a path exists, its size, its mtime. The filesystem decided these, not the subject.
|
|
37
|
+
*
|
|
38
|
+
* Phase 2. Named here so the vocabulary lives in one file rather than appearing when it is
|
|
39
|
+
* first needed, which is how two spellings of one channel get into a codebase.
|
|
40
|
+
*/
|
|
41
|
+
readonly ARTIFACT: "x-artifact";
|
|
42
|
+
/**
|
|
43
|
+
* The bytes inside a file, which the subject authored entirely.
|
|
44
|
+
*
|
|
45
|
+
* Split from `ARTIFACT` for the reason the protocol's own `visual` channel is actuation-derived
|
|
46
|
+
* despite being observed out of process: it is the CAUSING that decides independence. The
|
|
47
|
+
* filesystem decides WHETHER a write lands; nothing outside the tool decides what is in it.
|
|
48
|
+
*/
|
|
49
|
+
readonly ARTIFACT_CONTENT: "x-artifact-content";
|
|
50
|
+
};
|
|
51
|
+
export type TerminalChannel = (typeof TerminalChannel)[keyof typeof TerminalChannel];
|
package/dist/channels.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ChannelId } from 'open-verification';
|
|
2
|
+
/**
|
|
3
|
+
* What a command-line subject can be watched on, named for what it IS here.
|
|
4
|
+
*
|
|
5
|
+
* Two of these are the protocol's own channels under a local name, and two are extensions. The
|
|
6
|
+
* local names exist because the mapping is not obvious and a reader should not have to rediscover
|
|
7
|
+
* it: a CLI's exit code travels on the protocol's `signal` channel, because an exit status is the
|
|
8
|
+
* subject announcing something about itself, which is exactly what that channel means.
|
|
9
|
+
*
|
|
10
|
+
* The extensions follow the `x-` rule. Neither is proposed as a named member of the protocol: that
|
|
11
|
+
* needs two INDEPENDENT implementations agreeing on the meaning, and both of the ones that exist
|
|
12
|
+
* today share an author.
|
|
13
|
+
*/
|
|
14
|
+
export const TerminalChannel = {
|
|
15
|
+
/** stdout and stderr. A CLI's output is deliberate, so see `CLI_CHANNELS` for the downgrade. */
|
|
16
|
+
LOG: ChannelId.LOG,
|
|
17
|
+
/** The exit code the tool CHOSE. The subject announcing something about itself. */
|
|
18
|
+
EXIT_STATUS: ChannelId.SIGNAL,
|
|
19
|
+
/** How long it took, and whether it was still running. */
|
|
20
|
+
TIME: ChannelId.TIME,
|
|
21
|
+
/**
|
|
22
|
+
* Hosts the tool dialled, when a proxy is watching. Never what it said to them.
|
|
23
|
+
*
|
|
24
|
+
* Named here with the others rather than reached for as `ChannelId.NET` at each use, so this
|
|
25
|
+
* file stays the one place a reader learns what this realm can see.
|
|
26
|
+
*/
|
|
27
|
+
NET: ChannelId.NET,
|
|
28
|
+
/**
|
|
29
|
+
* Termination imposed from OUTSIDE the process: a signal, an OOM kill, a supervisor.
|
|
30
|
+
*
|
|
31
|
+
* A separate channel from `EXIT_STATUS` and not a field on it, which is OVP-CHAN-5 applied to
|
|
32
|
+
* the realm that produced the rule. The two carry opposite provenance -- one the tool chose, one
|
|
33
|
+
* the kernel imposed -- and a single declaration would have to lie about one of them.
|
|
34
|
+
*/
|
|
35
|
+
PROCESS: 'x-proc',
|
|
36
|
+
/**
|
|
37
|
+
* That a path exists, its size, its mtime. The filesystem decided these, not the subject.
|
|
38
|
+
*
|
|
39
|
+
* Phase 2. Named here so the vocabulary lives in one file rather than appearing when it is
|
|
40
|
+
* first needed, which is how two spellings of one channel get into a codebase.
|
|
41
|
+
*/
|
|
42
|
+
ARTIFACT: 'x-artifact',
|
|
43
|
+
/**
|
|
44
|
+
* The bytes inside a file, which the subject authored entirely.
|
|
45
|
+
*
|
|
46
|
+
* Split from `ARTIFACT` for the reason the protocol's own `visual` channel is actuation-derived
|
|
47
|
+
* despite being observed out of process: it is the CAUSING that decides independence. The
|
|
48
|
+
* filesystem decides WHETHER a write lands; nothing outside the tool decides what is in it.
|
|
49
|
+
*/
|
|
50
|
+
ARTIFACT_CONTENT: 'x-artifact-content',
|
|
51
|
+
};
|
package/dist/detect.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type Anomaly, type Observation } from 'open-verification';
|
|
2
|
+
/** Every disagreement these rules can see in one window. */
|
|
3
|
+
export interface DetectContext {
|
|
4
|
+
/** Hosts the command under test declared it would reach. Empty means it declared none. */
|
|
5
|
+
readonly reaches?: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
/** Every disagreement these rules can see in one window. */
|
|
8
|
+
export declare function detectAnomalies(observations: readonly Observation[], context?: DetectContext): readonly Anomaly[];
|