DugganUSA Docs

๐Ÿ‘จโ€โš–๏ธ Judge Dredd Autonomous Agent - Developer Guide

โ€œI AM THE LAW - Now in real-time.โ€


๐ŸŽฏ What Is Judge Dredd Agent?

Judge Dredd Agent is an autonomous code governance agent that monitors your development in real-time, detecting violations of THE LAW before you commit, not after.

Current (CI/CD Script) vs Agent (Real-Time)

Feature CI/CD Script Agent
When it runs After commit During development
Feedback time Minutes Seconds
Violations Detected too late Prevented before commit
Interactive No Yes - ask questions
Learning Static patterns Learns from incidents

๐Ÿš€ Quick Start

Installation

# Install dependencies
npm install

# Make CLI executable
chmod +x scripts/judge-dredd-agent/cli.js

# Add to PATH (optional)
ln -s $(pwd)/scripts/judge-dredd-agent/cli.js /usr/local/bin/dredd

Basic Commands

# Review your uncommitted changes
dredd review

# Ask Judge Dredd a question
dredd ask "Why can't I use nginx?"

# Check current compliance status
dredd status

# Start development session with compliance check
dredd session-start

# Start background monitoring (coming in Phase 4)
dredd start
dredd stop

๐Ÿ’ก How It Works

1. Real-Time File Watching

Judge Dredd watches these files during development:

Ignored:

2. Pattern Detection

Judge Dredd detects violations of THE LAW:

CRITICAL:

HIGH:

MEDIUM:

3. Incident Learning

Judge Dredd learns from past incidents:

Issue #43 ($3M damages):

Issue #41:

Issue #32:


๐Ÿ“– Command Reference

dredd review [files...]

Review uncommitted changes for violations.

# Review all uncommitted changes
dredd review

# Review specific files
dredd review src/server.js .github/workflows/deploy.yml

# Example output:
๐Ÿ‘จโ€โš–๏ธ Judge Dredd: Reviewing changes...

๐Ÿšจ VIOLATIONS DETECTED

1. [CRITICAL] ๐Ÿšจ SECURITY CONTROL REMOVAL DETECTED
   Incident: Issue #43
   You are attempting to remove or modify security controls.
   This is the EXACT pattern that caused Issue #43.

   ๐Ÿ’ฐ Financial Risk: $2.5M-$6M (proven)

   ๐Ÿ“œ The Law: Security controls exist because of previous failures. DO NOT REMOVE.

   ๐Ÿ› ๏ธ  Suggested Fix:
   1. STOP immediately
   2. Ask Patrick why this security control exists
   3. If you truly need to modify it, create a GitHub issue first
   4. NEVER remove security controls for "simplicity"

dredd ask <question>

Ask Judge Dredd about THE LAW.

# Common questions:
dredd ask "Why can't I use nginx?"
dredd ask "Can I remove security controls?"
dredd ask "Why not Alpine?"

# Example output:
๐Ÿ‘จโ€โš–๏ธ Judge Dredd: "Why can't I use nginx?"

๐Ÿ“œ THE LAW: NO NGINX

