feat(javascript): report observed export property presence (#1160)

* feat(javascript): report observed export property presence

Extend compare_javascript_export_shapes so each retained return variant
lists observed property names and each change reports presence independently
of value resolution. Complete parent coverage classifies one-sided names as
added or removed even when static values stay unknown.

Fixes #725

* test(javascript): match unknown export-shape values by availability

Nested availability objects include a reason when values stay unresolved.
Assert availability through objectContaining so presence-only added and
removed rows still verify unknown values.

* fix(javascript): preserve uncertain export property presence and locations

* fix(javascript): normalize presence and preserve local property coverage

* fix(javascript): require present discriminants for return pairing

* fix(javascript): normalize retained shapes before comparison

* refactor(javascript): share return projection with executable examples

* fix(javascript): localize uncertainty for missing mutated slots

* fix(javascript): bind advertised export examples to exact artifacts

* fix(javascript): keep uncertain property flow as candidates

---------

Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
Matt Van Horn
2026-10-09 18:30:31 +08:00
committed by GitHub
co-authored by morluto
parent 04aef6df33
commit 45e3edc17f
25 changed files with 1552 additions and 113 deletions
@@ -20,40 +20,46 @@ describe("JavaScript export container coverage through authenticated Evidence",
before: "",
after: ", options: {}",
paths: ["/options"],
addedPaths: ["/options"],
},
{
name: "empty array",
before: "",
after: ", options: []",
paths: ["/options"],
addedPaths: ["/options"],
},
{
name: "nested object",
before: ", options: {}",
after: ", options: { nested: {} }",
paths: ["/options/nested"],
addedPaths: ["/options/nested"],
},
{
name: "nested array",
before: ", options: []",
after: ", options: [[]]",
paths: ["/options/0"],
addedPaths: ["/options/0"],
},
{
name: "container subtree",
before: "",
after: ", options: { nested: {} }",
paths: ["/options", "/options/nested"],
addedPaths: ["/options"],
},
{
name: "escaped property keys",
before: ', "a/b~c": {}',
after: ', "a/b~c": { "d/e~f": [] }',
paths: ["/a~1b~0c/d~1e~0f"],
addedPaths: ["/a~1b~0c/d~1e~0f"],
},
])(
"reports absent versus $name as unknown in both directions",
async ({ before, after, paths }) => {
"reports $name presence independently of unresolved values in both directions",
async ({ before, after, paths, addedPaths }) => {
const [absent, retained] = await analyzeReturns(before, after);
for (const path of paths) {
expect(
@@ -71,16 +77,17 @@ describe("JavaScript export container coverage through authenticated Evidence",
);
}
for (const [left, right, leftAvailability, rightAvailability] of [
[absent, retained, "absent", "unknown"],
[retained, absent, "unknown", "absent"],
for (const [left, right, leftAvailability, rightAvailability, status] of [
[absent, retained, "absent", "unknown", "added"],
[retained, absent, "unknown", "absent", "removed"],
] as const) {
const result = compareEvidence(left, right);
expect(result.summary).toEqual({
added: 0,
removed: 0,
changed: 0,
unknown: paths.length,
unknown: paths.length - addedPaths.length,
[status]: addedPaths.length,
});
expect(result.changes).toHaveLength(paths.length);
expect(result.changes).toEqual(
@@ -88,7 +95,7 @@ describe("JavaScript export container coverage through authenticated Evidence",
paths.map((path) =>
expect.objectContaining({
path,
status: "unknown",
status: addedPaths.includes(path) ? status : "unknown",
discriminant: { path: "/type", value: "item" },
left: expect.objectContaining({
availability: leftAvailability,
@@ -102,15 +109,20 @@ describe("JavaScript export container coverage through authenticated Evidence",
left.evidence.evidence_id,
right.evidence.evidence_id,
],
limitations: [
"The static value or relevant parent-property coverage is incomplete.",
],
limitations: addedPaths.includes(path)
? []
: [
"The static value or relevant parent-property coverage is incomplete.",
],
}),
),
),
);
expect(result.coverage).toMatchObject({
status: "partial",
status:
addedPaths.length === paths.length
? "complete-within-inputs"
: "partial",
paired_variants: 1,
unpaired_left_variants: 0,
unpaired_right_variants: 0,