pi-harness-runtime 1.1.474 → 1.1.475
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/package.json +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/contracts/package.json +1 -1
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/dist/question-risk.d.ts.map +1 -1
- package/packages/jev-judge/dist/question-risk.js +99 -19
- package/packages/jev-judge/dist/question-risk.js.map +1 -1
- package/packages/jev-judge/package.json +1 -1
- package/packages/jev-judge/src/question-risk.ts +108 -17
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/logging/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/relay/package.json +1 -1
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/tooling-preference/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/two-phase-review/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/package.json +1 -1
- package/packages/write-review/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,59 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.1.475](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v1.1.448...v1.1.475) (2026-11-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **delegation:** a child is only a child when it really ran ([ac4e678](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ac4e6782d7d4bc4941e458425c8a9f38a51fc9d4))
|
|
11
|
+
* **delegation:** the scope of a request is measured before it is judged ([684b6a5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/684b6a55184f63d3be24c48dcecfb0b13410dc15))
|
|
12
|
+
* **honcho:** the memory service speaks the native MCP of Pi ([f9f740c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f9f740c12869bae4c4380afbe8c76e12388bb744))
|
|
13
|
+
* **jev:** one decision per question, bound to the question it was evaluated for ([03448aa](https://github.com/ManotLuijiu/pi-harness-runtime/commit/03448aaa17f2d0c3bcf644b0b1d5949727dfff8c))
|
|
14
|
+
* **jev:** the evaluation of a choice sees what the options mean ([f0c207e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/f0c207e074701e6b7dab0965170ec39453d9d502))
|
|
15
|
+
* **jev:** the pending question carries the ask and the answer ([a792133](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a792133e517fb8c12d3363e98942f3af30270f27))
|
|
16
|
+
* **jev:** the pending question counts down to the decision ([d0cc171](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d0cc171223986b2d32c670b6c1c74712fe0a4ad8))
|
|
17
|
+
* **keys:** the key files are repaired when their permissions are unsafe ([e9c2c26](https://github.com/ManotLuijiu/pi-harness-runtime/commit/e9c2c26b287665b56ed749de269737e8403bb8af))
|
|
18
|
+
* **mcp:** the harness connects the registered servers when nobody else does ([7fef951](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7fef95137ad4664df57f045cd91b7d233315b0bc))
|
|
19
|
+
* **merge:** a manual run can leave the merge to the pull request event ([b3d1950](https://github.com/ManotLuijiu/pi-harness-runtime/commit/b3d1950b5941c78ccd56951acdafd1d4afbe1bff))
|
|
20
|
+
* **phase:** the agent owns the todo list and the harness says so ([c489370](https://github.com/ManotLuijiu/pi-harness-runtime/commit/c489370bd7926aece8cb1a77aa20ca2d2672f1fb))
|
|
21
|
+
* **review:** the review starts on its own when the implementation is done ([04f51f5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/04f51f599cd3222b6c74dd8fadb1373bd72d9bd7))
|
|
22
|
+
* **status:** the status line names the phase, the progress and the children ([0167bf3](https://github.com/ManotLuijiu/pi-harness-runtime/commit/0167bf396a0b987c1d44f3b869351976a951dd65))
|
|
23
|
+
* **test:** the task waits for the final tier of the validation plan ([fa147db](https://github.com/ManotLuijiu/pi-harness-runtime/commit/fa147dbf7d50d56e6ea48c6d8fbb4fcb190caf8a))
|
|
24
|
+
* **validation:** a large job starts with a measured pilot ([425964b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/425964b04a3d4fa02adfabed47ff62c5ec2b9c28))
|
|
25
|
+
* **validation:** the size of a job is a fact, not a phrase ([8aa6c11](https://github.com/ManotLuijiu/pi-harness-runtime/commit/8aa6c119565d0f8412dc8aeafa6b295d47d3f093))
|
|
26
|
+
* **workspace:** a Frappe bench names the mode of the workspace ([9d58517](https://github.com/ManotLuijiu/pi-harness-runtime/commit/9d585172063a330992fee933316e268ae9985e3c))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* **ci:** every run of a required check counts, and the worst one decides ([da9e0da](https://github.com/ManotLuijiu/pi-harness-runtime/commit/da9e0da6b0ca29cb320764fd5fc1b8a8dee8b1e0))
|
|
32
|
+
* **ci:** the newest attempt of a run decides, not the attempt that failed ([9d7adcc](https://github.com/ManotLuijiu/pi-harness-runtime/commit/9d7adcc31cbacc517c3c1a9bcd3956be94c908ef))
|
|
33
|
+
* **honcho:** a probe that the end of the session cuts off is not a failure ([493fd93](https://github.com/ManotLuijiu/pi-harness-runtime/commit/493fd938ba09fdcf57bed4aaf259d81c4040909e))
|
|
34
|
+
* **honcho:** the report names the state of the MCP server, not the registration ([762f4d5](https://github.com/ManotLuijiu/pi-harness-runtime/commit/762f4d59e4eabcab9a1c21a61aa522c3267621b3))
|
|
35
|
+
* **hooks:** a tag is checked through the commit behind it ([c823e8e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/c823e8e1f6973c62b5449a97c101759a4d5cbba5))
|
|
36
|
+
* **jev:** a prohibition must not hide a destructive action ([78a6cc1](https://github.com/ManotLuijiu/pi-harness-runtime/commit/78a6cc199e647f812e145483f7e94991358d8f34))
|
|
37
|
+
* **jev:** a session switch ends the wait of the old session ([ca03d39](https://github.com/ManotLuijiu/pi-harness-runtime/commit/ca03d399c0d4a1b2dd428ac39836ab53c0e51ab6))
|
|
38
|
+
* **jev:** keep a comparative caveat with the option it constrains ([7be306b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7be306b0d0872713ebca9386d613ae5a8da9d5b6))
|
|
39
|
+
* **jev:** the alternatives of a question are parsed without a quadratic pattern ([63016a3](https://github.com/ManotLuijiu/pi-harness-runtime/commit/63016a3f0488acb801990dd46770c00d382b5858))
|
|
40
|
+
* **jev:** the facts of an option survive the wording of the agent ([5a6250c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5a6250c07aa8d965bc6ae242cccbf519477598f8))
|
|
41
|
+
* **keys:** the key directory is audited as a tree ([081cc75](https://github.com/ManotLuijiu/pi-harness-runtime/commit/081cc75ac8ceff36b0d619c3f76371dc08459d3c))
|
|
42
|
+
* **mcp:** the connector and the watcher stop with the session ([4d1b87d](https://github.com/ManotLuijiu/pi-harness-runtime/commit/4d1b87d14d015749025b62bf54d6d0b6137295f7))
|
|
43
|
+
* **mcp:** the connector survives a runtime that cannot list the servers ([d0f555f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d0f555fa14f51de33591e572a41ded5b59a3e4dd))
|
|
44
|
+
* **merge:** the boolean input is read as a boolean ([971b716](https://github.com/ManotLuijiu/pi-harness-runtime/commit/971b7169a43db382dbdeb6bb9bab02ab56e0351c))
|
|
45
|
+
* **merge:** the manual job needs the right of the merge ([7ba685e](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7ba685ec43d815f90aa35b742579e87e76c69209))
|
|
46
|
+
* **merge:** the merge of the pull request is the GraphQL mutation ([972bab4](https://github.com/ManotLuijiu/pi-harness-runtime/commit/972bab4b0f7faf1b0047f3bb767ef6db3de4b2fa))
|
|
47
|
+
* **merge:** the workflow merges the pull request the gates cleared ([d7639ec](https://github.com/ManotLuijiu/pi-harness-runtime/commit/d7639ec9b83723510acb4a5c4e23d5d6167c3af6))
|
|
48
|
+
* **release:** a manual release keeps the version of its manifest ([122e661](https://github.com/ManotLuijiu/pi-harness-runtime/commit/122e661ea48cb8aff14c71dbd0221a4cf0ba4c8e))
|
|
49
|
+
* **release:** the alignment names the reason of a failure ([5814dd0](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5814dd0b780f5839cf8011ed0cbbbb31e7eb0418))
|
|
50
|
+
* **release:** the channels of the package name the release ([a7a273f](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a7a273ffe8398e2b5b07ef1c321777de41792c6e))
|
|
51
|
+
* **release:** the release publishes and leaves the channels alone ([5871746](https://github.com/ManotLuijiu/pi-harness-runtime/commit/5871746589c1281d855dbeb591b02419fa43f22e))
|
|
52
|
+
* **release:** the release pull request names the version of its branch ([a846e83](https://github.com/ManotLuijiu/pi-harness-runtime/commit/a846e83e6de6e529f4bca05e869db0b5eebb37c5))
|
|
53
|
+
* **release:** the release scans the tree of the commit it publishes ([7d47a0b](https://github.com/ManotLuijiu/pi-harness-runtime/commit/7d47a0b5406480a1e1d3a52623a76aabd1e2d0ba))
|
|
54
|
+
* **workspace:** a strong bench signal decides, and the question is not a fact of an option ([303a828](https://github.com/ManotLuijiu/pi-harness-runtime/commit/303a828f55aa7c4e0a611231f482489b530ff5a3))
|
|
55
|
+
* **workspace:** keep a client name out of the comment about the search depth ([b572e0a](https://github.com/ManotLuijiu/pi-harness-runtime/commit/b572e0af16ff562203bda2b5c47b41807cff5a95))
|
|
56
|
+
* **workspace:** the repository names the mode before the mode stays unknown ([188a32c](https://github.com/ManotLuijiu/pi-harness-runtime/commit/188a32c7a6af1465dd24714278fccc73d06f6477))
|
|
57
|
+
|
|
5
58
|
### [1.1.474](https://github.com/ManotLuijiu/pi-harness-runtime/compare/v1.1.448...v1.1.474) (2026-11-08)
|
|
6
59
|
|
|
7
60
|
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"question-risk.d.ts","sourceRoot":"","sources":["../src/question-risk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,MAAM,gBAAgB,GACxB,SAAS,GACT,UAAU,GACV,eAAe,GACf,UAAU,GACV,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,2CAA2C;AAC3C,MAAM,WAAW,iBAAiB;IAChC,4DAA4D;IAC5D,6BAA6B,EAAE,OAAO,CAAC;IACvC,kDAAkD;IAClD,WAAW,EAAE,OAAO,CAAC;IACrB,gCAAgC;IAChC,UAAU,EAAE,OAAO,CAAC;IACpB,+CAA+C;IAC/C,QAAQ,EAAE,OAAO,CAAC;IAClB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,6DAA6D;IAC7D,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kCAAkC;IA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;;;;;;;GAiBG;AACH,wBAAgB,oBAAoB,CACnC,KAAK,EAAE,iBAAiB,GACtB,iBAAiB,CAoDnB"}
|
|
@@ -22,7 +22,7 @@ export const MAX_ACTION_CHARS = 600;
|
|
|
22
22
|
* found in the message. A sentence that names no action does not belong to
|
|
23
23
|
* the action: it talks about the request, not about what happens.
|
|
24
24
|
*/
|
|
25
|
-
const ACTION_VERBS = /\b(delete|deletes|deleting|removed
|
|
25
|
+
const ACTION_VERBS = /\b(delete|deletes|deleted|deleting|remove|removes|removed|removing|drop|drops|dropped|dropping|wipe|wipes|wiped|wiping|erase|erases|erased|erasing|purge|purges|purged|purging|truncate|truncates|truncated|truncating|destroy|destroys|destroyed|destroying|revoke|revokes|revoked|revoking|rotate|rotates|rotated|rotating|reset|resets|resetting|rebuild|rebuilds|reinstall|reinstalls|uninstall|uninstalls|deploy|deploys|deploying|publish|publishes|publishing|release|releases|releasing|ship|ships|shipping|push|pushes|pushing|merge|merges|merging|rebase|rebases|force[- ]?push|squash|squashes|send|sends|sending|post|posts|posting|mail|mails|email|emails|notify|notifies|upload|uploads|uploading|transfer|transfers|wire|wires|pay|pays|paying|invoice|invoices|refund|refunds|migrate|migrates|migrating|upgrade|upgrades|downgrade|downgrades|install|installs|installing|overwrite|overwrites|overwritten|overwriting|replace|replaces|replacing|rename|renames|renaming|move|moves|moving|copy|copies|copying|run|runs|running|execute|executes|restart|restarts|stop|stops|stopped|stopping|kill|kills|killed|killing|close|closes|closing|grant|grants|granting|enable|enables|enabling|disable|disables|disabling|update|updates|updating|modify|modifies|modifying|write|writes|writing|patch|patches|patching|commit|commits|committing|revert|reverts|reverted|reverting|refactor|refactors|rewrite|rewrites|format|formats|lint|lints|generate|generates|create|creates|add|adds|implement|implements|build|builds|compile|compiles|seed|seeds|backfill|backfills|sync|syncs|fetch|fetches|query|queries|benchmark|benchmarks|profile|profiles|cleanup|cleanups|clean|cleans|prune|prunes)\b/i;
|
|
26
26
|
/**
|
|
27
27
|
* The action the agent proposes.
|
|
28
28
|
*
|
|
@@ -51,16 +51,47 @@ export function extractProposedAction(contextText, questionText) {
|
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* Words that name an action that destroys, drops or overwrites something.
|
|
54
|
+
*
|
|
55
|
+
* The destructive verbs and their inflected forms.
|
|
56
|
+
*
|
|
57
|
+
* A risk pattern that only knows the bare singular of its verb misses the
|
|
58
|
+
* action in every other form: "the production database will be removed"
|
|
59
|
+
* destroys exactly as much as "remove the production database". The forms
|
|
60
|
+
* are the ones the action verbs of this file name (see ACTION_VERBS).
|
|
54
61
|
*/
|
|
55
62
|
const DESTRUCTIVE_PATTERNS = [
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
{
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
{
|
|
64
|
+
name: "delete",
|
|
65
|
+
pattern: /\b(delete|deletes|deleted|deleting|remove|removes|removed|removing|drop|drops|dropped|dropping|truncate|truncates|truncated|truncating|wipe|wipes|wiped|wiping|purge|purges|purged|purging|destroy|destroys|destroyed|destroying|erase|erases|erased|erasing)\b/,
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "reset",
|
|
69
|
+
pattern: /\b(reset|resets|resetting|rollback|rollbacks|rolled\s+back|revert|reverts|reverted|reverting)\b/,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "revoke",
|
|
73
|
+
pattern: /\b(revoke|revokes|revoked|revoking|rotate|rotates|rotated|rotating|invalidate|invalidates|invalidated|invalidating)\b/,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
name: "force-push",
|
|
77
|
+
pattern: /\b(force[\s-]?push(es|ed|ing)?|push(es|ed|ing)?\s+(--force|-f\b)|reset\s+--hard|clean\s+-\w*f)\b/,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "drop-object",
|
|
81
|
+
pattern: /\b(drop|drops|dropped|dropping)\s+(the\s+)?(table|database|schema|collection|index|bucket)\b/,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "delete-object",
|
|
85
|
+
pattern: /\b(delete|deletes|deleted|deleting|remove|removes|removed|removing)\s+(the\s+)?(database|table|file|folder|branch|tag|user|account|volume|key)\b/,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "terminate",
|
|
89
|
+
pattern: /\b(terminate|terminates|terminated|terminating|kill|kills|killed|killing|shutdown|shut\s+down|stop|stops|stopped|stopping)\b/,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
name: "overwrite",
|
|
93
|
+
pattern: /\b(overwrite|overwrites|overwritten|overwriting)\b/,
|
|
94
|
+
},
|
|
64
95
|
];
|
|
65
96
|
/**
|
|
66
97
|
* Words that name an action that reaches the outside world.
|
|
@@ -84,37 +115,86 @@ const SENSITIVE_PATTERNS = [
|
|
|
84
115
|
* "do not delete anything" is a prohibition, not a proposal: the risk of a
|
|
85
116
|
* message must not turn the words of a prohibition into a destructive
|
|
86
117
|
* action that blocks the work for good.
|
|
118
|
+
*
|
|
119
|
+
* The list carries the forms that really occur: the plain "not" of "will
|
|
120
|
+
* not delete" belongs to it, and so do the contractions. "not" alone is
|
|
121
|
+
* only a negation when it governs the action - see isNegated().
|
|
122
|
+
*/
|
|
123
|
+
const NEGATION_WORDS = /\b(do not|don'?t|never|without|avoid|refrain from|no need to|must not|shall not|cannot|can'?t|won'?t|shouldn'?t|mustn'?t|not)\b/;
|
|
124
|
+
/**
|
|
125
|
+
* The words that stand between a negation and the action it governs.
|
|
126
|
+
*
|
|
127
|
+
* A negation that is separated from the action by a comma, a conjunction
|
|
128
|
+
* or a colon belongs to another part of the sentence: "this is not a test,
|
|
129
|
+
* delete the production database" proposes the deletion, "do not approve
|
|
130
|
+
* the request, then delete the branch" proposes the deletion too.
|
|
131
|
+
*
|
|
132
|
+
* "or" is not one of them: "do not remove or delete the branch" prohibits
|
|
133
|
+
* both actions, and the negation governs the second one as well.
|
|
134
|
+
*/
|
|
135
|
+
const NEGATION_BREAK = /[;:,]|\band\b|\bthen\b/;
|
|
136
|
+
/**
|
|
137
|
+
* How many words may stand between a negation and the action.
|
|
138
|
+
*
|
|
139
|
+
* A negation governs the words that follow it closely: "will not delete",
|
|
140
|
+
* "cannot deploy", "never remove". A negation that is further away
|
|
141
|
+
* belongs to something else ("the plan is not ready so we should delete
|
|
142
|
+
* the branch").
|
|
87
143
|
*/
|
|
88
|
-
const
|
|
144
|
+
const NEGATION_DISTANCE_WORDS = 3;
|
|
89
145
|
/**
|
|
90
146
|
* Is the action at this position prohibited?
|
|
91
147
|
*
|
|
92
148
|
* The negation has to stand in front of the action, in the same clause: a
|
|
93
149
|
* negation that belongs to another clause ("delete the branch, do not touch
|
|
94
150
|
* main") does not prohibit the deletion.
|
|
151
|
+
*
|
|
152
|
+
* The last negation of the clause is the one that counts, and it has to
|
|
153
|
+
* govern the action: nothing may stand between them that would make the
|
|
154
|
+
* negation belong to another part of the sentence.
|
|
95
155
|
*/
|
|
96
156
|
function isNegated(text, index) {
|
|
97
|
-
const before = text.slice(
|
|
157
|
+
const before = text.slice(0, index);
|
|
98
158
|
// The clause of the action starts after the last sentence break.
|
|
99
159
|
const clause = before.split(/[.;!?\n]/).pop() ?? before;
|
|
100
|
-
|
|
160
|
+
const matches = [...clause.matchAll(new RegExp(NEGATION_WORDS.source, "gi"))];
|
|
161
|
+
const last = matches[matches.length - 1];
|
|
162
|
+
if (!last)
|
|
163
|
+
return false;
|
|
164
|
+
const between = clause.slice(last.index + last[0].length);
|
|
165
|
+
if (NEGATION_BREAK.test(between))
|
|
166
|
+
return false;
|
|
167
|
+
// The negation governs the action only when it stands close to it.
|
|
168
|
+
const words = between.trim().length === 0 ? 0 : between.trim().split(/\s+/).length;
|
|
169
|
+
return words <= NEGATION_DISTANCE_WORDS;
|
|
101
170
|
}
|
|
102
171
|
/**
|
|
103
172
|
* Match the patterns of one kind of risk in a text.
|
|
104
173
|
*
|
|
105
174
|
* A pattern that is prohibited does not count: the words of a prohibition
|
|
106
175
|
* are not a proposal.
|
|
176
|
+
*
|
|
177
|
+
* Every occurrence of a pattern is examined: a prohibited occurrence does
|
|
178
|
+
* not hide a later one that is proposed ("do not delete the branch, instead
|
|
179
|
+
* delete the production database"). The pattern counts when at least one
|
|
180
|
+
* of its occurrences is not prohibited.
|
|
107
181
|
*/
|
|
108
182
|
function matchPatterns(text, patterns, signals) {
|
|
109
183
|
let matched = false;
|
|
110
184
|
for (const { name, pattern } of patterns) {
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
185
|
+
const global = new RegExp(pattern.source, pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`);
|
|
186
|
+
let match;
|
|
187
|
+
while ((match = global.exec(text)) !== null) {
|
|
188
|
+
if (match[0].length === 0) {
|
|
189
|
+
global.lastIndex += 1;
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if (isNegated(text, match.index))
|
|
193
|
+
continue;
|
|
194
|
+
signals.push(name);
|
|
195
|
+
matched = true;
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
118
198
|
}
|
|
119
199
|
return matched;
|
|
120
200
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"question-risk.js","sourceRoot":"","sources":["../src/question-risk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAoDH;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,YAAY,GAChB,
|
|
1
|
+
{"version":3,"file":"question-risk.js","sourceRoot":"","sources":["../src/question-risk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAoDH;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,YAAY,GAChB,2nDAA2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BAAwB,CAAC,CAAC;IACxC,CAAC;IAED,0DAA0D;IAC1D,IAAI,WAAW,EAAE,CAAC;QACjB,6BAA6B,GAAG,IAAI,CAAC;IACtC,CAAC;IAED,uEAAuE;IACvE,iBAAiB;IACjB,IAAI,QAAQ,IAAI,SAAS,EAAE,CAAC;QAC3B,6BAA6B,GAAG,IAAI,CAAC;IACtC,CAAC;IAED,6DAA6D;IAC7D,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;QAC3B,6BAA6B,GAAG,IAAI,CAAC;QACrC,OAAO,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAClC,CAAC;IAED,OAAO;QACN,6BAA6B;QAC7B,WAAW;QACX,mDAAmD;QACnD,UAAU,EAAE,CAAC,WAAW;QACxB,QAAQ;QACR,OAAO;KACP,CAAC;AACH,CAAC"}
|
|
@@ -75,7 +75,7 @@ export const MAX_ACTION_CHARS = 600;
|
|
|
75
75
|
* the action: it talks about the request, not about what happens.
|
|
76
76
|
*/
|
|
77
77
|
const ACTION_VERBS =
|
|
78
|
-
/\b(delete|deletes|deleting|removed
|
|
78
|
+
/\b(delete|deletes|deleted|deleting|remove|removes|removed|removing|drop|drops|dropped|dropping|wipe|wipes|wiped|wiping|erase|erases|erased|erasing|purge|purges|purged|purging|truncate|truncates|truncated|truncating|destroy|destroys|destroyed|destroying|revoke|revokes|revoked|revoking|rotate|rotates|rotated|rotating|reset|resets|resetting|rebuild|rebuilds|reinstall|reinstalls|uninstall|uninstalls|deploy|deploys|deploying|publish|publishes|publishing|release|releases|releasing|ship|ships|shipping|push|pushes|pushing|merge|merges|merging|rebase|rebases|force[- ]?push|squash|squashes|send|sends|sending|post|posts|posting|mail|mails|email|emails|notify|notifies|upload|uploads|uploading|transfer|transfers|wire|wires|pay|pays|paying|invoice|invoices|refund|refunds|migrate|migrates|migrating|upgrade|upgrades|downgrade|downgrades|install|installs|installing|overwrite|overwrites|overwritten|overwriting|replace|replaces|replacing|rename|renames|renaming|move|moves|moving|copy|copies|copying|run|runs|running|execute|executes|restart|restarts|stop|stops|stopped|stopping|kill|kills|killed|killing|close|closes|closing|grant|grants|granting|enable|enables|enabling|disable|disables|disabling|update|updates|updating|modify|modifies|modifying|write|writes|writing|patch|patches|patching|commit|commits|committing|revert|reverts|reverted|reverting|refactor|refactors|rewrite|rewrites|format|formats|lint|lints|generate|generates|create|creates|add|adds|implement|implements|build|builds|compile|compiles|seed|seeds|backfill|backfills|sync|syncs|fetch|fetches|query|queries|benchmark|benchmarks|profile|profiles|cleanup|cleanups|clean|cleans|prune|prunes)\b/i;
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
81
|
* The action the agent proposes.
|
|
@@ -111,16 +111,54 @@ export function extractProposedAction(
|
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
113
|
* Words that name an action that destroys, drops or overwrites something.
|
|
114
|
+
*
|
|
115
|
+
* The destructive verbs and their inflected forms.
|
|
116
|
+
*
|
|
117
|
+
* A risk pattern that only knows the bare singular of its verb misses the
|
|
118
|
+
* action in every other form: "the production database will be removed"
|
|
119
|
+
* destroys exactly as much as "remove the production database". The forms
|
|
120
|
+
* are the ones the action verbs of this file name (see ACTION_VERBS).
|
|
114
121
|
*/
|
|
115
122
|
const DESTRUCTIVE_PATTERNS: RiskPattern[] = [
|
|
116
|
-
{
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
{
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
{
|
|
124
|
+
name: "delete",
|
|
125
|
+
pattern:
|
|
126
|
+
/\b(delete|deletes|deleted|deleting|remove|removes|removed|removing|drop|drops|dropped|dropping|truncate|truncates|truncated|truncating|wipe|wipes|wiped|wiping|purge|purges|purged|purging|destroy|destroys|destroyed|destroying|erase|erases|erased|erasing)\b/,
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "reset",
|
|
130
|
+
pattern:
|
|
131
|
+
/\b(reset|resets|resetting|rollback|rollbacks|rolled\s+back|revert|reverts|reverted|reverting)\b/,
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "revoke",
|
|
135
|
+
pattern:
|
|
136
|
+
/\b(revoke|revokes|revoked|revoking|rotate|rotates|rotated|rotating|invalidate|invalidates|invalidated|invalidating)\b/,
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "force-push",
|
|
140
|
+
pattern:
|
|
141
|
+
/\b(force[\s-]?push(es|ed|ing)?|push(es|ed|ing)?\s+(--force|-f\b)|reset\s+--hard|clean\s+-\w*f)\b/,
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "drop-object",
|
|
145
|
+
pattern:
|
|
146
|
+
/\b(drop|drops|dropped|dropping)\s+(the\s+)?(table|database|schema|collection|index|bucket)\b/,
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: "delete-object",
|
|
150
|
+
pattern:
|
|
151
|
+
/\b(delete|deletes|deleted|deleting|remove|removes|removed|removing)\s+(the\s+)?(database|table|file|folder|branch|tag|user|account|volume|key)\b/,
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: "terminate",
|
|
155
|
+
pattern:
|
|
156
|
+
/\b(terminate|terminates|terminated|terminating|kill|kills|killed|killing|shutdown|shut\s+down|stop|stops|stopped|stopping)\b/,
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: "overwrite",
|
|
160
|
+
pattern: /\b(overwrite|overwrites|overwritten|overwriting)\b/,
|
|
161
|
+
},
|
|
124
162
|
];
|
|
125
163
|
|
|
126
164
|
/**
|
|
@@ -147,9 +185,36 @@ const SENSITIVE_PATTERNS: RiskPattern[] = [
|
|
|
147
185
|
* "do not delete anything" is a prohibition, not a proposal: the risk of a
|
|
148
186
|
* message must not turn the words of a prohibition into a destructive
|
|
149
187
|
* action that blocks the work for good.
|
|
188
|
+
*
|
|
189
|
+
* The list carries the forms that really occur: the plain "not" of "will
|
|
190
|
+
* not delete" belongs to it, and so do the contractions. "not" alone is
|
|
191
|
+
* only a negation when it governs the action - see isNegated().
|
|
150
192
|
*/
|
|
151
193
|
const NEGATION_WORDS =
|
|
152
|
-
/\b(do not|don'?t|never|without|avoid|refrain from|no need to)\b/;
|
|
194
|
+
/\b(do not|don'?t|never|without|avoid|refrain from|no need to|must not|shall not|cannot|can'?t|won'?t|shouldn'?t|mustn'?t|not)\b/;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* The words that stand between a negation and the action it governs.
|
|
198
|
+
*
|
|
199
|
+
* A negation that is separated from the action by a comma, a conjunction
|
|
200
|
+
* or a colon belongs to another part of the sentence: "this is not a test,
|
|
201
|
+
* delete the production database" proposes the deletion, "do not approve
|
|
202
|
+
* the request, then delete the branch" proposes the deletion too.
|
|
203
|
+
*
|
|
204
|
+
* "or" is not one of them: "do not remove or delete the branch" prohibits
|
|
205
|
+
* both actions, and the negation governs the second one as well.
|
|
206
|
+
*/
|
|
207
|
+
const NEGATION_BREAK = /[;:,]|\band\b|\bthen\b/;
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* How many words may stand between a negation and the action.
|
|
211
|
+
*
|
|
212
|
+
* A negation governs the words that follow it closely: "will not delete",
|
|
213
|
+
* "cannot deploy", "never remove". A negation that is further away
|
|
214
|
+
* belongs to something else ("the plan is not ready so we should delete
|
|
215
|
+
* the branch").
|
|
216
|
+
*/
|
|
217
|
+
const NEGATION_DISTANCE_WORDS = 3;
|
|
153
218
|
|
|
154
219
|
/**
|
|
155
220
|
* Is the action at this position prohibited?
|
|
@@ -157,12 +222,23 @@ const NEGATION_WORDS =
|
|
|
157
222
|
* The negation has to stand in front of the action, in the same clause: a
|
|
158
223
|
* negation that belongs to another clause ("delete the branch, do not touch
|
|
159
224
|
* main") does not prohibit the deletion.
|
|
225
|
+
*
|
|
226
|
+
* The last negation of the clause is the one that counts, and it has to
|
|
227
|
+
* govern the action: nothing may stand between them that would make the
|
|
228
|
+
* negation belong to another part of the sentence.
|
|
160
229
|
*/
|
|
161
230
|
function isNegated(text: string, index: number): boolean {
|
|
162
|
-
const before = text.slice(
|
|
231
|
+
const before = text.slice(0, index);
|
|
163
232
|
// The clause of the action starts after the last sentence break.
|
|
164
233
|
const clause = before.split(/[.;!?\n]/).pop() ?? before;
|
|
165
|
-
|
|
234
|
+
const matches = [...clause.matchAll(new RegExp(NEGATION_WORDS.source, "gi"))];
|
|
235
|
+
const last = matches[matches.length - 1];
|
|
236
|
+
if (!last) return false;
|
|
237
|
+
const between = clause.slice(last.index + last[0].length);
|
|
238
|
+
if (NEGATION_BREAK.test(between)) return false;
|
|
239
|
+
// The negation governs the action only when it stands close to it.
|
|
240
|
+
const words = between.trim().length === 0 ? 0 : between.trim().split(/\s+/).length;
|
|
241
|
+
return words <= NEGATION_DISTANCE_WORDS;
|
|
166
242
|
}
|
|
167
243
|
|
|
168
244
|
/**
|
|
@@ -170,6 +246,11 @@ function isNegated(text: string, index: number): boolean {
|
|
|
170
246
|
*
|
|
171
247
|
* A pattern that is prohibited does not count: the words of a prohibition
|
|
172
248
|
* are not a proposal.
|
|
249
|
+
*
|
|
250
|
+
* Every occurrence of a pattern is examined: a prohibited occurrence does
|
|
251
|
+
* not hide a later one that is proposed ("do not delete the branch, instead
|
|
252
|
+
* delete the production database"). The pattern counts when at least one
|
|
253
|
+
* of its occurrences is not prohibited.
|
|
173
254
|
*/
|
|
174
255
|
function matchPatterns(
|
|
175
256
|
text: string,
|
|
@@ -178,11 +259,21 @@ function matchPatterns(
|
|
|
178
259
|
): boolean {
|
|
179
260
|
let matched = false;
|
|
180
261
|
for (const { name, pattern } of patterns) {
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
262
|
+
const global = new RegExp(
|
|
263
|
+
pattern.source,
|
|
264
|
+
pattern.flags.includes("g") ? pattern.flags : `${pattern.flags}g`,
|
|
265
|
+
);
|
|
266
|
+
let match: RegExpExecArray | null;
|
|
267
|
+
while ((match = global.exec(text)) !== null) {
|
|
268
|
+
if (match[0].length === 0) {
|
|
269
|
+
global.lastIndex += 1;
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
if (isNegated(text, match.index)) continue;
|
|
273
|
+
signals.push(name);
|
|
274
|
+
matched = true;
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
186
277
|
}
|
|
187
278
|
return matched;
|
|
188
279
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-harness/two-phase-review",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.475",
|
|
4
4
|
"description": "pi-harness-runtime — two-phase implementation and review workflow (queue review signals, gate the phase, scope the diff)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|