agentsclimarketplace

Parity guard test pattern

Skill fabioc-aloha/Alex_Skill_Mall/plugins/code-quality/parity-guard-test-pattern

284 curated plugins for AI assistants across 16 categories: security, Azure, documentation, code quality, cloud infrastructure, and more. Works with GitHub Copilot. Drop into .github/skills/local/ and go.

Install
npx -y skills add fabioc-aloha/Alex_Skill_Mall --skill parity-guard-test-pattern

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

When checking that all callers of a contract implement it correctly, you get false positives from wrapper delegators:

SKILL.md

2.6 KB, 547 tokens by cl100k_base, as published. Nobody here has run it

Parity Guard Test Pattern

The Problem

When checking that all callers of a contract implement it correctly, you get false positives from wrapper delegators:

// Contract: "All files that call exec() must handle exit code 2"

// Direct caller — MUST implement contract
execFileSync('node', [script]); // Must handle exit code

// Delegator — calls wrapper that already handles contract
runMuscle(script); // runMuscle handles exit code internally

Testing both the same way creates noise.

The Solution

Split tests into DIRECT callers and DELEGATION callers.

// parity-guard.test.js

const directCallers = findFiles((content) => 
  content.includes("child_process") && 
  /exec(File)?Sync|spawn/.test(content)
);

const wrapperCallers = findFiles((content) =>
  /runMuscle|muscleAndPrompt|executeScript/.test(content)
);

describe('Contract: exit code handling', () => {
  describe('Direct callers (must implement)', () => {
    directCallers.forEach(file => {
      it(`${file} handles exit code 2`, () => {
        const content = fs.readFileSync(file, 'utf8');
        expect(content).toMatch(/exitCode|status|code.*===?\s*2/);
      });
    });
  });

  describe('Delegators (exempt — wrapper handles)', () => {
    wrapperCallers.forEach(file => {
      it(`${file} uses contract-compliant wrapper`, () => {
        const content = fs.readFileSync(file, 'utf8');
        // Just verify they use the wrapper, not raw exec
        expect(content).not.toMatch(/execFileSync|execSync/);
      });
    });
  });
});

Classification Rules

PatternCategoryContract Obligation
require('child_process') + exec*DirectMust implement
import { spawn } + spawn()DirectMust implement
runMuscle()DelegatorExempt
shellExecute() (if contract-compliant)DelegatorExempt

Verification

  1. Direct callers all implement the contract
  2. Delegators use compliant wrappers
  3. No false positives from wrapper usage
  4. New callers are automatically classified

When to Apply

  • Any "all X must do Y" contract
  • Error handling requirements
  • Logging requirements
  • Security patterns (sanitization, auth checks)

Tags

quality testing contracts parity

Keep looking

Skills are one crate of 326,970. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.