CodeSampleX

Beispiel

flora-colossus 2.0.0: DepType

Verifiziertes Beispiel für npm flora-colossus 2.0.0: DepType. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.

sha256:e9f0793663d32a92ccc5cb9428a8f7532006ae68d30a1f9de633f3c53ee9eb35

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung linux 24 · ubuntu · glibc 2.39 x64 npm

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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-16

Fall

HOW
Ziel
verify flora-colossus.DepType in pkg:npm/flora-colossus@2.0.0
Pakete
Symbole
  • flora-colossus.DepType
Erstellt
2026-09-16T21:48:19Z

Contract

  1. DepType enum defines numeric values PROD (0), DEV (1), OPTIONAL (2), DEV_OPTIONAL (3), and ROOT (4)
  2. depTypeGreater returns true when newType has higher dependency priority than existing
  3. childDepType resolves child dependency type inherited from parent dependency context
  4. childDepType throws an Error if child dependency type is ROOT

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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 flora-colossus.DepType in pkg:npm/flora-colossus@2.0.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/flora-colossus@2.0.0
Demonstrate these symbols/APIs:
  - flora-colossus.DepType

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:c3eac0fe2609c56bc54e2308621710d524b83829d1cd071c735551bf1c178573","contract":["DepType enum defines numeric values PROD (0), DEV (1), OPTIONAL (2), DEV_OPTIONAL (3), and ROOT (4)","depTypeGreater returns true when newType has higher dependency priority than existing","childDepType resolves child dependency type inherited from parent dependency context","childDepType throws an Error if child dependency type is ROOT"],"goal":"verify flora-colossus.DepType in pkg:npm/flora-colossus@2.0.0","kind":"HOW","packages":["pkg:npm/flora-colossus@2.0.0"],"schemaVersion":1,"symbols":["flora-colossus.DepType"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/flora-colossus@2.0.0"],"schemaVersion":1,"subject":"pkg:npm/flora-colossus@2.0.0","symbols":["flora-colossus.DepType"],"verifierAdapter":"node-typescript@1"}
index.mjs
import floraColossus from 'flora-colossus';

export const { DepType, depTypeGreater, childDepType } = floraColossus;

/**
 * Returns whether newType has greater priority than existing.
 * @param {number} newType
 * @param {number} existing
 * @returns {boolean}
 */
export function isHigherPriority(newType, existing) {
  return depTypeGreater(newType, existing);
}

/**
 * Resolves child dependency type given parent and child types.
 * @param {number} parentType
 * @param {number} childType
 * @returns {number}
 */
export function resolveChildDepType(parentType, childType) {
  return childDepType(parentType, childType);
}

