Skip to content

An open-source, faster Devin alternative

TypeScript

filesetdigest: sync golden vector to the 5-file binary version (fbea3c24…, cross-repo, Lane B)

Igor Zalutski319394fe0d82
diff --git a/cmd/oc/internal/filesetdigest/filesetdigest_test.go b/cmd/oc/internal/filesetdigest/filesetdigest_test.go
index 9cd6e827..ef050703 100644
--- a/cmd/oc/internal/filesetdigest/filesetdigest_test.go
+++ b/cmd/oc/internal/filesetdigest/filesetdigest_test.go
@@ -4,6 +4,7 @@ import (
"bytes"
"compress/gzip"
"crypto/sha256"
+ "encoding/base64"
"encoding/hex"
"fmt"
"io"
@@ -14,16 +15,26 @@ import (
// goldenFiles is the SHARED cross-repo golden vector (flue-slice.md contract 4).
// The same fileset must produce goldenDigest in all three implementations:
-// this package, oc-runtimes/adapter-core, and sessions-api. The digest was
-// generated by the reference JS computeFilesetDigest.
+// this package, oc-runtimes/adapter-core, and sessions-api. It includes a real
+// binary file (logo.png) so a utf8 round-trip in ANY impl would change the digest
+// (finding #13). Kept byte-identical to testdata/golden-fileset.json.
var goldenFiles = []File{
{Path: "artifact.json", Mode: 0o644, Content: []byte("{\"entry\":\"oc.js\",\"profile_version\":1}\n")},
{Path: "oc.js", Mode: 0o644, Content: []byte("export const x = 1;\n")},
{Path: "skills/triage/SKILL.md", Mode: 0o644, Content: []byte("---\nname: triage\n---\nhello\n")},
+ {Path: "skills/triage/logo.png", Mode: 0o644, Content: mustB64("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==")},
{Path: "bin/run.sh", Mode: 0o755, Content: []byte("#!/bin/sh\necho hi\n")},
}
-const goldenDigest = "sha256:1fe94fec330dfaf6deef0774e2fd55cfc2f29ba8fb37f03db13e21cd49cfe5ba"
+func mustB64(s string) []byte {
+ b, err := base64.StdEncoding.DecodeString(s)
+ if err != nil {
+ panic(err)
+ }
+ return b
+}
+
+const goldenDigest = "sha256:fbea3c2455fbec53f75b474924fe38e7e0fc20a67cd69a7942bd5670bc25b501"
func TestGoldenDigest(t *testing.T) {
if got := Digest(goldenFiles); got != goldenDigest {
diff --git a/cmd/oc/internal/filesetdigest/testdata/golden-fileset.json b/cmd/oc/internal/filesetdigest/testdata/golden-fileset.json
index 9c4b567f..69d5d9c9 100644
--- a/cmd/oc/internal/filesetdigest/testdata/golden-fileset.json
+++ b/cmd/oc/internal/filesetdigest/testdata/golden-fileset.json
@@ -1,6 +1,6 @@
{
- "note": "Shared golden vector for the OpenComputer bundle fileset digest (flue-slice.md contract 4). computeFilesetDigest(files) MUST equal `digest` in all three implementations: cmd/oc filesetdigest (Go), sessions-api skill-bundle-canonical.ts, oc-runtimes adapter-core skills.ts. `mode` is decimal (0o644=420, 0o755=493); `content` is base64 UTF-8. `canonicalTarGzBase64` is a reference-produced canonical tar.gz — gzip framing is implementation-specific and NOT a byte-level golden; use it only to verify parseTar(gunzip(x)) recomputes `digest`.",
- "digest": "sha256:1fe94fec330dfaf6deef0774e2fd55cfc2f29ba8fb37f03db13e21cd49cfe5ba",
+ "note": "Shared golden vector for the OpenComputer bundle fileset digest (flue-slice.md contract 4). The fileset digest over RAW file bytes MUST equal `digest` in all implementations: cmd/oc filesetdigest (Go), sessions-api skill-bundle-canonical.ts (computeFilesetDigestRaw), oc-runtimes adapter-core skills.ts. `mode` is decimal (0o644=420, 0o755=493). `contentBase64` is base64 of the RAW file bytes — the fileset INCLUDES a binary PNG (skills/triage/logo.png), so any impl that decodes to a utf8 string before hashing diverges (finding #13). `canonicalTarGzBase64` is a reference canonical tar.gz — gzip framing is implementation-specific and NOT a byte-level golden; use it only to verify parseTar(gunzip(x)) recomputes `digest`.",
+ "digest": "sha256:fbea3c2455fbec53f75b474924fe38e7e0fc20a67cd69a7942bd5670bc25b501",
"files": [
{
"path": "artifact.json",
@@ -21,7 +21,12 @@
"path": "bin/run.sh",
"mode": 493,
"contentBase64": "IyEvYmluL3NoCmVjaG8gaGkK"
+ },
+ {
+ "path": "skills/triage/logo.png",
+ "mode": 420,
+ "contentBase64": "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="
}
],
- "canonicalTarGzBase64": "H4sIAAAAAAACE+2WTU7DMBBGvc4pjNmSZJxfKYgDILrjAMgEF7u4dmW7qAhxd5SyQERCrGKhdt5mrNnMZt7nET7qtRhjsQnOkmUAAOia5lgBYF4Bmu77PfU5NHVLKJAE7EMUnkCSWf+QdyZt9G9sYG4sNoFdsZ13a23kw6v0QTvLBv6REeREedS29HtbBLXcjEnqvm1/97+qfvoPfddW6H8KLi/KaQWCyuSoHFUaXT8rjqm/8Iw///+qmfnf9QDofwrkYed8pKOzIdIDvaH8GhPgjAgv2phQRq/Fsyzv725Xq2L7lNj/up7d/7zneP8nIc/zzIqtHOjXCmRTQ0ljHMYAgiDIKfMJy71XdQAUAAA="
+ "canonicalTarGzBase64": "H4sIAAAAAAACE+2XT0vDMBTAMxCRyvDkxYtdvbr2pesfmHhQJlocY6h3rTVbO2sykk4mIojoYeAX8eJn8ODdu5/Fg3QexIJ4WlCXH4SEB+Fd3u/lJeRZ0gmjzOwJRtFkAADwHGe8A0BxB3C8z3Mex+DUXKQDksBAZCFHICXXL+TSIDTjF0bdYJHZE8aq0eesk6Tk8JxwkTBq1PGVhhT/lOOEWnxATRFPLkcute+63/tv21/9B99zbeW/DFYqVl4CItZIFDM9TpTrU8W46084x4/vv+0U/Pd8AOW/DMiwz3imR4yKTB/q6zpeUx1gihCnSZoKK+NJ2CXW/m7QbJpnJ5L9r9UK8z/2sZr/pVCtVjUanpG6/lECWh6ISZoy1Qamz/+UdZnZp125/mMo/v9t7DnKfxmM2q3tsraUy14Odhp7CKFSvuZmEULLi88jhNB80Ng4GL5Gby9P7QU0c1e6vn24r+S3g61W43Hz6EZ5pFAoFH+Nd1JcnEEAGAAA"
}