You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e84b368
Browse filesBrowse the repository at this point in the historyBrowse files
fix(diagrams): #104 review — a name every object answers to is not a model, a version or a shape
Two findings from the Copilot review, both right, and a third of the same kind
that looking for them turned up.
stats.js — "IDs such as `constructor` resolve inherited properties". The
counters are plain objects keyed by model id, and a model id is whatever a
provider calls it. For a model called "constructor" the lookup found Object
itself: `calls++` wrote to Object, and the next line threw. For "__proto__" it
found the prototype every object shares, and `calls++` wrote there — every
object in the extension host had a `calls` of NaN — before it threw. The service
swallows a counter that throws, so the diagram was still drawn; the write was
not undone. An error class is a key too: "constructor" passes the class
pattern, and its count came out as "function Object() { [native code] }1".
A key is now read as an own property and written as one (defineProperty, so
"__proto__" is an entry and not a call to the prototype's setter). The store
stays an ordinary object: what is already in the editor's storage reads as
before, and it survives the JSON round trip it is stored through.
validate.js — "a crafted schema version such as `toString` resolves through
SCHEMAS' prototype". validate() promises a list of errors and threw instead:
SCHEMAS["toString"] is a function, so the version was "known", and the check
that followed read `.type` of undefined. prepare() threw with it, and so did
accept(), which is what reads a stored record back. A version is now looked up
only when it is one of the numbers this editor reads. That is deliberately
stricter than "an own key of the registry": no schema declares `v`, so the
string "1" passed as version 1 and was stored as a string, with nothing after
the lookup to object. On the ladder a version written as digits is still read
as the number, as before.
repair.js — the same lookup a third time, found by feeding those names through
every field. The synonym tables are objects, and `"shape": "constructor"`
found Object: the spec came out with a FUNCTION for a shape, and the model was
told "/nodes/0/shape: expected a string, got function" about a string it had
written. A line style of that name was read as solid without a word. A word is
now looked up as the table's own entry, so this one is unknown like any other
unknown word: drawn with the default, and said so.
Nothing else in these modules indexes an object with text from a spec: ids,
labels and groups are kept in Maps, and the schema is walked by its own field
names. The chat page keeps a table of its own, keyed by tool-call id; that one
is fixed with the page, two commits on.
Each has a test that fails on the code as reviewed: six such names as model
ids and one as an error class, with nothing written to Object or its
prototype, before and after a trip through JSON; fifteen things that are not
version 1 — the string "1" and the list [1] among them — as one error each and
never a throw, and four of them up the ladder and through accept(); seven such
words as a direction, a shape and a line style, with exactly the outcome of
"zigzag".
assert.deepStrictEqual(unknown.fixes,['/direction enum "<word>" is not a direction; used "right".','/edges/0/style enum "<word>" is not a line style; drew it solid.','/nodes/0/shape enum "<word>" is not a shape; drew a box.']);
0 commit comments