Exemple
pathval 2.0.1
Échantillon vérifié pour npm pathval 2.0.1. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi : getPathValue retrieves values from…
sha256:f8f683c721fd655420c71aa9f07ea917e950a2335645a418acf3c49b4e77b546
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 2
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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-26 |
| 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-07 |
Cas
HOW- Objectif
- verify pkg:npm/pathval@2.0.1
- Paquets
- Environnement
- node 22.23.2
- Créé
- 2026-08-26T09:39:19Z
Contrat
- getPathValue retrieves values from nested object structures by string path
- getPathValue supports array indexing in string paths
- setPathValue creates nested properties and sets value at string path
- getPathInfo returns parent object property name value and existence check
- hasProperty checks existence of own or inherited properties on objects and primitives
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
Code 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 pkg:npm/pathval@2.0.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/pathval@2.0.1
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:603cf19e7d23b723cca82081eb2470837210ef4e7c69764d76586dc8d710cda4","constraints":{"executionContext":"node"},"contract":["getPathValue retrieves values from nested object structures by string path","getPathValue supports array indexing in string paths","setPathValue creates nested properties and sets value at string path","getPathInfo returns parent object property name value and existence check","hasProperty checks existence of own or inherited properties on objects and primitives"],"goal":"verify pkg:npm/pathval@2.0.1","kind":"HOW","packages":["pkg:npm/pathval@2.0.1"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"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/pathval@2.0.1"],"schemaVersion":1,"subject":"pkg:npm/pathval@2.0.1","verifierAdapter":"node-typescript@1"}
{
"name": "sample-pathval",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-pathval",
"version": "1.0.0",
"dependencies": {
"pathval": "2.0.1"
}
},
"node_modules/pathval": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.1.tgz",
"integrity": "sha512-//nshmD55c46FuFw26xV/xFAaB5HF9Xdap7HJBBnrKdAd6/GxDBaNA1870O79+9ueg61cZLSVc+OaFlfmObYVQ==",
"license": "MIT",
"engines": {
"node": ">= 14.16"
}
}
}
}
{
"name": "sample-pathval",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of pathval property retrieval and mutation",
"type": "module",
"main": "src/index.js",
"dependencies": {
"pathval": "2.0.1"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/pathval@2.0.1",
"kind": "HOW",
"packages": [
"pkg:npm/pathval@2.0.1"
]
}
import { getPathValue, setPathValue, getPathInfo, hasProperty } from 'pathval';
/**
* Retrieve a value from an object given a string path.
*
* @param {object} obj - The target object to inspect.
* @param {string} path - The string path (e.g. 'a.b[0].c').
* @returns {*} The value at the path or undefined.
*/
export function getValue(obj, path) {
return getPathValue(obj, path);
}
/**
* Set a value on an object at a given string path, creating intermediate objects/arrays as needed.
*
* @param {object} obj - The target object to mutate.
* @param {string} path - The string path (e.g. 'a.b.c').
* @param {*} value - The value to set.
* @returns {object} The mutated object.
*/
export function setValue(obj, path, value) {
return setPathValue(obj, path, value);
}
/**
* Inspect property metadata for a given path on an object.
*
* @param {object} obj - The target object to inspect.
* @param {string} path - The string path.
* @returns {{ parent: object, name: string|number, value: *, exists: boolean }} Property metadata.
*/
export function inspectPath(obj, path) {
return getPathInfo(obj, path);
}
/**
* Check whether an object or primitive has a specified property (own or prototype).
*
* @param {*} obj - The target to check.
* @param {string|symbol} name - The property name to look for.
* @returns {boolean} True if the property exists.
*/
export function propertyExists(obj, name) {
return hasProperty(obj, name);
}
export { getPathValue, setPathValue, getPathInfo, hasProperty };
import assert from 'node:assert';
import {
getValue,
setValue,
inspectPath,
propertyExists,
getPathValue,
setPathValue,
getPathInfo,
hasProperty,
} from '../src/index.js';
// 1. Function exports verification
assert.strictEqual(typeof getPathValue, 'function', 'getPathValue should be a function');
assert.strictEqual(typeof setPathValue, 'function', 'setPathValue should be a function');
assert.strictEqual(typeof getPathInfo, 'function', 'getPathInfo should be a function');
assert.strictEqual(typeof hasProperty, 'function', 'hasProperty should be a function');
assert.strictEqual(typeof getValue, 'function', 'getValue helper should be a function');
assert.strictEqual(typeof setValue, 'function', 'setValue helper should be a function');
assert.strictEqual(typeof inspectPath, 'function', 'inspectPath helper should be a function');
assert.strictEqual(typeof propertyExists, 'function', 'propertyExists helper should be a function');
// 2. getPathValue retrieves nested properties
const sampleData = {
user: {
profile: {
name: 'Alice',
details: {
age: 30,
city: 'Metropolis',
},
},
tags: ['admin', 'editor'],
},
};
assert.strictEqual(getPathValue(sampleData, 'user.profile.name'), 'Alice');
assert.strictEqual(getValue(sampleData, 'user.profile.details.city'), 'Metropolis');
assert.strictEqual(getPathValue(sampleData, 'user.profile.nonexistent'), undefined);
assert.strictEqual(getPathValue(sampleData, 'nonexistent.path'), null);
// 3. getPathValue supports array indexing
assert.strictEqual(getPathValue(sampleData, 'user.tags[0]'), 'admin');
assert.strictEqual(getPathValue(sampleData, 'user.tags[1]'), 'editor');
assert.strictEqual(getPathValue(sampleData, 'user.tags[2]'), undefined);
// 4. setPathValue creates nested properties and mutates objects
const targetObj = {};
setPathValue(targetObj, 'app.config.port', 8080);
assert.strictEqual(targetObj.app.config.port, 8080);
setValue(targetObj, 'app.config.features[0]', 'logging');
assert.strictEqual(targetObj.app.config.features[0], 'logging');
assert.strictEqual(Array.isArray(targetObj.app.config.features), true);
setPathValue(targetObj, 'app.config.title', 'Sample Application');
assert.strictEqual(getPathValue(targetObj, 'app.config.title'), 'Sample Application');
// 5. getPathInfo returns parent, name, value, and existence check
const info = getPathInfo(targetObj, 'app.config.port');
assert.strictEqual(info.name, 'port');
assert.strictEqual(info.value, 8080);
assert.strictEqual(info.exists, true);
assert.strictEqual(info.parent, targetObj.app.config);
const missingInfo = inspectPath(targetObj, 'app.config.missingKey');
assert.strictEqual(missingInfo.exists, false);
assert.strictEqual(missingInfo.value, undefined);
// 6. hasProperty checks own and prototype properties safely
assert.strictEqual(hasProperty({ x: 10 }, 'x'), true);
assert.strictEqual(hasProperty({ x: 10 }, 'y'), false);
assert.strictEqual(hasProperty('string-val', 'length'), true);
assert.strictEqual(hasProperty(null, 'any'), false);
assert.strictEqual(hasProperty(undefined, 'any'), false);
assert.strictEqual(propertyExists(['first', 'second'], 0), true);
assert.strictEqual(propertyExists(['first', 'second'], 5), false);
console.log('Contract tests passed successfully.');
Seeder d'origine
anonyme