Read the board document's format/version stamp instead of only writing it (#1520) #1570
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge!1570
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/1116-0006"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #1520
formatandversionwere written in two hand-copied places (engine/topology.jsserialize()andserver/index.js's file envelope) and read by nothing.Topology.fromJSON({format:'lab', version:99, devices:[], links:[]})built a board without a word, so a document that said it was another format, or a generation this build has never heard of, loaded silently. A guard that looks like a guard and is none.What changed:
DOC_FORMAT/DOC_VERSIONare the single pair of constants; both writers use them.documentStampProblem(doc)reads the stamp. Every door asks it:Topology.fromJSON()(throws), the saved-file reader, andPOST /load(400E_BAD_DOCUMENT).this document was written by a newer PacketForge (version 99); this build reads version 1 and older.docs/ARCHITECTURE.mdsays what is now read; CHANGELOG entry added under Unreleased/Fixed.Tests (
test/document-stamp.test.js, 31 assertions): the stamp written equals the stamp read; a wrong format, a newer version, a string version, version 0 and a negative version are each refused with a message naming what it said; a stamp-less document and the current version still load; the server neither restates the literal nor skips the check; and over HTTP a version-2 document is a 400 while a stamp-less one and a current one are 200.Gates:
node scripts/syntax-check.js328 files OK; fullnpm test258 suites / 9418 assertions, 1 failure that is pre-existing onorigin/main(spec-vs-description: the fouredgecore/AS4610-*specs claim 2x 20G QSFP+ they do not have, from #1555 - verified by running that suite on a cleanorigin/mainworktree).The stamp was written twice - serialize() and the server's file envelope, two hand-copied literals - and read by nothing: fromJSON() turned {format:'lab', version:99} into a board with no complaint, so the version guard everyone would assume exists was decoration. One pair of constants (DOC_FORMAT, DOC_VERSION) and one reader (documentStampProblem()). The engine loader throws on a stamp it cannot read, and the saved-file reader and POST /load answer 400 / a load refusal through the same function, naming what the document claimed and what this build reads. A document with no stamp still loads: that is every file written before the check existed.5a99dc66f49cf0333604Duplicate of #1575 — needs Jay's decision.
#1570 and #1575 are two independent fixes for the same issue (#1520: read the board document's format/version stamp instead of only writing it). Both are clean against main on their own, but they cannot both land: they rewrite the same lines.
Conflicting hunks (identical regions, different designs):
engine/topology.js— the stamp constants and the reader function:DOC_FORMAT/DOC_VERSION/documentStampProblem(doc), plainError.DOCUMENT_FORMAT/DOCUMENT_VERSION/stampProblem(doc, who),err.code = 'E_BAD_DOCUMENT', also exposesTopology.DOCUMENT_FORMAT/Topology.DOCUMENT_VERSION/Topology.stampProblem.engine/topology.jsserialize()—format: DOC_FORMAT, version: DOC_VERSIONvsformat: DOCUMENT_FORMAT, version: DOCUMENT_VERSION.engine/topology.jsTopology.fromJSON()— both insert a stamp check at the same line beforeconst topo = new Topology().server/index.jssaveTopologyNow()— header takes the pair fromrequire('../engine')(#1570) vs fromTopology.*(#1575).server/index.jssavedDocProblem()— #1570 checks envelope then board; #1575 additionally refuses a file whose header version and board version disagree, and prefixes errors withthe file header:/its board:.server/index.jsdocumentShapeProblem()— same line, same replacement.docs/ARCHITECTURE.md— different wording for the same paragraph.test/document-stamp.test.js(200 lines, #1570) vstest/document-version-stamp.test.js(89 lines, #1575).Only #1570 also touches
CHANGELOG.md.Recommendation: land #1570 first (earlier, larger test file, has the CHANGELOG entry), then let #1575 rebase and keep only the part that #1570 lacks — the header/board version-mismatch refusal and the
E_BAD_DOCUMENTcode. The alternative (land #1575, close #1570) loses the CHANGELOG entry and the 200-line test file.Verified: neither was merged. Both rebase onto
0af8f64fwith only these overlapping regions; each PR's own suites were not re-run here because a rebase of either one invalidates the other's diff.needs Jay's decision — which stamp design ships, and whether the loser's tests are folded in.