Sample
compact-encoding 3.3.2: c.decode
Verified sample for npm compact-encoding 3.3.2: c.decode. The contract ran on node 22 · linux debian/x64 · docker and passed: c.decode is exported as a…
sha256:030633ff9dd643d7b4695e7a30029f83ed272e85a4fac49547f58c2f3c2ce32b
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-02 |
Case
HOW- Goal
- verify c.decode in pkg:npm/compact-encoding@3.3.2
- Packages
- Symbols
-
- c.decode
- Environment
- node 22.23.2
- Created
- 2026-09-02T15:21:41Z
Contract
- c.decode is exported as a function
- c.decode decodes UTF-8 strings from binary buffers
- c.decode decodes compact variable-length unsigned integers
- c.decode decodes fixed-size integers and signed integers
- c.decode decodes boolean values
- c.decode decodes arrays using composite array codecs
- c.decode decodes JSON objects from binary buffers
- c.decode decodes prefixed and raw binary buffers
- c.decode decodes structured custom records with multi-field codecs
- c.decode decodes from Uint8Array instances
- c.decode throws an out of bounds error when buffer length is insufficient
Files
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Source
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify c.decode in pkg:npm/compact-encoding@3.3.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/compact-encoding@3.3.2
Demonstrate these symbols/APIs:
- c.decode
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:59a97621c25985b0ca1eb0fe44e0c174e83b1da6227cb53f28769f9a2082a93e","contract":["c.decode is exported as a function","c.decode decodes UTF-8 strings from binary buffers","c.decode decodes compact variable-length unsigned integers","c.decode decodes fixed-size integers and signed integers","c.decode decodes boolean values","c.decode decodes arrays using composite array codecs","c.decode decodes JSON objects from binary buffers","c.decode decodes prefixed and raw binary buffers","c.decode decodes structured custom records with multi-field codecs","c.decode decodes from Uint8Array instances","c.decode throws an out of bounds error when buffer length is insufficient"],"goal":"verify c.decode in pkg:npm/compact-encoding@3.3.2","kind":"HOW","packages":["pkg:npm/compact-encoding@3.3.2"],"schemaVersion":1,"symbols":["c.decode"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/compact-encoding@3.3.2"],"schemaVersion":1,"subject":"pkg:npm/compact-encoding@3.3.2","symbols":["c.decode"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-compact-encoding",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-compact-encoding",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"compact-encoding": "3.3.2"
}
},
"node_modules/b4a": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/b4a/-/b4a-1.8.1.tgz",
"integrity": "sha512-aiqre1Nr0B/6DgE2N5vwTc+2/oQZ4Wh1t4NznYY4E00y8LCt6NqdRv81so00oo27D8MVKTpUa/MwUUtBLXCoDw==",
"license": "Apache-2.0",
"peerDependencies": {
"react-native-b4a": "*"
},
"peerDependenciesMeta": {
"react-native-b4a": {
"optional": true
}
}
},
"node_modules/compact-encoding": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/compact-encoding/-/compact-encoding-3.3.2.tgz",
"integrity": "sha512-bgZ84oVSzjQmVHXBYWON+wQUkdVflrr8fM5+0X6UwQHZyzolsGIkdsjNK3vLLn22dhdASGFz5mS6Lf7rfrPdlg==",
"license": "Apache-2.0",
"dependencies": {
"b4a": "^1.3.0"
}
}
}
}
{
"name": "sample-compact-encoding",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of compact-encoding",
"main": "src/index.js",
"license": "MIT-0",
"dependencies": {
"compact-encoding": "3.3.2"
}
}
{
"schemaVersion": 1,
"goal": "verify c.decode in pkg:npm/compact-encoding@3.3.2",
"kind": "HOW",
"packages": [
"pkg:npm/compact-encoding@3.3.2"
],
"symbols": [
"c.decode"
]
}
'use strict';
const c = require('compact-encoding');
/**
* Decode a binary buffer using compact-encoding.
* @param {object} encoding - compact-encoding codec
* @param {Buffer|Uint8Array} buffer - binary buffer to decode
* @returns {*} decoded value
*/
function decode(encoding, buffer) {
return c.decode(encoding, buffer);
}
/**
* Encode a value into a binary buffer using compact-encoding.
* @param {object} encoding - compact-encoding codec
* @param {*} value - value to encode
* @returns {Buffer|Uint8Array} encoded buffer
*/
function encode(encoding, value) {
return c.encode(encoding, value);
}
module.exports = {
c,
compactEncoding: c,
decode,
encode,
state: c.state,
string: c.string,
uint: c.uint,
uint8: c.uint8,
uint16: c.uint16,
uint32: c.uint32,
int: c.int,
int8: c.int8,
bool: c.bool,
buffer: c.buffer,
raw: c.raw,
json: c.json,
array: c.array,
frame: c.frame
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const {
c,
decode,
encode,
state,
string,
uint,
uint8,
uint16,
uint32,
int,
int8,
bool,
buffer,
raw,
json,
array,
frame
} = require('../src/index.js');
// 1. Export verification
assert.equal(typeof c.decode, 'function', 'c.decode must be exported as a function');
assert.equal(typeof decode, 'function', 'decode wrapper must be exported as a function');
assert.equal(typeof encode, 'function', 'encode wrapper must be exported as a function');
assert.equal(typeof state, 'function', 'state helper must be exported as a function');
// 2. c.decode decodes UTF-8 strings from binary buffers
{
const expected = 'compact encoding verification';
const encoded = encode(string, expected);
const result = decode(string, encoded);
assert.equal(result, expected);
}
// 3. c.decode decodes compact variable-length unsigned integers
{
const testValues = [0, 42, 252, 253, 65535, 65536, 4294967295];
for (const val of testValues) {
const encoded = encode(uint, val);
const result = decode(uint, encoded);
assert.equal(result, val);
}
}
// 4. c.decode decodes fixed-size integers and signed integers
{
assert.equal(decode(uint8, encode(uint8, 255)), 255);
assert.equal(decode(uint16, encode(uint16, 60000)), 60000);
assert.equal(decode(uint32, encode(uint32, 3000000000)), 3000000000);
assert.equal(decode(int8, encode(int8, -128)), -128);
assert.equal(decode(int, encode(int, -50000)), -50000);
}
// 5. c.decode decodes boolean values
{
assert.equal(decode(bool, encode(bool, true)), true);
assert.equal(decode(bool, encode(bool, false)), false);
}
// 6. c.decode decodes arrays using composite array codecs
{
const list = ['first', 'second', 'third'];
const listCodec = array(string);
const encoded = encode(listCodec, list);
const result = decode(listCodec, encoded);
assert.deepEqual(result, list);
}
// 7. c.decode decodes JSON objects from binary buffers
{
const payload = { id: 101, tags: ['alpha', 'beta'], active: true };
const encoded = encode(json, payload);
const result = decode(json, encoded);
assert.deepEqual(result, payload);
}
// 8. c.decode decodes prefixed and raw binary buffers
{
const sampleData = Buffer.from([0xaa, 0xbb, 0xcc, 0xdd]);
const encodedPrefixed = encode(buffer, sampleData);
const decodedPrefixed = decode(buffer, encodedPrefixed);
assert.deepEqual(decodedPrefixed, sampleData);
const encodedRaw = encode(raw, sampleData);
const decodedRaw = decode(raw, encodedRaw);
assert.deepEqual(decodedRaw, sampleData);
}
// 9. c.decode decodes structured custom records with multi-field codecs
{
const recordCodec = {
preencode(stateObj, rec) {
string.preencode(stateObj, rec.title);
uint.preencode(stateObj, rec.count);
bool.preencode(stateObj, rec.verified);
},
encode(stateObj, rec) {
string.encode(stateObj, rec.title);
uint.encode(stateObj, rec.count);
bool.encode(stateObj, rec.verified);
},
decode(stateObj) {
return {
title: string.decode(stateObj),
count: uint.decode(stateObj),
verified: bool.decode(stateObj)
};
}
};
const record = { title: 'Sample Spec', count: 42, verified: true };
const encoded = encode(recordCodec, record);
const result = decode(recordCodec, encoded);
assert.deepEqual(result, record);
}
// 10. c.decode decodes from Uint8Array instances
{
const text = 'typed array payload';
const encodedBuf = encode(string, text);
const uint8View = new Uint8Array(encodedBuf.buffer, encodedBuf.byteOffset, encodedBuf.byteLength);
const result = decode(string, uint8View);
assert.equal(result, text);
}
// 11. c.decode throws an out of bounds error when buffer length is insufficient
{
const truncatedBuffer = Buffer.alloc(1);
assert.throws(
() => decode(uint32, truncatedBuffer),
/Out of bounds/
);
}
console.log('Contract assertions passed.');
Origin Seeder
anonymous