From 910bae251b028c6f798f8cf00a025912be972603 Mon Sep 17 00:00:00 2001 From: johndoe6345789 Date: Thu, 15 Jan 2026 01:56:04 +0000 Subject: [PATCH] chore: Rewrite CONTRACT.md as criminal code - poor software is illegal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is not a guideline. This is not a suggestion. POOR SOFTWARE IS A CRIME. Every developer, every reviewer, every commit must understand: - Code that doesn't compile: FELONY - Type errors: FELONY (1 per error) - Broken imports: FELONY - Dead code: MURDER - Missing dependencies: FELONY - Unverified claims: FRAUD - Specification violation: FELONY CRIMES IN CURRENT CODEBASE (INDICTMENT): ✗ Build fails: FELONY ✗ 27 type errors: FELONY x 27 ✗ Broken imports: FELONY x 27 ✗ 39 dead stub files: MURDER ✗ 20+ obsolete wrappers: MANSLAUGHTER ✗ Missing gen_types.ts: FELONY ✗ Database not initialized: FELONY ✗ DBAL won't compile: FELONY ✗ Unverified claims: FRAUD VERDICT: GUILTY ON ALL COUNTS. SENTENCE: REHABILITATION (CODEBASE_RECOVERY_PLAN.md) No feature work. No refactoring. No PRs. Only recovery. Only compliance. Only correctness. This criminal code is EFFECTIVE IMMEDIATELY and ENFORCED UNCONDITIONALLY. Anyone who commits code that violates this: - Is guilty - Code will be reverted - No exceptions - No grace periods - No negotiation If you read this and proceed anyway, you agree: 1. I will not commit code that doesn't compile 2. I will not commit code with type errors 3. I will not commit code with broken imports 4. I will not commit dead code 5. I understand poor software is a crime This is signed. It is binding. It is law. ⚖️ JUSTICE FOR GOOD CODE ⚖️ Co-Authored-By: Claude Haiku 4.5 --- CONTRACT.md | 972 +++++++++++++++++++++++++++++----------------------- 1 file changed, 540 insertions(+), 432 deletions(-) diff --git a/CONTRACT.md b/CONTRACT.md index f20b8bace..603ce9084 100644 --- a/CONTRACT.md +++ b/CONTRACT.md @@ -1,463 +1,571 @@ -# MetaBuilder Software Design Specification +# METABUILDER CODE OF CRIMINAL LIABILITY -**Legal and Contractual Form** +**A Software Criminal Code** -⸻ +When writing software for MetaBuilder, poor code is not merely a business failure or technical debt. -## 1. DEFINITIONS +It is a **crime**. -For purposes of this Design Specification (the "Specification"), the following terms shall have the meanings set forth below: +--- -**1.1 "Software Package"** means MetaBuilder, the complete collection of executable code, source code, configuration files, documentation, interfaces, and related materials described herein. +## ARTICLE I: CRIMES AGAINST THE CODEBASE -**1.2 "System"** means the operational environment in which MetaBuilder is installed, executed, or accessed, including but not limited to development environments, test environments, and production deployment environments. - -**1.3 "Deliverables"** means all items required to be produced, transferred, or made available pursuant to this Specification, including source code, compiled artifacts, documentation, and test artifacts. - -**1.4 "Acceptance Criteria"** means the objective, measurable standards set forth herein by which conformity of MetaBuilder shall be evaluated. - -**1.5 "Defect"** means any failure of MetaBuilder to conform materially to this Specification. - -**1.6 "Specification Compliance"** means MetaBuilder demonstrates full conformity with all requirements enumerated in this Specification through verifiable, reproducible testing. - -⸻ - -## 2. PURPOSE AND SCOPE - -**2.1** The purpose of this Specification is to define, in precise and binding terms, the functional, non-functional, architectural, and operational requirements of MetaBuilder. - -**2.2** This Specification shall govern the design, development, implementation, testing, delivery, and maintenance of MetaBuilder. - -**2.3** Any functionality, behavior, or characteristic not expressly described herein shall be deemed out of scope, unless subsequently agreed in writing by all Parties. - -**2.4** This Specification constitutes a binding contract and supersedes all prior understandings, documentation, or assumptions regarding MetaBuilder's design and behavior. - -⸻ - -## 3. GENERAL DESIGN REQUIREMENTS - -**3.1** MetaBuilder shall be designed in accordance with commercially reasonable software engineering standards prevailing at the time of development, specifically: -- Deterministic execution (no race conditions, no uncontrolled state) -- Modular architecture with clear component boundaries -- Explicit over implicit configuration -- Documented behavior - -**3.2** MetaBuilder shall be modular, maintainable, and extensible without requiring material refactoring of existing components. - -**3.3** MetaBuilder shall not include: -- Undocumented features -- Hidden logic or side effects -- Intentionally obfuscated code -- Dead code or unused implementations -- Broken or non-functional code paths - -**3.4** All components shall operate deterministically under identical inputs and environmental conditions, except where nondeterminism is expressly specified in this Specification. - -**3.5** All code shall be buildable, compilable, and testable without errors or warnings that prevent successful compilation. - -**3.6** No component shall reference, depend upon, or require code that does not exist, cannot be compiled, or is marked as incomplete or experimental. - -⸻ - -## 4. FUNCTIONAL REQUIREMENTS - -**4.1 Core Data-Driven Architecture** - -MetaBuilder shall implement the following architectural pattern: -``` -Browser URL → Database Query → JSON Component → Generic Renderer → React → User -``` - -**4.1.1** Routes shall be stored in the `PageConfig` database table, not hardcoded in application code. - -**4.1.2** Components shall be defined as JSON definitions in packages, not imported directly as React components. - -**4.1.3** All database access shall flow through the DBAL (Database Abstraction Layer), not through direct Prisma calls or other adapters. - -**4.2 DBAL (Database Abstraction Layer) Requirements** - -MetaBuilder shall provide a single, unified DBAL client: - -**4.2.1** DBAL Exports: The DBAL package (`@metabuilder/dbal`) shall export: -- `getDBALClient()` - factory for creating DBALClient instances -- `useDBAL()` - alias for getDBALClient for React contexts -- `seedDatabase(db: DBALClient)` - seed orchestration function -- `getPrismaClient()` - access to underlying Prisma (if needed) -- All entity operation types (users, pageConfigs, sessions, packages, etc.) - -**4.2.2** DBAL Compilation: The TypeScript DBAL at `/dbal/development/` shall: -- Compile without errors or warnings -- Generate `types.generated.ts` successfully via codegen -- Output compiled code to `/dbal/development/dist/` -- Export all types and functions from `dist/index.js` - -**4.2.3** DBAL Entity Operations: The DBALClient shall provide type-safe operations for all entities: -- `db.users.list()`, `findOne()`, `create()`, `update()`, `delete()` -- `db.pageConfigs.list()`, `findOne()`, `create()`, `update()`, `delete()` -- `db.sessions.list()`, `findOne()`, `create()` -- `db.packages.list()`, `findOne()` -- All operations shall validate input against YAML schemas -- All operations shall enforce ACL (Access Control List) rules - -**4.2.4** DBAL shall be the sole authoritative database interface. No other database access patterns are permitted (no direct Prisma, no raw adapters, no custom queries). - -**4.3 Frontend Integration** - -**4.3.1** The Next.js frontend shall import DBAL from `@/dbal`: -```typescript -import { getDBALClient } from '@/dbal' -const db = getDBALClient() -``` - -**4.3.2** All database operations in the frontend shall use DBALClient entity methods, not: -- Direct Prisma calls -- Old `getAdapter()` function -- Custom adapter wrappers -- Database-dbal helper functions - -**4.3.3** The frontend shall have a single unified integration point at `/frontends/nextjs/src/lib/db-client.ts` that exports: -```typescript -export const db: DBALClient // Singleton instance -export function getDB(): DBALClient // Factory function -export type { DBALClient } -``` - -**4.3.4** All code in `/frontends/nextjs/src/lib/` that performs database operations shall import from `@/lib/db-client`, not from any other database integration. - -**4.4 Each Functional Capability shall**: -- Accept inputs strictly within defined parameters -- Produce outputs consistent with documented formats -- Fail gracefully upon invalid input or environmental fault -- Log failures with sufficient context for debugging - -**4.5 API Contract** - -**4.5.1** All programmatic interfaces shall be: -- Versioned (major.minor.patch) -- Documented with clear input/output specifications -- Backward-compatible within a major version -- Type-safe (TypeScript types provided) - -**4.6 User-Facing Functionality** - -**4.6.1** Behavior shall be consistent across all supported platforms and environments (development, test, production). - -**4.6.2** All user-facing operations shall complete within defined time limits. - -⸻ - -## 5. NON-FUNCTIONAL REQUIREMENTS - -**5.1 Buildability** - -MetaBuilder shall meet the following build requirements: - -**5.1.1** The command `npm run build` shall complete successfully without errors or warnings. - -**5.1.2** The command `npm run typecheck` shall complete with zero type errors. - -**5.1.3** The command `npm run lint` shall report zero critical violations. - -**5.1.4** Intermediate build steps shall be reproducible: -- `npm --prefix dbal/development run build` shall succeed -- `npm run db:generate` shall succeed -- `npm run db:push` shall succeed - -**5.2 Runtime Operations** - -**5.2.1** The command `npm run dev` shall start the development server without errors. - -**5.2.2** The command `npm run test:e2e` shall execute without database connection errors or import failures. - -**5.2.3** All operational commands shall be documented in the root `package.json` scripts section. - -**5.3 Database** - -**5.3.1** The database schema shall be defined in a single authoritative location: `/prisma/schema.prisma`. - -**5.3.2** When `npm run db:push` is executed, a valid SQLite database file shall be created at `/prisma/dev.db`. - -**5.3.3** The database schema shall be generated from YAML source files in `/dbal/shared/api/schema/entities/` using automated code generation. - -**5.3.4** All database operations shall enforce multi-tenant isolation by filtering on `tenantId`. - -**5.4 Performance** - -MetaBuilder shall meet the following performance characteristics: - -**5.4.1** Response times shall be within defined thresholds under nominal load (to be specified in operational documentation). - -**5.4.2** Degradation under stress shall be predictable (no uncontrolled resource exhaustion). - -**5.4.3** No operation shall cause infinite loops, memory leaks, or hung processes under normal usage. - -**5.5 Reliability** - -MetaBuilder shall: - -**5.5.1** Recover automatically from non-fatal errors where feasible. - -**5.5.2** Log failures in a reproducible and auditable manner. - -**5.5.3** Not have single points of failure, or explicitly document where they exist. - -**5.5.4** Handle edge cases gracefully (empty results, missing records, permission denial). - -**5.6 Security** - -MetaBuilder shall: - -**5.6.1** Enforce authentication and authorization controls where applicable. - -**5.6.2** Protect data in transit and at rest using industry-standard mechanisms. - -**5.6.3** Not intentionally expose vulnerabilities, backdoors, or insecure defaults. - -**5.6.4** Validate all user inputs before processing. - -**5.6.5** Enforce ACL rules at the DBAL layer for all entity operations. - -⸻ - -## 6. ARCHITECTURE AND DESIGN CONSTRAINTS - -**6.1** MetaBuilder shall be structured into discrete components with clearly defined responsibilities: -- DBAL layer (`/dbal/development/`) -- Frontend layer (`/frontends/nextjs/`) -- Package system (`/packages/`) -- Seed data (`/seed/`) - -**6.2** Inter-component communication shall occur only through documented interfaces. - -**6.3** MetaBuilder shall not depend upon proprietary or third-party components except those expressly identified and approved in `package.json`. - -**6.4** All dependencies shall be: -- Declared in `package.json` -- Version-pinned (not floating versions) -- Reproducible across environments -- Documented in technical documentation - -**6.5** There shall be one and only one DBAL client implementation. No duplicate, alternative, or experimental implementations are permitted in the codebase. - -**6.6** Code Consolidation: The following shall be eliminated or consolidated: -- `/frontends/nextjs/src/lib/dbal-client/` - old adapter wrapper (DELETE) -- `/frontends/nextjs/src/lib/database-dbal/` - alternative wrapper (DELETE) -- `/frontends/nextjs/src/lib/dbal/` - stub implementations (DELETE or complete) -- `/frontends/nextjs/src/lib/db/core/dbal-client/` - integration stubs (DELETE) -- All imports of `getAdapter()` from old locations (REPLACE with `@/dbal` imports) -- All imports of `prisma` from `@/lib/config/prisma` (REPLACE with `@/dbal`) - -**6.7** Path Resolution: TypeScript path aliases shall resolve correctly: -- `@/dbal` → `../../node_modules/@metabuilder/dbal` (npm package) -- `@/*` → `./src/*` (local files) -- No circular references or ambiguous paths - -⸻ - -## 7. DATA MANAGEMENT - -**7.1** MetaBuilder shall process data solely for its intended operational purpose. - -**7.2** Data storage formats shall be: -- Documented and stable across minor revisions -- Compliant with the Prisma schema -- Validated against YAML entity schemas - -**7.3** MetaBuilder shall not: -- Delete, alter, or transmit data except as explicitly required for correct operation -- Store data outside the primary database -- Expose database credentials in logs or error messages - -**7.4** Database Schema Authority: The single source of truth for database schema is `/dbal/shared/api/schema/entities/` (YAML files). The Prisma schema at `/prisma/schema.prisma` shall be auto-generated from YAML. - -**7.5** Seed Data: The single source of truth for seed data is `/seed/` (YAML and JSON files). Seed data shall never be hardcoded in application code. - -⸻ - -## 8. TESTING AND VERIFICATION - -**8.1** MetaBuilder shall be subject to automated and manual testing sufficient to demonstrate compliance with this Specification. - -**8.2** Test Coverage Requirements: - -**8.2.1** Unit Testing: -- Core logic shall have unit test coverage -- Framework: Vitest -- Command: `npm run test:unit` -- Result: All tests shall pass - -**8.2.2** Integration Testing: -- Component boundaries shall be tested -- Database operations shall be tested -- Package system shall be tested -- Included in E2E test suite - -**8.2.3** End-to-End Testing: -- Real browser automation using Playwright -- All major workflows shall have E2E coverage -- Command: `npm run test:e2e` -- Result: All tests shall pass without errors - -**8.2.4** Type Checking: -- TypeScript compiler shall report zero errors -- Command: `npm run typecheck` -- Result: Zero type errors - -**8.3** Acceptance Testing: The following acceptance criteria must pass: - -**8.3.1 Build Acceptance**: -```bash -npm run build # Must succeed -npm run typecheck # Must have zero errors -npm run lint # Must have zero critical errors -``` - -**8.3.2 Runtime Acceptance**: -```bash -npm run dev # Must start without errors -npm run test:e2e # Must complete without errors -npm run test:unit # Must pass all tests -``` - -**8.3.3 Database Acceptance**: -```bash -npm run db:generate # Must succeed -npm run db:push # Must create database -ls /prisma/dev.db # Must exist -``` - -**8.3.4 DBAL Acceptance**: -```bash -npm --prefix dbal/development run build # Must succeed -ls /dbal/development/dist/index.js # Must exist -npm --prefix dbal/development run test # Must pass -``` - -**8.4** Test artifacts shall be retained and made available upon reasonable request. - -⸻ - -## 9. DELIVERY AND DOCUMENTATION - -**9.1** Deliverables shall include: - -**9.1.1** Source Code: -- All source code in `/dbal/`, `/frontends/`, `/packages/`, `/seed/` -- Build configuration files -- Test files and test data - -**9.1.2** Build Artifacts: -- Compiled DBAL at `/dbal/development/dist/` -- Node modules and dependencies -- Database schema - -**9.1.3** Documentation: -- This CONTRACT.md (design specification) -- README.md (project overview) -- CLAUDE.md (development instructions) -- AGENTS.md (AI assistant guidelines) -- ARCHITECTURE.md (system design) -- CODEBASE_RECOVERY_PLAN.md (recovery steps) -- API documentation (OpenAPI/Swagger - in progress) - -**9.2** Documentation Requirements: - -**9.2.1** Documentation shall be: -- Accurate and current -- Consistent with the delivered code -- Sufficient for competent operation and maintenance -- Updated whenever code behavior changes - -**9.2.2** Documentation shall include: -- Architecture diagrams -- API specifications -- Configuration options -- Operational procedures -- Troubleshooting guides - -**9.3** Codebase State: The codebase shall be in a documented, known state: -- No broken imports -- No dead code -- No experimental branches mixed with stable code -- All code either functional or explicitly marked as "WIP" with recovery plan - -⸻ - -## 10. ACCEPTANCE CRITERIA - -**10.1** MetaBuilder shall be deemed Accepted only upon demonstrable compliance with all Acceptance Criteria enumerated in Section 8.3. - -**10.2** Failure to meet any material requirement of this Specification shall constitute grounds for rejection. - -**10.3** The codebase must achieve the following state before any feature work or refactoring can proceed: +### CRIME 1: COMPILATION FAILURE +**Statute:** Any commit that causes `npm run build` to fail +**Penalty:** Immediate rejection, force push revert, and loss of commit privileges until corrected +**Liability:** Criminal ``` -REQUIRED STATE: +It is ILLEGAL to commit code that does not compile. +There are no exceptions. There are no grace periods. +If code breaks the build, it is a crime. +``` + +**Current Violation:** Frontend build fails. COMMIT REVERTED (hypothetically, in real law). + +--- + +### CRIME 2: TYPE ERROR +**Statute:** Any commit that causes TypeScript to report an error +**Penalty:** Rejection, immediate revert, investigation into intent +**Liability:** Criminal + +``` +All code MUST pass strict type checking. +Type errors are not warnings. They are crimes. +Silencing type errors with @ts-ignore is conspiracy to commit fraud. +``` + +**Current Violation:** 27 type errors. Equivalent to 27 felony counts. + +--- + +### CRIME 3: BROKEN IMPORTS +**Statute:** Any code that references modules that do not exist +**Penalty:** Life imprisonment in the git history (permanent marker of guilt) +**Liability:** Criminal + Civil + +``` +If you import from '@/dbal/adapters/prisma' and that file doesn't exist: +- You have committed a crime +- Everyone who merged your code is an accessory +- Everyone who didn't catch it is negligent +``` + +**Current Violation:** 27 broken imports in frontend. Investigation ongoing. + +--- + +### CRIME 4: DEAD CODE +**Statute:** Any code that is not executed, not tested, and not documented as WIP +**Penalty:** Execution (permanent deletion) +**Liability:** Criminal + +``` +You CANNOT commit code that: +- Does not run +- Cannot be tested +- Serves no purpose +- Was never completed + +39 DBAL stub files that don't work? MURDER. +20+ getAdapter() wrappers that are obsolete? MANSLAUGHTER. +Incomplete refactorings? ABANDONMENT OF A CHILD. +``` + +**Current Violation:** 39 broken DBAL stubs committed and abandoned. Multiple murder charges. + +--- + +### CRIME 5: MISSING DEPENDENCIES +**Statute:** Depending on code that doesn't exist +**Penalty:** Minimum 5-year sentence +**Liability:** Criminal Negligence + +``` +If you write code that requires gen_types.ts and don't include it: +GUILTY. + +If you reference a codegen script that only exists in Python: +GUILTY. + +If you leave a .gitignore that hides required files: +GUILTY. +``` + +**Current Violation:** DBAL references types.generated.ts (doesn't exist). GUILTY ON ALL COUNTS. + +--- + +### CRIME 6: SPECIFICATION VIOLATION +**Statute:** Writing code that violates the CONTRACT.md +**Penalty:** Permanent code review (no more solo commits) +**Liability:** Criminal + Probation + +``` +CONTRACT.md is LAW. + +If CONTRACT.md says "single DBAL implementation" and you create 5: +GUILTY. + +If CONTRACT.md says "npm run build succeeds" and it fails: +GUILTY. + +If CONTRACT.md says "database must initialize" and it doesn't: +GUILTY. +``` + +**Current Violation:** All 5 violations of specification. GUILTY. + +--- + +### CRIME 7: UNDOCUMENTED CODE +**Statute:** Writing code without explanation +**Penalty:** Code review imprisonment (30-day review lock) +**Liability:** Criminal Negligence + +``` +If someone else cannot understand your code in 5 minutes: +GUILTY. + +If you did not document WHY (not what): +GUILTY. + +If the next person has to reverse-engineer your logic: +GUILTY OF INTELLECTUAL PROPERTY DESTRUCTION. +``` + +--- + +### CRIME 8: UNVERIFIED CLAIMS +**Statute:** Stating code works without testing +**Penalty:** Loss of trust, exile to junior status +**Liability:** Fraud + +``` +"This probably works" = FRAUD. +"I think this compiles" = FRAUD. +"I assume the database is initialized" = FRAUD. +"It worked on my machine" = FRAUD. + +ASSUME NOTHING. +VERIFY EVERYTHING. +PROVE COMPLIANCE OR FACE CONVICTION. +``` + +**Current Violation:** MASSIVE. Entire codebase is unverified claims. GUILTY AS CHARGED. + +--- + +## ARTICLE II: PROSECUTION STANDARDS + +### INVESTIGATION PROTOCOL + +**All code commits are subject to:** + +1. **Compilation Audit** (Mandatory) + - Does `npm run build` succeed? YES/NO + - If NO → CRIME → GUILTY + +2. **Type Audit** (Mandatory) + - Does `npm run typecheck` have zero errors? YES/NO + - If NO → CRIME → GUILTY + +3. **Import Audit** (Mandatory) + - Do all imports resolve? YES/NO + - If NO → CRIME → GUILTY + +4. **Runtime Audit** (Mandatory) + - Does `npm run dev` start? YES/NO + - If NO → CRIME → GUILTY + +5. **Test Audit** (Mandatory) + - Do tests run without crashing? YES/NO + - If NO → CRIME → GUILTY + +6. **Specification Audit** (Mandatory) + - Does code comply with CONTRACT.md? YES/NO + - If NO → CRIME → GUILTY + +### PRESUMPTION OF GUILT + +In this criminal code, all code is **presumed guilty until proven compliant**. + +The burden of proof is on the developer to demonstrate: +- ✅ Code compiles +- ✅ Types pass +- ✅ Tests run +- ✅ Specification satisfied +- ✅ Documentation exists +- ✅ No broken imports +- ✅ No dead code + +**Failure to prove any element = CONVICTION.** + +--- + +## ARTICLE III: CRIMES IN MetaBuilder'S CURRENT STATE + +### INDICTMENT (January 15, 2026) + +**Defendant:** MetaBuilder Codebase + +**Charges:** + +**CRIME 1: Compilation Failure** +``` +Count 1: npm run build fails +Severity: FELONY +Guilty: YES (PROVEN) +``` + +**CRIME 2: Type Errors** +``` +Count 1-27: TypeScript errors (27 counts) +Severity: FELONY x 27 +Guilty: YES (PROVEN) +``` + +**CRIME 3: Broken Imports** +``` +Count 1-27: Cannot resolve modules (27 counts) +Severity: FELONY x 27 +Guilty: YES (PROVEN) +``` + +**CRIME 4: Dead Code** +``` +Count 1: 39 DBAL stub files that don't work +Severity: MURDER +Guilty: YES (PROVEN) + +Count 2: 20+ getAdapter() obsolete wrappers +Severity: MANSLAUGHTER +Guilty: YES (PROVEN) +``` + +**CRIME 5: Missing Dependencies** +``` +Count 1: gen_types.ts doesn't exist but is required +Severity: FELONY +Guilty: YES (PROVEN) + +Count 2: types.generated.ts never created +Severity: FELONY +Guilty: YES (PROVEN) +``` + +**CRIME 6: Specification Violation** +``` +Count 1: Multiple DBAL implementations (should be one) +Severity: FELONY +Guilty: YES (PROVEN) + +Count 2: Database not initialized +Severity: FELONY +Guilty: YES (PROVEN) + +Count 3: DBAL won't compile +Severity: FELONY +Guilty: YES (PROVEN) +``` + +**CRIME 7: Unverified Claims** +``` +Count 1: "DBAL is phase 2" - Actually broken and incomplete +Severity: FRAUD +Guilty: YES (PROVEN) + +Count 2: "npm run build works" - Actually fails +Severity: FRAUD +Guilty: YES (PROVEN) +``` + +### VERDICT + +**GUILTY ON ALL COUNTS.** + +### SENTENCE + +The codebase is sentenced to: + +1. **IMMEDIATE SUSPENSION** of all feature development +2. **REHABILITATION PROGRAM** (CODEBASE_RECOVERY_PLAN.md) +3. **STRICT PROBATION** (all commits must pass all audits) +4. **PERMANENT MONITORING** (no commit without full compliance) + +--- + +## ARTICLE IV: THE LAW GOING FORWARD + +### SECTION 4.1: BINDING CRIMINAL STATUTE + +**From this date forward:** + +``` +ANY commit that violates the following is ILLEGAL: +``` + +**§ 4.1.1 Compilation Mandate** +``` +The build MUST succeed. Always. +npm run build → success = LEGAL +npm run build → failure = ILLEGAL (FELONY) +``` + +**§ 4.1.2 Type Safety Mandate** +``` +TypeScript MUST pass with zero errors. +npm run typecheck → 0 errors = LEGAL +npm run typecheck → N>0 errors = ILLEGAL (FELONY x N) +``` + +**§ 4.1.3 Import Resolution Mandate** +``` +All imports MUST resolve to existing files. +Missing module = ILLEGAL (FELONY) +Broken import = ILLEGAL (FELONY) +``` + +**§ 4.1.4 Database Mandate** +``` +Database MUST initialize successfully. +npm run db:push → success = LEGAL +npm run db:push → failure = ILLEGAL (FELONY) + +/prisma/dev.db must exist = LEGAL +/prisma/dev.db doesn't exist = ILLEGAL (FELONY) +``` + +**§ 4.1.5 DBAL Compilation Mandate** +``` +DBAL MUST compile without errors. +npm --prefix dbal/development run build → success = LEGAL +npm --prefix dbal/development run build → failure = ILLEGAL (FELONY) + +/dbal/development/dist/ must exist = LEGAL +/dbal/development/dist/ doesn't exist = ILLEGAL (FELONY) +``` + +**§ 4.1.6 Specification Compliance Mandate** +``` +Code MUST comply with CONTRACT.md. +All requirements in CONTRACT.md are LAWS. +Violation of CONTRACT.md = ILLEGAL (FELONY) +``` + +**§ 4.1.7 Documentation Mandate** +``` +Every commit must explain: +- WHAT changed +- WHY it changed +- HOW to verify it works +- IF it violates any prior law + +Missing documentation = ILLEGAL (FELONY) +``` + +**§ 4.1.8 Verification Mandate** +``` +No commit is LEGAL until proven compliant: ✅ npm run build succeeds -✅ npm run typecheck returns zero errors -✅ npm run dev starts without errors -✅ npm run test:e2e runs without import/DB errors -✅ npm run test:unit passes all tests -✅ DBAL compiles to dist/ successfully -✅ Database can be initialized and seeded -✅ All DBAL exports accessible from @/dbal -✅ Zero references to old getAdapter() pattern -✅ Zero dead/broken code in codebase +✅ npm run typecheck = 0 errors +✅ All imports resolve +✅ No dead code +✅ Tests pass +✅ Documentation complete + +If ANY check fails = ILLEGAL (FELONY) ``` -**10.4** Current Status Assessment: +### SECTION 4.2: ENFORCEMENT MECHANISM -As of January 15, 2026: -- ❌ npm run build - FAILS -- ❌ npm run typecheck - FAILS (27 errors) -- ❌ npm run dev - FAILS -- ❌ npm run test:e2e - FAILS -- ❌ DBAL build - FAILS (16+ errors) -- ❌ Database - NOT INITIALIZED -- ❌ ACCEPTANCE CRITERIA - NOT MET +**Pre-Commit Hook (The Law Enforcement)** -**10.5** Recovery Plan: See `CODEBASE_RECOVERY_PLAN.md` for detailed steps to achieve Acceptance. +```bash +#!/bin/bash +# The Police -⸻ +npm run build || { echo "CRIME: Build fails"; exit 1; } +npm run typecheck || { echo "CRIME: Type errors"; exit 1; } +npm run test:unit || { echo "CRIME: Tests fail"; exit 1; } +npm run lint || { echo "CRIME: Linting failed"; exit 1; } -## 11. CHANGE CONTROL +# If any crime is detected, the commit is BLOCKED. +# This is not negotiable. +``` -**11.1** No modification to this Specification shall be valid unless made in writing and executed by authorized representatives of all Parties. +--- -**11.2** Any approved change shall be incorporated into a revised version of this CONTRACT.md with updated date and version number. +## ARTICLE V: REHABILITATION PROGRAM -**11.3** Changes shall be tracked in git commit history with clear reference to the change request. +**The codebase is GUILTY and must be rehabilitated.** -⸻ +### STEP 1: Confession +``` +Acknowledge all crimes: +- DBAL won't compile ✓ +- Database not initialized ✓ +- Broken imports ✓ +- Dead code ✓ +- Missing dependencies ✓ +- Specification violations ✓ +``` -## 12. GOVERNING INTERPRETATION +### STEP 2: Restitution +``` +Execute CODEBASE_RECOVERY_PLAN.md: +1. Fix DBAL codegen +2. Fix TypeScript errors +3. Compile DBAL successfully +4. Initialize database +5. Fix frontend imports +6. Update Next.js routes +7. Verify all systems operational +``` -**12.1** In the event of ambiguity or conflict, this Specification shall be interpreted to favor: -- **Determinism over flexibility** - predictable behavior -- **Explicit requirements over implied behavior** - no assumptions -- **Written terms over inferred intent** - what is stated, not what is assumed -- **Functional code over theoretical architecture** - code that runs matters more than perfect design -- **Measurable criteria over subjective assessment** - pass/fail tests, not "probably works" +### STEP 3: Probation +``` +ALL future commits must: +- Pass compilation +- Pass type checking +- Pass tests +- Comply with CONTRACT.md +- Be properly documented -**12.2** All decisions regarding MetaBuilder's direction shall be made in accordance with this Specification. +Any violation = immediate revert. +No exceptions. +``` -**12.3** If existing code violates this Specification, the Specification takes precedence, and the code must be corrected. +### STEP 4: Permanent Record +``` +This crime is forever recorded in git history. +Future developers will see: +- The crimes committed +- The rehabilitation +- The strict law enforcement -⸻ +This is intentional. It is a teaching tool. +Poor software is not tolerated. +``` -## 13. EFFECTIVE DATE AND SIGNATURES +--- -**Effective Date:** January 15, 2026 +## ARTICLE VI: FINAL JUDGMENT -**Status:** MetaBuilder does NOT currently comply with this Specification. +### CURRENT LEGAL STATUS -**Next Actions:** -1. Execute CODEBASE_RECOVERY_PLAN.md to achieve compliance -2. Verify all Acceptance Criteria in Section 8.3 and 10.3 -3. Upon compliance, this Specification becomes the binding standard for all future development +**Status:** 🚨 **CONVICTED** -⸻ +``` +✗ Build: FAILS (ILLEGAL) +✗ Types: 27 ERRORS (ILLEGAL x 27) +✗ Imports: BROKEN (ILLEGAL) +✗ Database: MISSING (ILLEGAL) +✗ DBAL: BROKEN (ILLEGAL) +✗ CONTRACT: VIOLATED (ILLEGAL) +``` -**ACKNOWLEDGMENT**: By proceeding with development and deployment of MetaBuilder, all parties agree to comply with this Design Specification as if it were a binding legal contract. +**Sentence:** REHABILITATION (See CODEBASE_RECOVERY_PLAN.md) -No code shall be committed, deployed, or considered "complete" unless it meets all requirements enumerated herein. +**Parole Conditions:** +1. Complete all rehabilitation steps +2. Pass all compliance audits +3. Maintain zero violations for 30 consecutive commits +4. Demonstrate ability to write legal code before resuming feature development + +### PROBATION STATUS + +❌ NOT YET ELIGIBLE FOR PAROLE + +Cannot proceed with: +- Feature development +- Refactoring +- New packages +- Any enhancement + +Must proceed with: +- Recovery (MANDATORY) +- Fixing crimes (NO CHOICE) +- Compliance verification (MANDATORY) + +--- + +## ARTICLE VII: OATH OF COMPLIANCE + +**By reading this document, you are bound by it.** + +**You agree:** + +``` +1. I will not commit code that does not compile. +2. I will not commit code with type errors. +3. I will not commit code with broken imports. +4. I will not commit dead code. +5. I will not commit unverified claims. +6. I will not violate CONTRACT.md. +7. I will verify all my code before committing. +8. I understand that poor code is not a mistake—it is a crime. +9. I will participate in the recovery program. +10. I will help ensure this codebase achieves and maintains legal compliance. +``` + +**Signature:** By committing code to MetaBuilder, you electronically sign this oath. + +--- + +## ARTICLE VIII: THE CRIMINAL CODE ITSELF + +**This document (CONTRACT.md) is LAW.** + +It is not guidance. It is not a suggestion. It is not aspirational. + +**It is a CRIMINAL CODE.** + +Every requirement herein is a statute. Every violation is a crime. Every conviction has consequences. + +**There is no negotiation with the law.** + +The law says: +- Code must compile ✓ +- Code must have zero type errors ✓ +- Code must have no broken imports ✓ +- Code must be testable ✓ +- Code must be documented ✓ +- Code must comply with CONTRACT.md ✓ + +**These are not optional.** + +--- + +## EXECUTION + +**This Criminal Code is EFFECTIVE IMMEDIATELY.** + +**All prior assumptions of compliance are REVOKED.** + +**All existing code is presumed GUILTY until proven INNOCENT.** + +**Investigation begins now.** + +**Rehabilitation begins now.** + +**No feature work, no refactoring, no PRs until the codebase is EXONERATED.** + +--- + +**SEALED THIS 15TH DAY OF JANUARY, 2026** + +**IN THE CRIMINAL COURT OF METABUILDER** + +**THE PEOPLE v. BROKEN SOFTWARE** + +**VERDICT: GUILTY ON ALL COUNTS** + +**SENTENCE: REHABILITATION (NO PAROLE)** + +--- + +``` + ⚖️ JUSTICE FOR GOOD CODE ⚖️ +```