@raytrace-cli/cli 0.22.0 → 0.22.2

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.
@@ -209,48 +209,151 @@ export async function readTraces(db, { includeHistory = false, evidence = true,
209
209
  started_at: row.started_at ?? null, ended_at: row.ended_at ?? null,
210
210
  });
211
211
  }
212
+ // Where a sandboxed Claude Code's project folder stood after each call,
213
+ // and any host-observed activity facts (file, network, dns) stamped with call_id.
214
+ const allCallIds = traceOrigins.map((origin) => origin.call_id);
215
+ const sessionScope = { sessionId: trace.sandboxId || trace.id };
216
+ const snapshots = await db.snapshotsForCalls(allCallIds, sessionScope);
217
+ const activityFacts = db?.activityFactsForCalls ? await db.activityFactsForCalls(allCallIds, sessionScope) : new Map();
218
+ const FILE_WRITERS = /^(?:Write|Edit|MultiEdit|NotebookEdit|apply_patch)$/i;
219
+ const factVerification = (origin, real) => {
220
+ if (real && real.outcome !== 'not_executed') {
221
+ return {
222
+ outcome: real.outcome,
223
+ verified: true,
224
+ status: real.status ?? null,
225
+ error: real.error ?? null,
226
+ match_score: real.match_score ?? null,
227
+ match_basis: real.match_basis ?? null,
228
+ source: real.source ?? null,
229
+ kernel_confirmed: real.kernel_confirmed === 1,
230
+ file_confirmed: false,
231
+ tier: real.tier ?? null,
232
+ };
233
+ }
234
+ const facts = activityFacts.get(origin.call_id) ?? [];
235
+ const fileFacts = facts.filter((fact) => fact.kind === 'file');
236
+ const snapshot = snapshots.get(origin.call_id) ?? null;
237
+ if (origin.kind === 'file') {
238
+ if (fileFacts.length > 0) {
239
+ const fromReport = fileFacts.some((fact) => fact.call_from === 'tool_report');
240
+ return {
241
+ outcome: 'file_observed',
242
+ verified: true,
243
+ status: 'completed',
244
+ error: null,
245
+ match_score: 1,
246
+ match_basis: fromReport ? 'tool_report' : 'file_fact',
247
+ source: 'file_fact',
248
+ kernel_confirmed: false,
249
+ file_confirmed: true,
250
+ tier: 'corroborated',
251
+ };
252
+ }
253
+ if (snapshot?.changed === true) {
254
+ return {
255
+ outcome: 'file_observed',
256
+ verified: true,
257
+ status: 'completed',
258
+ error: null,
259
+ match_score: 1,
260
+ match_basis: 'snapshot',
261
+ source: 'snapshot',
262
+ kernel_confirmed: false,
263
+ file_confirmed: true,
264
+ tier: 'corroborated',
265
+ };
266
+ }
267
+ if (!FILE_WRITERS.test(origin.name || '')) {
268
+ // Read-only file tools (Read, Grep, Glob, LS) run inside the agent
269
+ // process and start no program; never flag them as a missing command.
270
+ return {
271
+ outcome: 'in_agent',
272
+ verified: false,
273
+ status: 'in_agent',
274
+ error: null,
275
+ match_score: null,
276
+ match_basis: null,
277
+ source: null,
278
+ kernel_confirmed: false,
279
+ file_confirmed: false,
280
+ tier: null,
281
+ };
282
+ }
283
+ } else if (facts.length > 0) {
284
+ // Activity already carries this call_id (e.g. network/dns/file fact),
285
+ // so the call definitely ran even if the process row has not joined yet.
286
+ return {
287
+ outcome: 'join_pending',
288
+ verified: true,
289
+ status: 'join_pending',
290
+ error: null,
291
+ match_score: 1,
292
+ match_basis: 'id',
293
+ source: 'activity_fact',
294
+ kernel_confirmed: false,
295
+ file_confirmed: fileFacts.length > 0,
296
+ tier: 'corroborated',
297
+ };
298
+ }
299
+ return {
300
+ outcome: real?.outcome ?? 'not_executed',
301
+ verified: false,
302
+ status: real?.status ?? null,
303
+ error: real?.error ?? null,
304
+ match_score: real?.match_score ?? null,
305
+ match_basis: real?.match_basis ?? null,
306
+ source: real?.source ?? null,
307
+ kernel_confirmed: false,
308
+ file_confirmed: false,
309
+ tier: real?.tier ?? null,
310
+ };
311
+ };
312
+
313
+ const originByCallId = new Map(traceOrigins.map((origin) => [origin.call_id, origin]));
212
314
  trace.evidence = trace.evidence.map((item) => {
213
315
  const real = item.call_id ? byCallId.get(item.call_id) : null;
214
- if (!real) return item;
215
- // 'not_executed' means no execution row was correlated — this could be
216
- // a call that genuinely never ran, or one the (deliberately
217
- // conservative) matcher failed to correlate. Either way, there is no
218
- // real ground truth to show yet, so this stays "unverified" and keeps
219
- // the regex-heuristic succeeded value rather than asserting a fact we
220
- // don't actually have.
221
- const verified = real.outcome !== 'not_executed';
222
- return {
223
- ...item,
224
- real_outcome: real.outcome,
225
- real_status: real.status ?? null,
226
- real_error: real.error ?? null,
316
+ const origin = item.call_id ? originByCallId.get(item.call_id) : null;
317
+ if (!real && !origin) return item;
318
+ const resolved = origin ? factVerification(origin, real) : {
319
+ outcome: real.outcome,
320
+ verified: real.outcome !== 'not_executed',
321
+ status: real.status ?? null,
322
+ error: real.error ?? null,
227
323
  match_score: real.match_score ?? null,
228
324
  match_basis: real.match_basis ?? null,
229
- // Which witness observed it (only 'gvisor' now), and whether the
230
- // runtime layer saw it start. Both drive the badge.
231
325
  source: real.source ?? null,
232
326
  kernel_confirmed: real.kernel_confirmed === 1,
233
- // How this call's execution was attributed, recorded at capture (see
234
- // migration 005). The UI badges this directly instead of re-deriving
235
- // confidence from kernel_confirmed + match_basis, which is how a
236
- // text-similarity guess ended up wearing the same badge as an exact
237
- // join. Null for rows written before 005.
327
+ file_confirmed: false,
238
328
  tier: real.tier ?? null,
329
+ };
330
+ return {
331
+ ...item,
332
+ real_outcome: resolved.outcome,
333
+ real_status: resolved.status,
334
+ real_error: resolved.error,
335
+ match_score: resolved.match_score,
336
+ match_basis: resolved.match_basis,
337
+ // Which witness observed it (gvisor, file_fact, snapshot, activity_fact),
338
+ // and whether the runtime layer saw a program start.
339
+ source: resolved.source,
340
+ kernel_confirmed: resolved.kernel_confirmed,
341
+ file_confirmed: resolved.file_confirmed,
342
+ tier: resolved.tier,
239
343
  // The call's own process, so the decision chain can say which pid
240
344
  // this call ran as and jump to it in the sandbox tree.
241
345
  ...executionFields(real),
242
346
  descendants: descendantsByCall.get(item.call_id) ?? [],
243
- descendant_count: real.descendant_count ?? 0,
244
- verified,
347
+ descendant_count: real?.descendant_count ?? 0,
348
+ verified: resolved.verified,
245
349
  // Whether the agent's own report of the result (exit code, wall
246
350
  // time) agrees with what the runtime observed. See migration 007.
247
- reported_check: real.reported_check ?? null,
351
+ reported_check: real?.reported_check ?? null,
248
352
  // Real ground truth overrides the text-scanning heuristic once we
249
- // have it -- except while a sandbox command is still 'running'
250
- // (gVisor has seen it start but not exit yet) or its outcome is
251
- // 'unknown' (the evidence that would say was lost): asserting success
252
- // or failure there would be a fact we don't have, so keep the heuristic.
253
- succeeded: verified && real.status !== 'running' && real.status !== 'unknown' ? real.status === 'completed' : item.succeeded,
353
+ // have it -- except while a sandbox command is still 'running' /
354
+ // 'join_pending' / 'in_agent' or its outcome is 'unknown'.
355
+ succeeded: resolved.verified && resolved.kernel_confirmed && resolved.status !== 'running' && resolved.status !== 'unknown'
356
+ ? resolved.status === 'completed' : item.succeeded,
254
357
  };
255
358
  });
256
359
 
@@ -258,13 +361,9 @@ export async function readTraces(db, { includeHistory = false, evidence = true,
258
361
  // above, this isn't limited to calls whose result got resent as later
259
362
  // input — it covers every call this trace ever proposed, including one
260
363
  // in the very last response with no later request to resend it into.
261
- // `origins` already has one entry per call_id with the exchange that
262
- // proposed it, so this is just that, decorated with whatever real
263
- // execution data (if any) `divergence()` found for the same call_id.
264
- // Where a sandboxed Claude Code's project folder stood after each call.
265
- const snapshots = await db.snapshotsForCalls(traceOrigins.map((origin) => origin.call_id), { sessionId: trace.sandboxId || trace.id });
266
364
  trace.callVerifications = traceOrigins.map((origin) => {
267
365
  const real = byCallId.get(origin.call_id);
366
+ const resolved = factVerification(origin, real);
268
367
  return {
269
368
  call_id: origin.call_id,
270
369
  exchange_id: origin.exchange_id,
@@ -273,14 +372,15 @@ export async function readTraces(db, { includeHistory = false, evidence = true,
273
372
  category: origin.category.category,
274
373
  category_source: origin.category.source,
275
374
  ...(origin.category.command ? { category_command: origin.category.command } : {}),
276
- verified: real ? real.outcome !== 'not_executed' : false,
277
- status: real?.status ?? null,
278
- error: real?.error ?? null,
279
- match_score: real?.match_score ?? null,
280
- match_basis: real?.match_basis ?? null,
281
- source: real?.source ?? null,
282
- kernel_confirmed: real?.kernel_confirmed === 1,
283
- tier: real?.tier ?? null,
375
+ verified: resolved.verified,
376
+ status: resolved.status,
377
+ error: resolved.error,
378
+ match_score: resolved.match_score,
379
+ match_basis: resolved.match_basis,
380
+ source: resolved.source,
381
+ kernel_confirmed: resolved.kernel_confirmed,
382
+ file_confirmed: resolved.file_confirmed,
383
+ tier: resolved.tier,
284
384
  reported_check: real?.reported_check ?? null,
285
385
  descendant_count: real?.descendant_count ?? 0,
286
386
  // Everything the "proposed vs observed" table needs for this row:
@@ -117,6 +117,11 @@ ALIAS_WINDOW = 5_000_000_000 # ns before a change within which an open of ano
117
117
  # naming a folder (a script given its working folder) says nothing of them.
118
118
  FOLDER_TOOLS = frozenset(['rm', 'rmdir', 'mv', 'cp', 'chmod', 'chown', 'chgrp', 'find', 'rsync', 'shred', 'unlink', 'truncate'])
119
119
  PACKAGE_TOOLS = frozenset(['npm', 'npx', 'pnpm', 'yarn', 'bun', 'pip', 'pip3', 'uv', 'poetry'])
120
+ PIP_BIN = re.compile(r'^pip(?:\d+(?:\.\d+)*)?$')
121
+ PYTHON_BIN = re.compile(r'^python(?:\d+(?:\.\d+)*)?$')
122
+ VENV_BIN_PREFIX = re.compile(r'^(.+)/bin/(?:python(?:\d+(?:\.\d+)*)?|pip(?:\d+(?:\.\d+)*)?)$')
123
+ SYSTEM_PREFIXES = frozenset(['', '/', '/usr', '/usr/local'])
124
+ DIST_INFO_FILES = frozenset(['METADATA', 'RECORD', 'WHEEL', 'INSTALLER'])
120
125
  REGISTRIES = frozenset(['registry.npmjs.org', 'registry.yarnpkg.com', 'pypi.org', 'files.pythonhosted.org'])
121
126
  MAX_PACKAGES = 400
122
127
  REJECTED = [ipaddress.ip_network(block) for block in network.REJECTED]
@@ -239,10 +244,8 @@ def change(before, after, events, flags):
239
244
  return 'changed'
240
245
 
241
246
 
242
- def project_path(event):
243
- """The project file an open names, relative to the project, or None when
244
- it is outside it. Worked out from the text of the path: links inside the
245
- project are not followed, which a fact says as `resolution: lexical`."""
247
+ def observed_path(event):
248
+ """Normalized absolute path inside the container an open names, or None."""
246
249
  name = event.get('pathname') or ''
247
250
  if not name:
248
251
  return None
@@ -251,46 +254,154 @@ def project_path(event):
251
254
  if not base or not base.startswith('/'):
252
255
  return None
253
256
  name = base + '/' + name
254
- name = posixpath.normpath(name)
255
- return name[len(WORKSPACE):] if name.startswith(WORKSPACE) else None
257
+ return posixpath.normpath(name)
258
+
259
+
260
+ def project_path(event):
261
+ """The project file an open names, relative to the project, or None when
262
+ it is outside it. Worked out from the text of the path: links inside the
263
+ project are not followed, which a fact says as `resolution: lexical`."""
264
+ name = observed_path(event)
265
+ return name[len(WORKSPACE):] if name and name.startswith(WORKSPACE) else None
266
+
267
+
268
+ def dist_info_from_path(path):
269
+ """If `path` is a Python package metadata file inside a `*.dist-info`
270
+ folder anywhere in the container (including `/tmp/venv`), return
271
+ `('pip', package, version)`; else None."""
272
+ if not path:
273
+ return None
274
+ folder, leaf = posixpath.split(path)
275
+ if leaf not in DIST_INFO_FILES:
276
+ return None
277
+ dist = posixpath.basename(folder)
278
+ if not dist.endswith('.dist-info') or '-' not in dist:
279
+ return None
280
+ package, _, version = dist[:-len('.dist-info')].rpartition('-')
281
+ if not package or not version or package.startswith('.'):
282
+ return None
283
+ return ('pip', package[:200], version[:80])
284
+
256
285
 
286
+ def is_package_manager(argv):
287
+ """Whether `argv` is a package-manager invocation (npm/pip/uv/poetry,
288
+ `python ... -m pip`, `python ... -m ensurepip`, `*/bin/pip*`, or `get-pip.py`)."""
289
+ if not argv:
290
+ return False
291
+ bases = [posixpath.basename(part) for part in argv if isinstance(part, str) and part]
292
+ if not bases:
293
+ return False
294
+ if PACKAGE_TOOLS.intersection(bases[:4]):
295
+ return True
296
+ if any(PIP_BIN.match(base) or base == 'get-pip.py' for base in bases):
297
+ return True
298
+ if PYTHON_BIN.match(bases[0]):
299
+ for index, part in enumerate(argv[1:], start=1):
300
+ if part == '-m' and index + 1 < len(argv) and argv[index + 1] in ('pip', 'ensurepip'):
301
+ return True
302
+ if isinstance(part, str) and part in ('-mpip', '-mensurepip'):
303
+ return True
304
+ return False
305
+
306
+
307
+ def package_prefixes(argv):
308
+ """Container venv/target prefixes named in `argv` (e.g. `/tmp/venv` from
309
+ `/tmp/venv/bin/python`, or `--prefix` / `--target` / `-t`)."""
310
+ if not argv:
311
+ return []
312
+ found = []
313
+ first = posixpath.normpath(argv[0]) if isinstance(argv[0], str) and argv[0].startswith('/') else ''
314
+ match = VENV_BIN_PREFIX.match(first)
315
+ if match and match.group(1) not in SYSTEM_PREFIXES:
316
+ found.append(match.group(1))
317
+ for index, part in enumerate(argv[1:], start=1):
318
+ if not isinstance(part, str):
319
+ continue
320
+ value = None
321
+ if part in ('--prefix', '--target', '-t') and index + 1 < len(argv) and isinstance(argv[index + 1], str):
322
+ value = argv[index + 1]
323
+ elif part.startswith('--prefix='):
324
+ value = part[len('--prefix='):]
325
+ elif part.startswith('--target='):
326
+ value = part[len('--target='):]
327
+ if value:
328
+ norm = posixpath.normpath(value if value.startswith('/') else WORKSPACE + value)
329
+ if norm not in SYSTEM_PREFIXES and norm not in found:
330
+ found.append(norm)
331
+ return found
257
332
 
258
- def installed(workspace, home):
333
+
334
+ def _scan_pip_site(found, volume, site):
335
+ for name in names_inside(volume, site):
336
+ if name.endswith('.dist-info') and '-' in name:
337
+ package, _, version = name[:-len('.dist-info')].rpartition('-')
338
+ if package and version:
339
+ found[('pip', package[:200], version[:80])] = None
340
+
341
+
342
+ def installed(workspace, home, extra_prefixes=()):
259
343
  """{(manager, name, version): where it came from} as the package managers'
260
- own records on the volume have it. The agent can write those files, so a
261
- fact drawn from them is `reported`, not seen."""
344
+ own records on the host-mounted volumes have it. The agent can write those
345
+ files, so a fact drawn from them is `reported`, not seen.
346
+
347
+ `extra_prefixes` may name container prefixes (e.g. `/workspace/custom-env`
348
+ or `/home/node/myenv`) extracted from package-manager argv; only prefixes
349
+ inside the sandbox's own workspace or home volume are walked from the host.
350
+ Container-ephemeral paths like `/tmp/venv` are observed directly via open
351
+ syscalls (`dist_info_from_path`)."""
262
352
  found = {}
263
- roots = [''] + [name for name in names_inside(workspace, '') if name not in SKIPPED and not name.startswith('.')][:50]
264
- for root in roots:
265
- modules = posixpath.join(root, 'node_modules')
266
- lock = read_inside(workspace, posixpath.join(modules, '.package-lock.json'), 32 * 1024 * 1024)
267
- try:
268
- listed = json.loads(lock)['packages'] if lock else None
269
- except (ValueError, KeyError, TypeError):
270
- listed = None
271
- if isinstance(listed, dict):
272
- for key, entry in listed.items():
273
- if isinstance(key, str) and isinstance(entry, dict) and isinstance(entry.get('version'), str):
274
- found[('npm', key.rsplit('node_modules/', 1)[-1][:200], entry['version'][:80])] = str(entry.get('resolved') or '')[:300] or None
353
+ if workspace:
354
+ roots = [''] + [name for name in names_inside(workspace, '') if name not in SKIPPED and not name.startswith('.')][:50]
355
+ for root in roots:
356
+ modules = posixpath.join(root, 'node_modules')
357
+ lock = read_inside(workspace, posixpath.join(modules, '.package-lock.json'), 32 * 1024 * 1024)
358
+ try:
359
+ listed = json.loads(lock)['packages'] if lock else None
360
+ except (ValueError, KeyError, TypeError):
361
+ listed = None
362
+ if isinstance(listed, dict):
363
+ for key, entry in listed.items():
364
+ if isinstance(key, str) and isinstance(entry, dict) and isinstance(entry.get('version'), str):
365
+ found[('npm', key.rsplit('node_modules/', 1)[-1][:200], entry['version'][:80])] = str(entry.get('resolved') or '')[:300] or None
366
+ continue
367
+ # No npm record (yarn, pnpm, bun): the packages at the top of node_modules.
368
+ for name in names_inside(workspace, modules)[:1000]:
369
+ for package in ([posixpath.join(name, inner) for inner in names_inside(workspace, posixpath.join(modules, name))[:200]]
370
+ if name.startswith('@') else [name]):
371
+ text = read_inside(workspace, posixpath.join(modules, package, 'package.json'), 1024 * 1024)
372
+ try:
373
+ version = json.loads(text)['version'] if text else None
374
+ except (ValueError, KeyError, TypeError):
375
+ version = None
376
+ if isinstance(version, str):
377
+ found[('node', package[:200], version[:80])] = None
378
+ sites = ([(workspace, posixpath.join(env, 'lib')) for env in ('.venv', 'venv')] if workspace else []) + ([(home, '.local/lib')] if home else [])
379
+ direct_sites = []
380
+ for prefix in extra_prefixes or ():
381
+ if not isinstance(prefix, str) or not prefix:
275
382
  continue
276
- # No npm record (yarn, pnpm, bun): the packages at the top of node_modules.
277
- for name in names_inside(workspace, modules)[:1000]:
278
- for package in ([posixpath.join(name, inner) for inner in names_inside(workspace, posixpath.join(modules, name))[:200]]
279
- if name.startswith('@') else [name]):
280
- text = read_inside(workspace, posixpath.join(modules, package, 'package.json'), 1024 * 1024)
281
- try:
282
- version = json.loads(text)['version'] if text else None
283
- except (ValueError, KeyError, TypeError):
284
- version = None
285
- if isinstance(version, str):
286
- found[('node', package[:200], version[:80])] = None
287
- sites = [(workspace, posixpath.join(env, 'lib')) for env in ('.venv', 'venv')] + ([(home, '.local/lib')] if home else [])
383
+ norm = posixpath.normpath(prefix)
384
+ if workspace and (norm == WORKSPACE.rstrip('/') or norm.startswith(WORKSPACE)):
385
+ rel = norm[len(WORKSPACE):] if norm.startswith(WORKSPACE) else ''
386
+ lib = posixpath.join(rel, 'lib') if rel else 'lib'
387
+ if (workspace, lib) not in sites:
388
+ sites.append((workspace, lib))
389
+ if rel and (workspace, rel) not in direct_sites:
390
+ direct_sites.append((workspace, rel))
391
+ elif home and norm.startswith('/home/'):
392
+ parts = PurePosixPath(norm).parts # ('/', 'home', '<user>', ...)
393
+ if len(parts) >= 4:
394
+ rel = posixpath.join(*parts[3:])
395
+ lib = posixpath.join(rel, 'lib')
396
+ if (home, lib) not in sites:
397
+ sites.append((home, lib))
398
+ if (home, rel) not in direct_sites:
399
+ direct_sites.append((home, rel))
288
400
  for volume, lib in sites:
289
401
  for python in names_inside(volume, lib)[:10]:
290
- for name in names_inside(volume, posixpath.join(lib, python, 'site-packages')):
291
- if name.endswith('.dist-info') and '-' in name:
292
- package, _, version = name[:-len('.dist-info')].rpartition('-')
293
- found[('pip', package[:200], version[:80])] = None
402
+ _scan_pip_site(found, volume, posixpath.join(lib, python, 'site-packages'))
403
+ for volume, site in direct_sites:
404
+ _scan_pip_site(found, volume, site)
294
405
  return found
295
406
 
296
407
 
@@ -361,6 +472,8 @@ class Sandbox:
361
472
  self.watches = {} # folder -> inotify watch
362
473
  self.counts = {} # step -> opens that were only counted
363
474
  self.packages = None # what was installed when last looked
475
+ self.package_prefixes = set() # extra venv/target prefixes seen in package-manager argv
476
+ self.observed_packages = {} # {(manager, name, version): None} seen via open syscalls (e.g. /tmp/venv)
364
477
  self.package_due = self.package_who = None
365
478
  self.registry_at = float('-inf') # when a package registry was last connected to
366
479
  self.gap_at = float('-inf') # when events were last lost
@@ -685,8 +798,12 @@ class Engine(threading.Thread):
685
798
  and writer['who'].get('start_ns') in (None, event.get('process_start_ns'))):
686
799
  writer['gone'] = True
687
800
  box.due[path] = min(box.due.get(path, now + SETTLE), now + SETTLE)
688
- if gone and box.workspace and PACKAGE_TOOLS & {posixpath.basename(part) for part in gone['argv'][:4]}:
689
- # A package manager finished: see what it left, once it has settled.
801
+ if gone and is_package_manager(gone.get('argv')):
802
+ # A package manager finished: record any venv/target prefix it named
803
+ # and inspect what it left once writes have settled.
804
+ for prefix in package_prefixes(gone.get('argv')):
805
+ if len(box.package_prefixes) < 64:
806
+ box.package_prefixes.add(prefix)
690
807
  box.package_due = self.clock() + 1
691
808
  box.package_who = self.who(box, event, gone)
692
809
 
@@ -790,11 +907,21 @@ class Engine(threading.Thread):
790
907
  def opened(self, box, event):
791
908
  at_ns = int(event.get('timestamp_ns') or 0) or time.time_ns()
792
909
  who = self.who(box, event)
910
+ flags, errno = event.get('flags', 0), event.get('errno', 0)
911
+ writing = (flags & O_ACCMODE) != 0 or bool(flags & (O_CREAT | O_TRUNC))
912
+ if writing and not errno and not who.get('own'):
913
+ pkg = dist_info_from_path(observed_path(event))
914
+ if pkg and pkg not in box.observed_packages:
915
+ box.observed_packages[pkg] = None
916
+ if len(box.observed_packages) > 5000:
917
+ box.observed_packages.pop(next(iter(box.observed_packages)))
918
+ due = self.clock() + 1
919
+ box.package_due = min(box.package_due, due) if box.package_due else due
920
+ if not box.package_who or who.get('call_id'):
921
+ box.package_who = who
793
922
  path = project_path(event)
794
923
  if path is None or not box.workspace:
795
924
  return self.counted(box, who, '(outside the project)', at_ns)
796
- flags, errno = event.get('flags', 0), event.get('errno', 0)
797
- writing = (flags & O_ACCMODE) != 0 or bool(flags & (O_CREAT | O_TRUNC))
798
925
  guard = box.guarded.get(path)
799
926
  top = path.split('/', 1)[0] if '/' in path else '(project root)'
800
927
  if guard is None:
@@ -1187,9 +1314,9 @@ class Engine(threading.Thread):
1187
1314
 
1188
1315
  def packages(self, box):
1189
1316
  """What a package manager left that was not there before."""
1190
- if not box.workspace:
1317
+ if not box.workspace and not box.observed_packages:
1191
1318
  return
1192
- now = installed(box.workspace, box.home)
1319
+ now = {**installed(box.workspace, box.home, extra_prefixes=box.package_prefixes), **box.observed_packages}
1193
1320
  before, box.packages = box.packages or {}, now
1194
1321
  fresh = sorted(key for key in now if key not in before)
1195
1322
  if not fresh: