CodeSampleX

Sample

robots-parser 3.0.1: robotsParser

Verified sample for npm robots-parser 3.0.1: robotsParser. The contract ran on node 22 · linux debian/x64 · docker and passed.

sha256:81f8b1e32cfc286494fa9ab4949156a06d1203a111c28d6da690273b08fb3328

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 linux 24 · ubuntu · glibc 2.39 x64 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-13

Case

HOW
Goal
verify robotsParser in pkg:npm/robots-parser@3.0.1
Packages
Symbols
  • robotsParser
Created
2026-09-13T18:57:06Z

Contract

  1. robotsParser parses robots.txt and determines path allow and disallow permissions for user agents
  2. robotsParser respects crawl-delay directives for specific and wildcard user agents
  3. robotsParser extracts sitemap URLs and preferred host directives
  4. robotsParser returns matching line numbers for directive rules and handles comments and wildcards
  5. robotsParser handles relative URLs and case-insensitive user agent matching

Files

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

Download the source artifact (tar.gz)

Source

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 robotsParser in pkg:npm/robots-parser@3.0.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/robots-parser@3.0.1
Demonstrate these symbols/APIs:
  - robotsParser

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:5a66b1376afdc93951d05e16af1eb5381aff1185ef88b995ded95390f98ed5dd","contract":["robotsParser parses robots.txt and determines path allow and disallow permissions for user agents","robotsParser respects crawl-delay directives for specific and wildcard user agents","robotsParser extracts sitemap URLs and preferred host directives","robotsParser returns matching line numbers for directive rules and handles comments and wildcards","robotsParser handles relative URLs and case-insensitive user agent matching"],"goal":"verify robotsParser in pkg:npm/robots-parser@3.0.1","kind":"HOW","packages":["pkg:npm/robots-parser@3.0.1"],"schemaVersion":1,"symbols":["robotsParser"]},"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/robots-parser@3.0.1"],"schemaVersion":1,"subject":"pkg:npm/robots-parser@3.0.1","symbols":["robotsParser"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "robots-parser-sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "robots-parser-sample",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "robots-parser": "3.0.1"
      }
    },
    "node_modules/robots-parser": {
      "version": "3.0.1",
      "resolved": "https://registry.npmjs.org/robots-parser/-/robots-parser-3.0.1.tgz",
      "integrity": "sha512-s+pyvQeIKIZ0dx5iJiQk1tPLJAWln39+MI5jtM8wnyws+G5azk+dMnMX0qfbqNetKKNgcWWOdi0sfm+FbQbgdQ==",
      "license": "MIT",
      "engines": {
        "node": ">=10.0.0"
      }
    }
  }
}
package.json
{
  "name": "robots-parser-sample",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification for robots-parser",
  "license": "MIT-0",
  "dependencies": {
    "robots-parser": "3.0.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify robotsParser in pkg:npm/robots-parser@3.0.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/robots-parser@3.0.1"
  ],
  "symbols": [
    "robotsParser"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import robotsParser from 'robots-parser';

// 1. robotsParser parses robots.txt and determines path allow and disallow permissions for user agents
const robotsTxt = [
  'User-agent: *',
  'Crawl-delay: 5',
  'Disallow: /admin/',
  'Disallow: /private.html',
  'Allow: /admin/public.html',
  '',
  'User-agent: Googlebot',
  'Crawl-delay: 10',
  'Disallow: /secret/',
  'Allow: /admin/',
  '',
  'Sitemap: https://example.com/sitemap.xml',
  'Sitemap: https://example.com/sitemap-news.xml',
  'Host: example.com'
].join('\n');

const parser = robotsParser('https://example.com/robots.txt', robotsTxt);

// Test allow / disallow for wildcard user agent
assert.equal(parser.isAllowed('https://example.com/admin/public.html', 'CustomBot/1.0'), true);
assert.equal(parser.isDisallowed('https://example.com/admin/public.html', 'CustomBot/1.0'), false);
assert.equal(parser.isAllowed('https://example.com/admin/dashboard', 'CustomBot/1.0'), false);
assert.equal(parser.isDisallowed('https://example.com/admin/dashboard', 'CustomBot/1.0'), true);
assert.equal(parser.isDisallowed('https://example.com/private.html', 'CustomBot/1.0'), true);

// Specific user agent override
assert.equal(parser.isAllowed('https://example.com/admin/dashboard', 'Googlebot'), true);
assert.equal(parser.isDisallowed('https://example.com/secret/doc.html', 'Googlebot'), true);

// 2. robotsParser respects crawl-delay directives for specific and wildcard user agents
assert.equal(parser.getCrawlDelay('CustomBot'), 5);
assert.equal(parser.getCrawlDelay('Googlebot'), 10);

// 3. robotsParser extracts sitemap URLs and preferred host directives
assert.deepEqual(parser.getSitemaps(), [
  'https://example.com/sitemap.xml',
  'https://example.com/sitemap-news.xml'
]);
assert.equal(parser.getPreferredHost(), 'example.com');

// 4. robotsParser returns matching line numbers for directive rules and handles comments and wildcards
const wildcardTxt = [
  '# Global directives',
  'User-agent: *',
  'Disallow: /*.php$',
  'Allow: /index.php'
].join('\n');

const wildcardParser = robotsParser('https://example.com/robots.txt', wildcardTxt);
assert.equal(wildcardParser.isAllowed('https://example.com/index.php', 'Bot'), true);
assert.equal(wildcardParser.getMatchingLineNumber('https://example.com/index.php', 'Bot'), 4);
assert.equal(wildcardParser.isDisallowed('https://example.com/page.php', 'Bot'), true);
assert.equal(wildcardParser.getMatchingLineNumber('https://example.com/page.php', 'Bot'), 3);
assert.equal(wildcardParser.getMatchingLineNumber('https://example.com/other.html', 'Bot'), -1);

// 5. robotsParser handles relative URLs and case-insensitive user agent matching
const relativeTxt = [
  'User-Agent: SpecialBot',
  'Disallow: /hidden/'
].join('\n');

const relativeParser = robotsParser('/robots.txt', relativeTxt);
assert.equal(relativeParser.isDisallowed('/hidden/file', 'specialbot'), true);
assert.equal(relativeParser.isAllowed('/other/file', 'specialbot'), true);

console.log('Contract passed');

Origin Seeder

anonymous