fix(semantics): preserve direct promise ownership boundaries (#758)

Signed-off-by: Rudy Celekli <rudy@gradiahq.com>
This commit is contained in:
Rudy Mizrahi Celekli
2026-10-06 13:36:41 -05:00
committed by GitHub
parent 66c26f280b
commit e1ca412757
3 changed files with 124 additions and 8 deletions
@@ -286,3 +286,27 @@ const graphFor = (source: string) => {
analysis,
});
};
it.each([
"const value = consume(Promise.resolve(1));",
"async function run() { await consume(Promise.resolve(1)); }",
"function run() { return consume(Promise.resolve(1)); }",
"const value = Promise.all([{ promise: Promise.resolve(1) }]);",
])(
"does not claim direct Promise ownership through an enclosing expression: %s",
(source) => {
const graph = graphFor(source);
const promise = graph.nodes.find(
({ kind, properties }) =>
kind === "promise" && properties.method === "resolve",
);
expect(promise?.properties.ownership).toBe("unknown");
expect(
graph.relations.filter(
({ target_node_id, relation }) =>
target_node_id === promise?.node_id &&
["owns", "awaits", "returns-task", "aggregates"].includes(relation),
),
).toEqual([]);
},
);