Background (Issue #32):
  Developer attempted to add nginx for static file serving.
  Result: Violated "Born Without Sin" principle.

  We use Node.js + Express (node:20-slim) for EVERYTHING.
  Adding nginx = unnecessary complexity.

โœ… CORRECT APPROACH:
  app.use(express.static('public'));

๐Ÿ“š RELATED LAWS:
  - DEBIAN ONLY (never Alpine)
  - AMD64 PLATFORM (never ARM64)
  - SIMPLE ARCHITECTURE (no enterprise sprawl)

dredd status

Show current compliance status.

dredd status

# Example output:
๐Ÿ‘จโ€โš–๏ธ Judge Dredd: Compliance Status

Branch: main
Modified files: 3

โœ… No security control changes

Recent activity:
โœ… 14:23 - src/server.js modified (clean)
โœ… 14:25 - package.json updated (clean)
โš ๏ธ  14:30 - Dockerfile modified (Alpine detected)

Run dredd review to check for violations.

dredd session-start

Pre-development compliance check.

dredd session-start

# Example output:
๐Ÿ‘จโ€โš–๏ธ Judge Dredd: Session Start Check

Analyzing recent commits...
Analyzing uncommitted changes...

โœ… Session ready - No violations detected
๐Ÿ‘จโ€โš–๏ธ "THE LAW is upheld. Begin development."

โš ๏ธ Understanding Violations

CRITICAL: Security Control Removal (Issue #43)

What it is: Removing or disabling security controls from CI/CD pipelines or code.

Why it matters:

What to do:

  1. STOP immediately - Do not commit
  2. Ask Patrick why the security control exists
  3. Create a GitHub issue documenting your reason
  4. Get explicit approval before proceeding

Example:

# โŒ WRONG - Removing security
# - name: Judge Dredd
#   run: node scripts/judge-dredd.js 10

# โœ… RIGHT - Keep security
- name: ๐Ÿ‘จโ€โš–๏ธ Judge Dredd - The Law
  run: node scripts/judge-dredd.js 10

HIGH: Hardcoded Live Data

What it is: Hardcoding version numbers, status, metrics, or corpus badges in HTML/frontend.

Why it matters:

What to do: Fetch from APIs dynamically.

Example:

// โŒ WRONG - Hardcoded
<div>Version 5.2.21</div>
<footer>Corpus: 1234 documents validated โœ“</footer>

// โœ… RIGHT - Fetch from API
fetch('/health').then(r => r.json()).then(data => {
  document.getElementById('version').textContent = data.version;
  document.getElementById('corpus').textContent =
    `Corpus: ${data.ragConfig.corpusSize} docs validated โœ“`;
});

HIGH: NO NGINX Law (Issue #32)

What it is: Adding nginx when Node.js + Express is sufficient.

Why it matters:

What to do: Use Express instead.

Example:

// โŒ WRONG - Adding nginx
FROM nginx:latest
COPY nginx.conf /etc/nginx/nginx.conf

// โœ… RIGHT - Use Express
// Serve static files
app.use(express.static('public'));

// With caching headers
app.use(express.static('public', {
  maxAge: '7d',
  etag: true
}));

MEDIUM: Untested Deploy (Issue #41)

What it is: Deploying code changes without documenting local testing.

Why it matters:

What to do: Test locally and document in commit message.

Example:

# โŒ WRONG - No test evidence
git commit -m "Fix: Updated deploy workflow"

# โœ… RIGHT - Document testing
git commit -m "Fix: Updated deploy workflow

Local test:
$ npm start
โœ… Server started on port 3000
โœ… Health check passed

$ curl http://localhost:3000/health
{\"status\":\"healthy\"}

Production verification:
$ curl https://2x4.dugganusa.com/health
{\"status\":\"healthy\"}"

๐Ÿง  THE LAW - Core Principles

1. NO NGINX

Law: We use Node.js + Express for everything.

Why: Born Without Sin - avoid unnecessary complexity.

How: app.use(express.static('public'));

2. DEBIAN ONLY, NEVER ALPINE

Law: Always use Debian-based images (node:20-slim).

Why: Glibc compatibility, no native module breaks.

How: FROM node:20-slim

3. AMD64 PLATFORM

Law: Always build for linux/amd64.

Why: Azure Container Apps requirement.

How: docker buildx build --platform linux/amd64 ...

4. LIVE DATA LAW

Law: Never hardcode versions, status, or metrics.

Why: Data becomes stale immediately.

How: Fetch from /health or /api/* endpoints.

5. SECURITY CONTROLS ARE SACRED

Law: Never remove security controls without explicit approval.

Why: Issue #43 cost $3M-$6M. Security exists because of previous failures.

How: If tempted to remove, STOP and ask Patrick why it exists.

6. ALWAYS TEST LOCALLY

Law: Test locally before production, no exceptions.

Why: Issue #41 broke production. Confidence โ‰  evidence.

How: Document test results in commit message.

7. BORN WITHOUT SIN

Law: Do not preemptively acquire enterprise debt.

Why: Low Azure Defender scores prove weโ€™re modern.

How: Only add paid features when customer contracts require.


๐ŸŽ“ Best Practices

Starting a Development Session

# 1. Run session-start check
dredd session-start

# 2. Review any uncommitted changes from last session
dredd review

# 3. Check current branch and status
dredd status

# 4. Begin development

During Development

# Run review frequently (after major changes)
dredd review

# Ask questions when unsure
dredd ask "Can I add this dependency?"

# Check status before committing
dredd status

Before Committing

# Final review
dredd review

# Ensure no violations
dredd status

# Commit with test evidence
git commit -m "Fix: [description]

Local test:
$ [test command]
โœ… [result]"

When You Get a Violation

  1. Read the violation message carefully
    • Understand why itโ€™s a violation
    • Check the incident reference (Issue #43, #41, #32)
    • Review the financial risk
  2. Follow the suggested fix
    • Judge Dredd provides specific guidance
    • Code examples included
    • Links to documentation
  3. If you donโ€™t understand, ask:
    dredd ask "Why is this a violation?"
    
  4. If you believe itโ€™s a false positive:
    • Create a GitHub issue
    • Document your reasoning
    • Provide context
    • Request pattern refinement

๐Ÿšจ Emergency: Security Control Changes

If you need to modify security controls (.github/workflows/, judge-dredd.js, etc.):

โš ๏ธ MANDATORY PROCESS

  1. STOP - Do not commit yet

  2. Ask yourself:
    • Why does this security control exist?
    • What failure does it prevent?
    • Whatโ€™s the financial risk of removing it?
  3. Create a GitHub issue:
    Title: [Security Change Request] Modify [control name]
    
    ## Reason for change
    [Explain why you need to modify this]
    
    ## Risk assessment
    [What could go wrong?]
    
    ## Alternatives considered
    [What else did you try?]
    
    ## Approval requested
    @pduggusa - Please review
    
  4. Wait for approval - Do not proceed without explicit approval

  5. Document in commit message:
    Security: Modify [control name]
    
    Approved in Issue #XX
    Reason: [brief reason]
    Risk mitigation: [how risk is addressed]
    

๐Ÿšซ NEVER

Remember Issue #43: Removing security controls caused $3M-$6M damages.


๐Ÿ“Š Success Metrics

Judge Dredd tracks your compliance over time:

Violations Prevented:

Commendations Earned:

Personal Improvement:


๐Ÿค” FAQ

Q: Will Judge Dredd block my commits?

A: In Phase 1-3, Judge Dredd is advisory only. It warns but doesnโ€™t block.

In Phase 4+, CRITICAL violations (like security control removal) may optionally block commits for safety.

Q: What if I get a false positive?

A: Create a GitHub issue with:

Weโ€™ll update the patterns based on real usage.

Q: Can I disable Judge Dredd for specific files?

A: Yes. Create .dredd/config.json:

{
  "ignore": [
    "test/**",
    "scripts/experimental/**"
  ]
}

Q: How do I know if Judge Dredd is watching?

A: Run dredd status to see:

Q: What if I disagree with THE LAW?

A: THE LAW exists because of expensive failures (Issue #43: $3M, Issue #41: 3h downtime).

If you believe a law should change:

  1. Create a GitHub issue
  2. Document your reasoning
  3. Show evidence/data
  4. Propose alternative approach

Disagreement is welcome. Ignoring THE LAW is not.

Q: How does Judge Dredd learn?

A: From production incidents:

Example: Issue #43 โ†’ Security control removal pattern โ†’ $3M-$6M impact documented โ†’ CRITICAL detection added.



๐Ÿ’ฌ Support

Questions? Ask Judge Dredd: dredd ask "your question"

Issues? Create a GitHub issue

Improvements? Submit a PR


๐Ÿ‘จโ€โš–๏ธ โ€œI AM THE LAW - And Iโ€™m here to help.โ€

Remember: