mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 05:02:40 +00:00
fix(desktop): preserve capture evidence and output ownership (#9899)
* fix(desktop): retain capture identity and cleanup ownership * fix(desktop): validate destinations and finish inputs before export * fix(desktop): preserve package ownership and apt trust boundaries * fix(sqlite): preserve observed facts and distinguish special real values * fix(desktop): bind computer files to data-object metadata * test(desktop): count the tagged negative-zero cell spelling SQLite view cells encode negative zero as a real object so it stays distinct from the text "-0". The byte budget follows that spelling. * fix(desktop): keep unresolved discovered state directories Canonicalizing an unreadable path or dangling symlink aborted capture before the inventory could record that the path was unknown. Those discovered directories now keep their absolute spelling in the scope. * test(desktop): keep the capture scope suite within its line limit The unresolved state-directory case lives beside the suite so the existing callback stays within the lint limit. * fix(desktop): retain cancellation through capture input cleanup * fix(desktop): avoid reserved Pydantic settings properties --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This commit is contained in:
1 parent
a896e35c47
commit
9f5f9c1289
56 files changed
+2153
-267
No files matched your search
@@ -4,6 +4,7 @@ import { AnalysisCapabilityUnavailableError } from "../../domain/analysisErrorCo
|
||||
import { err, ok } from "../../domain/result.js";
|
||||
import { createAnalysisExecution } from "../AnalysisProvider.js";
|
||||
import { sqliteDatabaseSchema } from "../../domain/sqlite/sqliteDatabase.js";
|
||||
import { createAnalysisProfile } from "../../domain/analysisProfile.js";
|
||||
|
||||
const fixture = () => ({
|
||||
artifact: { path: "/selected.db", sha256: "a".repeat(64), bytes: 4096 },
|
||||
@@ -236,39 +237,59 @@ it.each(["path", "digest", "subject", "wal", "table"])(
|
||||
},
|
||||
);
|
||||
|
||||
it("preserves completed observed evidence when cancellation arrives after provider completion", async () => {
|
||||
const value = fixture();
|
||||
const service = new SqliteDatabaseService({
|
||||
inspect: () => Promise.resolve(ok(execution(value))),
|
||||
});
|
||||
expect(await service.inspect({ path: "/selected.db" })).toMatchObject({
|
||||
ok: true,
|
||||
value: {
|
||||
it.each([false, true])(
|
||||
"retains completed SQLite facts with late cancellation=%s",
|
||||
async (cancelled) => {
|
||||
const value = fixture();
|
||||
const observed = execution(value);
|
||||
const profile = createAnalysisProfile(
|
||||
{ ...observed.provider, version: value.engine.version },
|
||||
{
|
||||
schema: "inventory",
|
||||
},
|
||||
);
|
||||
const relationshipCoverage = {
|
||||
status: "unknown",
|
||||
reason: "Relationships were not inspected",
|
||||
} as const;
|
||||
const completed = {
|
||||
...observed,
|
||||
analysisProfile: profile,
|
||||
relationshipCoverage,
|
||||
};
|
||||
const controller = new AbortController();
|
||||
const reason = Object.freeze({
|
||||
requested: "cancel after database inspection",
|
||||
});
|
||||
const service = new SqliteDatabaseService({
|
||||
inspect: () => {
|
||||
if (cancelled) controller.abort(reason);
|
||||
return Promise.resolve(ok(completed));
|
||||
},
|
||||
});
|
||||
const result = await service.inspect(
|
||||
{ path: "/selected.db" },
|
||||
{ signal: controller.signal },
|
||||
);
|
||||
expect(result.ok).toBe(!cancelled);
|
||||
if (!result.ok) {
|
||||
expect(result.error._tag).toBe("AnalysisCancelledError");
|
||||
expect(result.error.cause).toBe(reason);
|
||||
}
|
||||
const evidence = result.ok ? result.value : result.error.partialObservation;
|
||||
expect(evidence).toMatchObject({
|
||||
operation: "inspect_sqlite_database",
|
||||
confidence: "observed",
|
||||
subject: {
|
||||
local_path: "/selected.db",
|
||||
digest: { sha256: "a".repeat(64) },
|
||||
},
|
||||
normalized_result: value,
|
||||
},
|
||||
});
|
||||
const controller = new AbortController();
|
||||
const cancelled = new SqliteDatabaseService({
|
||||
inspect: () => {
|
||||
controller.abort();
|
||||
return Promise.resolve(ok(execution(value)));
|
||||
},
|
||||
});
|
||||
expect(
|
||||
await cancelled.inspect(
|
||||
{ path: "/selected.db" },
|
||||
{ signal: controller.signal },
|
||||
),
|
||||
).toMatchObject({
|
||||
ok: true,
|
||||
value: { normalized_result: value },
|
||||
});
|
||||
});
|
||||
analysis_profile: profile,
|
||||
relationship_coverage: relationshipCoverage,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it("preserves the exact caller reason when inspection is already aborted", async () => {
|
||||
const reason = Object.freeze({ requested: "stop" });
|
||||
|
||||
Reference in new issue
Block a user