CodeSampleX

サンプル

chownr 3.0.0: sync

検証済みサンプル — npm chownr 3.0.0: sync. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: chownrSync recursively changes ownership of nested directory…

sha256:c3a2d375eabf20c03cfb58397ae03db1dcec6a010e6af1f271971990eea0e16e

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

検証実行環境

環境 コントラクト ステージ 実行日
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

ケース

HOW
ゴール
verify chownr.sync in pkg:npm/chownr@3.0.0
パッケージ
シンボル
  • chownr.sync
環境
node 22.23.2
作成日
2026-08-26T10:41:38Z

コントラクト

  1. chownrSync recursively changes ownership of nested directory trees, subdirectories, and files
  2. chownrSync changes ownership of individual files without error
  3. chownrSync modifies symlink ownership using lchown without traversing into the symlink target
  4. chownrSync handles empty directories without error
  5. chownrSync ignores non-existent paths (ENOENT) and returns without throwing
  6. chownr exports both named chownrSync function and chownr function in CommonJS

ファイル

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.cjs

ソースアーティファクトをダウンロード (tar.gz)

ソース

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 chownr.sync in pkg:npm/chownr@3.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/chownr@3.0.0
Demonstrate these symbols/APIs:
  - chownr.sync
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.2

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:2c59e8ff843ec4ea179acd4a1ab9a58553084401b90f5516ff1048f985388a05","constraints":{"executionContext":"node"},"contract":["chownrSync recursively changes ownership of nested directory trees, subdirectories, and files","chownrSync changes ownership of individual files without error","chownrSync modifies symlink ownership using lchown without traversing into the symlink target","chownrSync handles empty directories without error","chownrSync ignores non-existent paths (ENOENT) and returns without throwing","chownr exports both named chownrSync function and chownr function in CommonJS"],"goal":"verify chownr.sync in pkg:npm/chownr@3.0.0","kind":"HOW","packages":["pkg:npm/chownr@3.0.0"],"schemaVersion":1,"symbols":["chownr.sync"]},"contractCommand":["node","test/contract.cjs"],"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/chownr@3.0.0"],"schemaVersion":1,"subject":"pkg:npm/chownr@3.0.0","symbols":["chownr.sync"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-chownr-sync",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-chownr-sync",
      "version": "1.0.0",
      "dependencies": {
        "chownr": "3.0.0"
      }
    },
    "node_modules/chownr": {
      "version": "3.0.0",
      "resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz",
      "integrity": "sha512-+IxzY9BZOQd/XuYPRmrvEVjF/nqj5kgT4kEq7VofrDoM1MxoRjEWkrCC3EtLi59TVawxTAn+orJwFQcrqEN1+g==",
      "license": "BlueOak-1.0.0",
      "engines": {
        "node": ">=18"
      }
    }
  }
}
package.json
{
  "name": "sample-chownr-sync",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "chownr": "3.0.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify chownr.sync in pkg:npm/chownr@3.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/chownr@3.0.0"
  ],
  "symbols": [
    "chownr.sync"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.cjs
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const os = require('node:os');
const chownr = require('chownr');
const { chownrSync } = chownr;

const uid = typeof process.getuid === 'function' ? process.getuid() : 0;
const gid = typeof process.getgid === 'function' ? process.getgid() : 0;

// Contract 1: chownrSync recursively changes ownership of nested directory trees, subdirectories, and files
{
  const root = fs.mkdtempSync(path.join(os.tmpdir(), 'chownr-contract-1-'));
  try {
    const dirA = path.join(root, 'dirA');
    const dirB = path.join(dirA, 'dirB');
    fs.mkdirSync(dirA);
    fs.mkdirSync(dirB);
    const file1 = path.join(root, 'file1.txt');
    const file2 = path.join(dirA, 'file2.txt');
    const file3 = path.join(dirB, 'file3.txt');
    fs.writeFileSync(file1, 'root file');
    fs.writeFileSync(file2, 'dirA file');
    fs.writeFileSync(file3, 'dirB file');

    chownrSync(root, uid, gid);

    for (const p of [root, dirA, dirB, file1, file2, file3]) {
      const stat = fs.statSync(p);
      assert.strictEqual(stat.uid, uid, `uid mismatch for ${p}`);
      assert.strictEqual(stat.gid, gid, `gid mismatch for ${p}`);
    }
  } finally {
    fs.rmSync(root, { recursive: true, force: true });
  }
}

// Contract 2: chownrSync changes ownership of individual files without error
{
  const root = fs.mkdtempSync(path.join(os.tmpdir(), 'chownr-contract-2-'));
  try {
    const singleFile = path.join(root, 'single.txt');
    fs.writeFileSync(singleFile, 'hello');

    chownrSync(singleFile, uid, gid);

    const stat = fs.statSync(singleFile);
    assert.strictEqual(stat.uid, uid);
    assert.strictEqual(stat.gid, gid);
  } finally {
    fs.rmSync(root, { recursive: true, force: true });
  }
}

// Contract 3: chownrSync modifies symlink ownership using lchown without traversing into the symlink target
{
  const root = fs.mkdtempSync(path.join(os.tmpdir(), 'chownr-contract-3-'));
  try {
    const target = path.join(root, 'target.txt');
    const symlink = path.join(root, 'symlink.txt');
    fs.writeFileSync(target, 'target content');
    fs.symlinkSync(target, symlink);

    chownrSync(root, uid, gid);

    const lstat = fs.lstatSync(symlink);
    assert.strictEqual(lstat.isSymbolicLink(), true);
    assert.strictEqual(lstat.uid, uid);
    assert.strictEqual(lstat.gid, gid);
  } finally {
    fs.rmSync(root, { recursive: true, force: true });
  }
}

// Contract 4: chownrSync handles empty directories without error
{
  const root = fs.mkdtempSync(path.join(os.tmpdir(), 'chownr-contract-4-'));
  try {
    chownrSync(root, uid, gid);
    const stat = fs.statSync(root);
    assert.strictEqual(stat.uid, uid);
    assert.strictEqual(stat.gid, gid);
  } finally {
    fs.rmSync(root, { recursive: true, force: true });
  }
}

// Contract 5: chownrSync ignores non-existent paths (ENOENT) and returns without throwing
{
  const root = fs.mkdtempSync(path.join(os.tmpdir(), 'chownr-contract-5-'));
  try {
    const nonExistent = path.join(root, 'missing-file-or-dir');
    assert.doesNotThrow(() => {
      chownrSync(nonExistent, uid, gid);
    });
  } finally {
    fs.rmSync(root, { recursive: true, force: true });
  }
}

// Contract 6: chownr exports both named chownrSync function and chownr function in CommonJS
{
  assert.strictEqual(typeof chownr.chownrSync, 'function');
  assert.strictEqual(typeof chownr.chownr, 'function');
  assert.strictEqual(typeof chownrSync, 'function');
}

console.log('All chownr.sync contract assertions passed.');

オリジンシーダー

匿名