fix(javascript)!: preserve property paths and uncertain slot presence

Use one explicit object/array slot model and JSON-pointer property identity across mutation analysis, return projection, and semantic graphs. Require observed presence for discriminants and resolve writes only through retained object or array receivers.

BREAKING CHANGE: projected return fields require explicit presence and semantic object operations carry full property paths.
This commit is contained in:
morluto
2026-10-09 20:18:52 +08:00
parent 63bf91405c
commit 475a0f84da
23 changed files with 831 additions and 560 deletions
@@ -463,7 +463,7 @@ describe("JavaScript export localized mutation uncertainty", () => {
});
describe("JavaScript export property presence boundaries", () => {
it("normalizes omitted legacy presence before comparing identical literals and unions", async () => {
it("rejects return-shape observations that omit required slot presence", async () => {
const source =
'export default () => ({ kind: "result", count: flag ? 1 : 2, nested: { enabled: true } });';
const [left, right] = await analyzeSources({ left: source, right: source });
@@ -513,9 +513,14 @@ describe("JavaScript export property presence boundaries", () => {
[right, { ...left, graph }],
] as const) {
const result = compare(sides[0], sides[1]);
expect(result.coverage.paired_variants).toBe(1);
expect(result.changes).toEqual([]);
expect(result.coverage.status).toBe("complete-within-inputs");
expect(result.coverage.paired_variants).toBe(0);
expect([result.left.status, result.right.status]).toContain(
"unavailable",
);
expect(result.changes).toEqual([
expect.objectContaining({ status: "unknown", path: "" }),
]);
expect(result.coverage.status).toBe("partial");
}
});
@@ -41,7 +41,7 @@ it("executes the advertised export presence example with matching analyzed Evide
});
expect(response.isError).not.toBe(true);
expect(response.structuredContent).toMatchObject({
result: {
normalized_result: {
left: { status: "selected" },
right: { status: "selected" },
summary: { added: 1, removed: 1, changed: 0, unknown: 0 },
@@ -102,7 +102,7 @@ it("traces example semantic modules with their parsed artifact digests", async (
});
expect(response.isError).not.toBe(true);
expect(response.structuredContent).toMatchObject({
result: {
normalized_result: {
nodes: expect.arrayContaining([
expect.objectContaining({
node_id: module.node_id,
@@ -161,10 +161,8 @@ describe("application workflow MCP parity", () => {
expect(relativeApplication.isError).not.toBe(true);
expect(relativeApplication.structuredContent).toMatchObject({
evidence_id: left.value.evidence_id,
result: { input_path: leftAnalysis.input_path },
evidence: {
subject: { local_path: left.value.subject?.local_path },
},
normalized_result: { input_path: leftAnalysis.input_path },
subject: { local_path: left.value.subject?.local_path },
});
const full = await client.callTool({
name: "compare_javascript_export_shapes",
@@ -172,7 +170,7 @@ describe("application workflow MCP parity", () => {
});
expect(full.isError).not.toBe(true);
expect(full.structuredContent).toMatchObject({
result: {
normalized_result: {
summary: { added: 1, removed: 0, changed: 0, unknown: 0 },
property_inventories: expect.arrayContaining([
expect.objectContaining({
@@ -231,7 +229,7 @@ describe("application workflow MCP parity", () => {
});
expect(semantic.isError).not.toBe(true);
expect(semantic.structuredContent).toMatchObject({
result: {
normalized_result: {
source_evidence_id: left.value.evidence_id,
source_graph_id: analyzed.semantic_graph.graph_id,
summary: { total_seed_matches: 1 },