eklavya 1.49.0 → 1.49.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/dist/memory/capture.js
CHANGED
|
@@ -46,12 +46,24 @@ export function prepare(config, identity, event) {
|
|
|
46
46
|
return null;
|
|
47
47
|
if (isOwnTraffic(event.tool, event.body))
|
|
48
48
|
return null;
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
const named = event.files ?? [];
|
|
50
|
+
const files = named.filter((f) => !pathExcluded(f, policy));
|
|
51
|
+
if (files.length < named.length) {
|
|
52
|
+
// A file event whose only file was excluded is the excluded file. Keeping
|
|
53
|
+
// the event for its body would re-admit through the back door what the path
|
|
54
|
+
// rule just shut out. A read or edit naming an allowed file too keeps that
|
|
55
|
+
// file: its body is the arguments, not the excluded file's contents.
|
|
56
|
+
if (event.kind === 'file_edit' || event.kind === 'file_read') {
|
|
57
|
+
if (files.length === 0)
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
// Any other event naming an excluded file is dropped whole, allowed files
|
|
62
|
+
// or not. A failed Read is a `tool_error`, and an error or a result
|
|
63
|
+
// excerpt quotes whichever file it came from — the body cannot be split
|
|
64
|
+
// by file, so no part of it can be kept safely.
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
55
67
|
}
|
|
56
68
|
// Redact, then cut — never the other way round. Cut first, the cap can land
|
|
57
69
|
// inside a secret and leave a head too short for any pattern to recognise
|
|
@@ -113,6 +125,17 @@ export function captureOrSpool(db, config, identity, event) {
|
|
|
113
125
|
}
|
|
114
126
|
return spoolEvent(input);
|
|
115
127
|
}
|
|
128
|
+
/** Tools that name their file in a required argument. */
|
|
129
|
+
const FILE_FAILURE_TOOLS = new Set(['Read', 'NotebookRead', 'Edit', 'Write', 'MultiEdit', 'NotebookEdit']);
|
|
130
|
+
/**
|
|
131
|
+
* A failure of a file tool left with no file: before exclusions covered
|
|
132
|
+
* failures, that was a failed read or edit of an excluded file whose error text
|
|
133
|
+
* was kept. `prepare` no longer produces one; a spool line written before the
|
|
134
|
+
* upgrade still can. Migration 024 removes the same shape from the database.
|
|
135
|
+
*/
|
|
136
|
+
function excludedFileFailure(input) {
|
|
137
|
+
return input.kind === 'tool_error' && FILE_FAILURE_TOOLS.has(input.tool ?? '') && !input.files?.length;
|
|
138
|
+
}
|
|
116
139
|
/** Replays whatever the spool holds. Idempotent through `event_uid`. */
|
|
117
140
|
export function drainSpool(db) {
|
|
118
141
|
const { records, commit } = takeSpooled();
|
|
@@ -123,7 +146,7 @@ export function drainSpool(db) {
|
|
|
123
146
|
// A spool line is data this process wrote earlier, but a truncated write or
|
|
124
147
|
// a hand-edited file is still possible; anything without an identity cannot
|
|
125
148
|
// be replayed idempotently and is discarded rather than guessed at.
|
|
126
|
-
if (!input || typeof input !== 'object' || !input.eventUid || !input.project) {
|
|
149
|
+
if (!input || typeof input !== 'object' || !input.eventUid || !input.project || excludedFileFailure(input)) {
|
|
127
150
|
skipped++;
|
|
128
151
|
continue;
|
|
129
152
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capture.js","sourceRoot":"","sources":["../../src/memory/capture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,iBAAiB,EAAyB,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAsB,MAAM,cAAc,CAAC;AACjI,OAAO,EAAE,WAAW,EAAsB,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAiCrD,iFAAiF;AACjF,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB;;;;;;GAMG;AACH,MAAM,aAAa,GA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, captured before the fix.
|
|
2
|
+
--
|
|
3
|
+
-- A failed Read, Edit or Write is `tool_error` evidence, and capture used to
|
|
4
|
+
-- apply the path exclusions only to `file_read` and `file_edit`. The excluded
|
|
5
|
+
-- path was stripped from `files`, but the error text -- which can quote the
|
|
6
|
+
-- file, a `.env` for example -- was kept. Capture now drops those events.
|
|
7
|
+
--
|
|
8
|
+
-- They are identifiable: each of these tools names its file in a required
|
|
9
|
+
-- argument, so a failure of one that is left with no file is a failure whose
|
|
10
|
+
-- only file was excluded. A rare failure the host sent without its arguments
|
|
11
|
+
-- matches too; it named no file, so nothing useful goes with it.
|
|
12
|
+
--
|
|
13
|
+
-- The links are cleared the way retention pruning clears them (`pruneEvidence`
|
|
14
|
+
-- in `src/memory/worker.ts`), so a connection without foreign keys cannot leave
|
|
15
|
+
-- rows pointing at nothing. A learning candidate outlives its event. Entries
|
|
16
|
+
-- already summarised from these events are left as they are.
|
|
17
|
+
-- Keep the tool list in step with `FILE_FAILURE_TOOLS` in
|
|
18
|
+
-- `src/memory/capture.ts`, which guards spool records written before this ran.
|
|
19
|
+
CREATE TEMP TABLE purge_excluded_failures AS
|
|
20
|
+
SELECT id FROM evidence_events
|
|
21
|
+
WHERE kind = 'tool_error'
|
|
22
|
+
AND tool IN ('Read', 'NotebookRead', 'Edit', 'Write', 'MultiEdit', 'NotebookEdit')
|
|
23
|
+
AND (files IS NULL OR files = '[]');
|
|
24
|
+
|
|
25
|
+
UPDATE learning_sources SET event_id = NULL WHERE event_id IN (SELECT id FROM purge_excluded_failures);
|
|
26
|
+
DELETE FROM memory_entry_events WHERE event_id IN (SELECT id FROM purge_excluded_failures);
|
|
27
|
+
DELETE FROM evidence_events WHERE id IN (SELECT id FROM purge_excluded_failures);
|
|
28
|
+
|
|
29
|
+
DROP TABLE purge_excluded_failures;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eklavya",
|
|
3
3
|
"displayName": "Eklavya",
|
|
4
|
-
"version": "1.49.
|
|
4
|
+
"version": "1.49.1",
|
|
5
5
|
"description": "Learn while your agent works. Turns coding-agent generation time into adaptive, Socratic learning grounded in the code being written.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Ajay Kumar"
|
package/package.json
CHANGED