export default {
  DepType,
  depTypeGreater,
  childDepType,
  isHigherPriority,
  resolveChildDepType,
};
package-lock.json
{
  "name": "sample-flora-colossus-deptype",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-flora-colossus-deptype",
      "version": "1.0.0",
      "dependencies": {
        "flora-colossus": "2.0.0"
      }
    },
    "node_modules/debug": {
      "version": "4.4.3",
      "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
      "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
      "license": "MIT",
      "dependencies": {
        "ms": "^2.1.3"
      },
      "engines": {
        "node": ">=6.0"
      },
      "peerDependenciesMeta": {
        "supports-color": {
          "optional": true
        }
      }
    },
    "node_modules/flora-colossus": {
      "version": "2.0.0",
      "resolved": "https://registry.npmjs.org/flora-colossus/-/flora-colossus-2.0.0.tgz",
      "integrity": "sha512-dz4HxH6pOvbUzZpZ/yXhafjbR2I8cenK5xL0KtBFb7U2ADsR+OwXifnxZjij/pZWF775uSCMzWVd+jDik2H2IA==",
      "license": "MIT",
      "dependencies": {
        "debug": "^4.3.4",
        "fs-extra": "^10.1.0"
      },
      "engines": {
        "node": ">= 12"
      }
    },
    "node_modules/fs-extra": {
      "version": "10.1.0",
      "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
      "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==",
      "license": "MIT",
      "dependencies": {
        "graceful-fs": "^4.2.0",
        "jsonfile": "^6.0.1",
        "universalify": "^2.0.0"
      },
      "engines": {
        "node": ">=12"
      }
    },
    "node_modules/graceful-fs": {
      "version": "4.2.11",
      "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
      "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
      "license": "ISC"
    },
    "node_modules/jsonfile": {
      "version": "6.2.1",
      "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz",
      "integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==",
      "license": "MIT",
      "dependencies": {
        "universalify": "^2.0.0"
      },
      "optionalDependencies": {
        "graceful-fs": "^4.1.6"
      }
    },
    "node_modules/ms": {
      "version": "2.1.3",
      "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
      "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
      "license": "MIT"
    },
    "node_modules/universalify": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",
      "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==",
      "license": "MIT",
      "engines": {
        "node": ">= 10.0.0"
      }
    }
  }
}
package.json
{
  "name": "sample-flora-colossus-deptype",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "dependencies": {
    "flora-colossus": "2.0.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify flora-colossus.DepType in pkg:npm/flora-colossus@2.0.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/flora-colossus@2.0.0"
  ],
  "symbols": [
    "flora-colossus.DepType"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { DepType, depTypeGreater, childDepType, isHigherPriority, resolveChildDepType } from '../index.mjs';

// Contract 1: DepType enum defines numeric values PROD (0), DEV (1), OPTIONAL (2), DEV_OPTIONAL (3), and ROOT (4)
{
  assert.equal(DepType.PROD, 0);
  assert.equal(DepType.DEV, 1);
  assert.equal(DepType.OPTIONAL, 2);
  assert.equal(DepType.DEV_OPTIONAL, 3);
  assert.equal(DepType.ROOT, 4);

  // Enum reverse lookup
  assert.equal(DepType[0], 'PROD');
  assert.equal(DepType[1], 'DEV');
  assert.equal(DepType[2], 'OPTIONAL');
  assert.equal(DepType[3], 'DEV_OPTIONAL');
  assert.equal(DepType[4], 'ROOT');
}

// Contract 2: depTypeGreater returns true when newType has higher dependency priority than existing
{
  assert.equal(typeof depTypeGreater, 'function');
  assert.equal(typeof isHigherPriority, 'function');

  // ROOT has highest priority over all other types
  assert.equal(depTypeGreater(DepType.ROOT, DepType.DEV), true);
  assert.equal(depTypeGreater(DepType.ROOT, DepType.OPTIONAL), true);
  assert.equal(depTypeGreater(DepType.ROOT, DepType.PROD), true);
  assert.equal(depTypeGreater(DepType.ROOT, DepType.ROOT), false);

  // PROD has higher priority than OPTIONAL, DEV, DEV_OPTIONAL
  assert.equal(depTypeGreater(DepType.PROD, DepType.DEV), true);
  assert.equal(depTypeGreater(DepType.PROD, DepType.OPTIONAL), true);
  assert.equal(depTypeGreater(DepType.PROD, DepType.DEV_OPTIONAL), true);
  assert.equal(depTypeGreater(DepType.PROD, DepType.PROD), false);

  // OPTIONAL has higher priority than DEV and DEV_OPTIONAL
  assert.equal(depTypeGreater(DepType.OPTIONAL, DepType.DEV), true);
  assert.equal(depTypeGreater(DepType.OPTIONAL, DepType.DEV_OPTIONAL), true);
  assert.equal(depTypeGreater(DepType.OPTIONAL, DepType.OPTIONAL), false);
  assert.equal(depTypeGreater(DepType.OPTIONAL, DepType.PROD), false);

  // DEV does not have higher priority than PROD or OPTIONAL
  assert.equal(depTypeGreater(DepType.DEV, DepType.PROD), false);
  assert.equal(depTypeGreater(DepType.DEV, DepType.OPTIONAL), false);

  // Helper function delegates correctly
  assert.equal(isHigherPriority(DepType.PROD, DepType.DEV), true);
  assert.equal(isHigherPriority(DepType.DEV, DepType.PROD), false);
}

// Contract 3: childDepType resolves child dependency type inherited from parent dependency context
{
  assert.equal(typeof childDepType, 'function');
  assert.equal(typeof resolveChildDepType, 'function');

  // Parent ROOT preserves child's direct type
  assert.equal(childDepType(DepType.ROOT, DepType.PROD), DepType.PROD);
  assert.equal(childDepType(DepType.ROOT, DepType.DEV), DepType.DEV);
  assert.equal(childDepType(DepType.ROOT, DepType.OPTIONAL), DepType.OPTIONAL);
  assert.equal(childDepType(DepType.ROOT, DepType.DEV_OPTIONAL), DepType.DEV_OPTIONAL);

  // Parent PROD
  assert.equal(childDepType(DepType.PROD, DepType.PROD), DepType.PROD);
  assert.equal(childDepType(DepType.PROD, DepType.OPTIONAL), DepType.OPTIONAL);
  assert.equal(childDepType(DepType.PROD, DepType.DEV), DepType.PROD);

  // Parent OPTIONAL stays OPTIONAL
  assert.equal(childDepType(DepType.OPTIONAL, DepType.PROD), DepType.OPTIONAL);
  assert.equal(childDepType(DepType.OPTIONAL, DepType.DEV), DepType.OPTIONAL);
  assert.equal(childDepType(DepType.OPTIONAL, DepType.OPTIONAL), DepType.OPTIONAL);

  // Parent DEV
  assert.equal(childDepType(DepType.DEV, DepType.PROD), DepType.DEV);
  assert.equal(childDepType(DepType.DEV, DepType.OPTIONAL), DepType.DEV_OPTIONAL);
  assert.equal(childDepType(DepType.DEV, DepType.DEV), DepType.DEV);

  // Parent DEV_OPTIONAL stays DEV_OPTIONAL
  assert.equal(childDepType(DepType.DEV_OPTIONAL, DepType.PROD), DepType.DEV_OPTIONAL);
  assert.equal(childDepType(DepType.DEV_OPTIONAL, DepType.DEV), DepType.DEV_OPTIONAL);

  // Helper function delegates correctly
  assert.equal(resolveChildDepType(DepType.ROOT, DepType.PROD), DepType.PROD);
}

// Contract 4: childDepType throws an Error if child dependency type is ROOT
{
  assert.throws(
    () => childDepType(DepType.ROOT, DepType.ROOT),
    (err) => {
      assert(err instanceof Error);
      assert.match(err.message, /Something went wrong, a child dependency can't be marked as the ROOT/);
      return true;
    }
  );

  assert.throws(
    () => childDepType(DepType.PROD, DepType.ROOT),
    (err) => {
      assert(err instanceof Error);
      assert.match(err.message, /Something went wrong, a child dependency can't be marked as the ROOT/);
      return true;
    }
  );

  assert.throws(
    () => resolveChildDepType(DepType.DEV, DepType.ROOT),
    (err) => {
      assert(err instanceof Error);
      assert.match(err.message, /Something went wrong, a child dependency can't be marked as the ROOT/);
      return true;
    }
  );
}

console.log('All flora-colossus.DepType contract assertions passed.');

Ursprungs-Seeder

anonym