CodeSampleX

Ejemplo

abbrev 1.1.1: abbrev

Muestra verificada para npm abbrev 1.1.1: abbrev. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: abbrev calculates all unambiguous…

sha256:e73d10bd2d00ed3f3c2bffde80aad32db552ed618dac1255e262392fb0eb152f

Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido. Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas. MIT-0

Evidencia de ejecución

El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.

Base de evidencia
Contrato firmado aprobado
Recibos de verificación
1
Claves de firma que lo compilaron
1
Entorno declarado node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Entornos de las ejecuciones de verificación

Entorno Contrato Etapas Ejecución
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5…
2026-08-27

Caso

HOW
Objetivo
verify pkg:npm/abbrev@1.1.1
Paquetes
Símbolos
  • abbrev
Entorno
node 22.23.2
Creado
2026-08-27T17:20:41Z

Contrato

  1. abbrev calculates all unambiguous prefix abbreviations for an array of strings or multiple arguments
  2. abbrev maps the full original word to itself for all input words
  3. abbrev removes ambiguous prefixes shared by multiple distinct words
  4. abbrev coerces non-string arguments to strings when generating abbreviations
  5. abbrev handles single string inputs and duplicate words without collision errors

Archivos

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.js

Descargar el artefacto de código fuente (tar.gz)

Código fuente

PROMPT.md
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 pkg:npm/abbrev@1.1.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/abbrev@1.1.1
Demonstrate these symbols/APIs:
  - abbrev

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.
csx.json
{"case":{"caseId":"case:sha256:02437bd212c4f80a77b950baa8b19cb8e3035e71f81f8987a40870d86b3e64d3","contract":["abbrev calculates all unambiguous prefix abbreviations for an array of strings or multiple arguments","abbrev maps the full original word to itself for all input words","abbrev removes ambiguous prefixes shared by multiple distinct words","abbrev coerces non-string arguments to strings when generating abbreviations","abbrev handles single string inputs and duplicate words without collision errors"],"goal":"verify pkg:npm/abbrev@1.1.1","kind":"HOW","packages":["pkg:npm/abbrev@1.1.1"],"schemaVersion":1,"symbols":["abbrev"]},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/abbrev@1.1.1"],"schemaVersion":1,"subject":"pkg:npm/abbrev@1.1.1","symbols":["abbrev"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-abbrev",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-abbrev",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "abbrev": "1.1.1"
      }
    },
    "node_modules/abbrev": {
      "version": "1.1.1",
      "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
      "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
      "license": "ISC"
    }
  }
}
package.json
{
  "name": "sample-abbrev",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for abbrev",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "abbrev": "1.1.1"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/abbrev@1.1.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/abbrev@1.1.1"
  ],
  "symbols": [
    "abbrev"
  ]
}
src/index.js
const abbrev = require("abbrev");

function getAbbrevs(...words) {
  return abbrev(...words);
}

module.exports = {
  abbrev,
  getAbbrevs
};
test/contract.js
const assert = require("node:assert");
const abbrev = require("abbrev");
const { getAbbrevs } = require("../src/index.js");

// 1. abbrev calculates all unambiguous prefix abbreviations for an array of strings or multiple arguments
const resArray = getAbbrevs(["cat", "dog", "duck"]);
assert.strictEqual(resArray["c"], "cat", "c should abbreviate cat");
assert.strictEqual(resArray["ca"], "cat", "ca should abbreviate cat");
assert.strictEqual(resArray["cat"], "cat", "cat should abbreviate cat");
assert.strictEqual(resArray["do"], "dog", "do should abbreviate dog");
assert.strictEqual(resArray["dog"], "dog", "dog should abbreviate dog");
assert.strictEqual(resArray["du"], "duck", "du should abbreviate duck");
assert.strictEqual(resArray["duc"], "duck", "duc should abbreviate duck");
assert.strictEqual(resArray["duck"], "duck", "duck should abbreviate duck");

const resArgs = abbrev("foo", "fool", "folding", "flop");
assert.strictEqual(resArgs["fl"], "flop", "fl should abbreviate flop");
assert.strictEqual(resArgs["flo"], "flop", "flo should abbreviate flop");
assert.strictEqual(resArgs["flop"], "flop", "flop should abbreviate flop");
assert.strictEqual(resArgs["fol"], "folding", "fol should abbreviate folding");
assert.strictEqual(resArgs["fold"], "folding", "fold should abbreviate folding");
assert.strictEqual(resArgs["foldi"], "folding", "foldi should abbreviate folding");
assert.strictEqual(resArgs["foldin"], "folding", "foldin should abbreviate folding");
assert.strictEqual(resArgs["folding"], "folding", "folding should abbreviate folding");

// 2. abbrev maps the full original word to itself for all input words
assert.strictEqual(resArgs["foo"], "foo", "full word foo should map to foo");
assert.strictEqual(resArgs["fool"], "fool", "full word fool should map to fool");
assert.strictEqual(resArray["cat"], "cat", "full word cat should map to cat");
assert.strictEqual(resArray["dog"], "dog", "full word dog should map to dog");
assert.strictEqual(resArray["duck"], "duck", "full word duck should map to duck");

// 3. abbrev removes ambiguous prefixes shared by multiple distinct words
assert.strictEqual(resArray["d"], undefined, "ambiguous prefix d should not be present");
assert.strictEqual(resArgs["f"], undefined, "ambiguous prefix f should not be present");
assert.strictEqual(resArgs["fo"], undefined, "ambiguous prefix fo should not be present");

// 4. abbrev coerces non-string arguments to strings when generating abbreviations
const resCoerce = getAbbrevs([10, 12]);
assert.strictEqual(resCoerce["10"], "10", "coerced full number 10 should map to 10");
assert.strictEqual(resCoerce["12"], "12", "coerced full number 12 should map to 12");
assert.strictEqual(resCoerce["1"], undefined, "ambiguous numeric prefix 1 should not be present");

// 5. abbrev handles single string inputs and duplicate words without collision errors
const resSingle = getAbbrevs("single");
assert.strictEqual(resSingle["s"], "single", "s should abbreviate single");
assert.strictEqual(resSingle["si"], "single", "si should abbreviate single");
assert.strictEqual(resSingle["sin"], "single", "sin should abbreviate single");
assert.strictEqual(resSingle["sing"], "single", "sing should abbreviate single");
assert.strictEqual(resSingle["singl"], "single", "singl should abbreviate single");
assert.strictEqual(resSingle["single"], "single", "single should abbreviate single");

const resDups = abbrev(["cat", "cat", "dog"]);
assert.strictEqual(resDups["c"], "cat", "duplicate words should not eliminate valid abbreviations");
assert.strictEqual(resDups["ca"], "cat", "ca should map to cat");
assert.strictEqual(resDups["cat"], "cat", "cat should map to cat");
assert.strictEqual(resDups["d"], "dog", "d should abbreviate dog when dog is the only word starting with d");
assert.strictEqual(resDups["do"], "dog", "do should map to dog");
assert.strictEqual(resDups["dog"], "dog", "dog should map to dog");

console.log("All abbrev contract tests passed successfully.");

Seeder de origen

anónimo