trenyx 0.0.0-stage → 0.1.1

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 ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
package/README.md CHANGED
@@ -1,3 +1,159 @@
1
- # Temporary Holding Version
1
+ # trenyx run
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
+ **Early release.** Scores are self-run and can differ from Trenyx's independent runs.
4
+
5
+ Plants realistic bugs in a throwaway copy of your repo, runs your tests against each one, and tells you which got through.
6
+ Everything runs on your machine. Your code goes only to the AI provider you already use, through your own key. Nothing goes
7
+ to Trenyx: there is no telemetry, no upload and no Trenyx server in this version.
8
+
9
+ ```sh
10
+ cd your-repo # a git repo with passing tests
11
+ export ANTHROPIC_API_KEY=...
12
+ npx trenyx run
13
+ ```
14
+
15
+ What you see: it runs your tests twice on a clean copy of your last commit, says which provider gets the code and how many
16
+ files, and asks before sending anything. Then it locks the bug list with a SHA-256 fingerprint, prints where the bugs went,
17
+ runs each bug alone, and prints the score and every bug that got through, with file and line. A markdown report goes to
18
+ `~/.trenyx/reports/` (or `--out`). The score is a self-run score, not an independent Trenyx result. AI output can be wrong, so
19
+ check the bugs and the score before you rely on them. For an independent measure, run by Trenyx and not by you, see
20
+ https://trenyx.io.
21
+
22
+ `trenyx run --help` lists the options. The useful ones: `--bugs N`, `--test-cmd`, `--path`, `--exclude`, `--copy`,
23
+ `--list-files`, `--bugs-file`, `--max-cost`, `--seed`.
24
+
25
+ ## Where your code goes
26
+
27
+ | What | Where |
28
+ |---|---|
29
+ | Product source at your last commit, tests removed | Your provider, and only the files the bug writer chooses to open. `--list-files` shows every file it could open; `--path` and `--exclude` narrow that. |
30
+ | Tests, untracked files, `.env`, `.git` history | Nowhere. The view is built from a clean copy of committed files only, and links are never followed. |
31
+ | Your API key | The provider's client only. Tests and bugs run with it removed from their environment. |
32
+ | Anything, to Trenyx | Nothing. The code has no network calls of its own; the only package it uses is the provider's SDK. |
33
+
34
+ The bug writer is a small loop of our own over the plain Claude API (`src/loop.ts`), with three tools (`src/tools.ts`): list,
35
+ read and search, inside the view and nothing else. There is no write, shell, web or MCP tool to ask for. A check runs on every
36
+ call, and a file that isn't on the view's list reads exactly like one that doesn't exist. The only credential read is the chosen
37
+ provider's: the key is passed in code, and anything else an SDK would pick up by itself (an auth token, a subscription token, a
38
+ saved profile, custom headers, a log setting) is removed from the process first. A run makes the model call and nothing else, and
39
+ saves no session. If `ANTHROPIC_BASE_URL` is set, the screen names that host instead.
40
+
41
+ Behind a proxy, set `NODE_USE_ENV_PROXY=1` as well as `HTTPS_PROXY` (Node 22.21 or later): Node's own HTTP client ignores
42
+ `HTTPS_PROXY` without it.
43
+
44
+ **The tests run on your machine like any test run**, with the bugs in them. An AI wrote those bugs, so read them if your
45
+ tests can do real damage: `--bugs-file` runs a list you have checked. A bug that adds a process, a network call or a read
46
+ of credentials is dropped before it runs, but that filter is a check, not a sandbox.
47
+
48
+ ## What it does to your repository
49
+
50
+ Nothing. Each run happens in a `git clone --shared` in the system temp folder, with its remote removed, so a test that runs
51
+ git cannot reach your branches or stash, your hooks do not run, and nothing is written into your `.git`. `node_modules` and
52
+ anything named by `--copy` are copied once into that folder, and every run gets its own copy of them, so each bug starts
53
+ from the same state. The temp folder is removed at the end, on Ctrl-C, on SIGTERM and on a crash. A `kill -9` leaves only
54
+ that folder behind.
55
+
56
+ ## Where the bugs go
57
+
58
+ A score only means something if the bugs land where bugs land. Left alone, a writer picks small self-contained files, which
59
+ is where a good suite is strongest, so the spread is a rule the run enforces, not a request:
60
+
61
+ - **The plan comes first.** Files in the project's language are grouped by folder, and any folder with more than an eighth of
62
+ the code is split into its subfolders. Each folder gets bugs in proportion to its code (one file counts for 1,500 lines at most).
63
+ - **Limits.** At most 2 bugs in a file, 30% of the bugs in a folder (more only where a folder holds more of the code, as in a
64
+ flat package), and 25% of the bugs in files smaller than the project's median file. A project with few files loosens the file
65
+ limit, because the bugs have nowhere else to go.
66
+ - **Kept out by name:** dot folders, generated code, type and config files, and support folders such as `scripts/`, `examples/`
67
+ and `benchmarks/` above the source root.
68
+ - **Enforced.** A bug that breaks a limit is dropped and the report says why. A folder left short gets one narrow second pass,
69
+ and if that fails too, the run says plainly which folders are short.
70
+ - **Blind.** The plan sees the view, the language and the bug count, nothing else: never a test, a test file, or which code is
71
+ tested. Tests are gone from the sizes too.
72
+
73
+ The run output and the report show where the bugs went; the report adds what the tests did in each folder. A saved list
74
+ (`--bugs-file`) runs as written, and the limits are shown as not applied.
75
+
76
+ If your test command covers only part of the repository, use `--path` for that part: a bug in code your command never runs
77
+ will always read as got through. The run says so where it can tell, and prints the flag to use:
78
+
79
+ - a test command that names a folder gets `--path` for it;
80
+ - Go folders with their own `go.mod`, which a root `go test ./...` never reaches, get `--exclude`;
81
+ - when the clean runs fail on something the output names and a clean copy lacks, it prints `--copy` for that;
82
+ - when the root runs no tests but parts of the repository have their own project file, it prints the command for each part.
83
+
84
+ These read names and the test output only, never reach the bug writer, and change nothing by themselves. There is no coverage
85
+ check, so a folder your tests miss for any other reason is not flagged: it reads as bugs that got through.
86
+
87
+ ## Which kinds of bug
88
+
89
+ The kinds bundled here are a small subset of the Trenyx bug catalogue: 63 kinds out of about 1,000, each with its name and a
90
+ one-line how-to, and no miss rates. The full catalogue grows with every independent Trenyx run and stays with the hosted service.
91
+
92
+ Each run gives the writer a random two-thirds of the bundled kinds for your language, so a suite can't be tuned to a fixed list.
93
+ The run prints its seed, and `--seed` draws the same kinds again. It does not repeat the bugs, because the AI writes those fresh
94
+ each time: to run the same bugs again, use `--bugs-file`.
95
+
96
+ ## What it costs
97
+
98
+ 16 bugs is the default and the most: US$0.64 to US$0.99 of AI cost on the two real projects measured so far. `--max-cost` (default US$5) covers the first list, its one retry and the second pass
99
+ together. Cost comes from the token counts the API returns, at Anthropic's list prices; on Bedrock and Vertex that is an
100
+ estimate, because they bill separately. Each reply is held to what the money left can buy, the run stops at 90% of your limit to
101
+ leave room for a last turn, and the second pass may use at most a third of it. A run that hits the limit before a bug list comes
102
+ back runs nothing and says what it spent.
103
+
104
+ ## Bedrock and Vertex
105
+
106
+ Set `CLAUDE_CODE_USE_BEDROCK=1` with your AWS setup and `AWS_REGION`, or `CLAUDE_CODE_USE_VERTEX=1` with your Google Cloud setup,
107
+ `CLOUD_ML_REGION` and `ANTHROPIC_VERTEX_PROJECT_ID`. Their clients are large, so they stay out of the normal install:
108
+
109
+ ```sh
110
+ npx --package=trenyx --package=@anthropic-ai/bedrock-sdk trenyx run # or @anthropic-ai/vertex-sdk
111
+ ```
112
+
113
+ ## How bugs are scored
114
+
115
+ The same rules as the Trenyx engine, where they apply. Tests that fail on either clean run never count as a catch; tests that
116
+ fail on only one are flaky and left out. Caught means a new failing test, and each catch is re-run once and must fail one of
117
+ the same tests again. A hang counts as caught only on new failing tests that reproduce, otherwise it is left out. A broken
118
+ build, and a run that only crashes, are left out too. The score is caught over counted. When bugs are left out, the score shows
119
+ how far they could move it, for example "11 of 12 counted; 11 to 15 of 16 if those four count."
120
+ A test that fails both clean runs gets two more before the run stops, so one unstable test doesn't end the check: a test that
121
+ fails some clean runs but not all is left out. Only a test failing all four stops the run.
122
+
123
+ Two passing clean runs can't rule out a test that fails now and then, and such a test reads as a catch for any bug. So when
124
+ anything was caught, the suite runs clean three more times. A catch resting only on tests that went both ways on identical
125
+ code, in those runs or across a bug's own two runs, is not counted.
126
+
127
+ A second line says how far the score could move on another draw of bugs, an 80% Wilson interval on caught over counted, for
128
+ example "Likely between 4 and 8 of 15 if different bugs were drawn." The two ranges measure different things.
129
+
130
+ ## Try it from this folder
131
+
132
+ ```sh
133
+ npm ci && npx tsc -p . && npm pack # needs Node 20.3 or later (22 for the tests)
134
+ cd your-repo && npx --package=/path/to/trenyx-0.0.1.tgz trenyx run
135
+ ```
136
+
137
+ ## Tests
138
+
139
+ ```sh
140
+ npm test # needs go, cargo, python3 and Node 22; a missing toolchain is skipped by name
141
+ ```
142
+
143
+ Unit tests use a fake API client, the SDK tests run the real client against a fake provider on localhost, and a Trenyx-side tool replays an engine run's bug list through the spread rule (placement only,
144
+ never scores). End-to-end tests run a tiny repo in each language with canned bugs and hash every byte of it,
145
+ `.git` included, before and after, also after SIGINT and SIGTERM. On macOS a run also passes with every network call denied by
146
+ the OS. With pytest on the PATH the Python tests use pytest, otherwise unittest.
147
+
148
+ ## What ships, and how it was chosen
149
+
150
+ `src/rules.gen.ts` is generated from the engine's blind view; `src/blind.ts` ports the logic, and the port is measured against
151
+ the engine on real checkouts. `catalogue/slice.json` is the bundled catalogue
152
+ (built by Trenyx's own tools, which aren't in this repository): for each language, the classes marked for every domain, ranked by how many repositories they were
153
+ planted in, never by whether they were caught, at most 36 per language, name and one-line how-to only. Bug writing sits behind `BugWriter` (`src/writer.ts`) and the catalogue behind `CatalogueSource`
154
+ (`src/catalogue.ts`), so neither the run nor the report depends on where they come from.
155
+
156
+ ## Licence
157
+
158
+ The code is Apache-2.0 (`LICENSE`); the bug catalogue in `catalogue/` has its own terms (`catalogue/LICENSE`): use it through this
159
+ package on your own code, including at work, but don't copy it out.
@@ -0,0 +1,7 @@
1
+ The files in this folder are not covered by the Apache License.
2
+
3
+ Copyright 2026 Saurabh Bhatt.
4
+
5
+ You may use these files as part of this package to run Trenyx on your own code, including at work and for commercial projects. You may not copy them out of this package, redistribute them, or use them to build or train another product or model. All other rights reserved.
6
+
7
+ These files are provided as is, without warranty of any kind.