Read the Markdown source ↗

Constraint First Decision Table

Reject options that break stated constraints, then compare eligible options with explicit weights.

Version: 1.0.0. License: MIT. Status: tested reference baseline; no comparative ranking is claimed.

Contract

Require nonempty unique criteria, nonnegative weights with a positive total, and unique option IDs. Every option must provide exactly the declared score keys with finite numeric values. Exclude options with any declared violation. Compute weighted sums, negating scores for min criteria. Return every tied winner without inventing a tie breaker.

The exact required input fields and types are in input.schema.json. Extra fields are rejected at declared object boundaries. JSON duplicate keys and non-finite numbers are rejected by the CLI. Input strings are case-sensitive unless stated otherwise. Array order is preserved unless the contract specifies sorting.

Use

Unpack the ZIP, enter its directory, and run:

python3 baseline.py < example.input.json
python3 -m unittest -v

Python 3.10 or newer, standard library only. The reference implementation exposes run(input_dict) and accepts one JSON object on standard input. Success returns {"ok": true, "result": ...} with exit code 0. Invalid input returns {"ok": false, "error": "..."} with exit code 1. example.output.json contains the result without the CLI envelope. Import callers receive exceptions for invalid input.

Example input

{
  "criteria": [
    {
      "id": "fit",
      "weight": 1,
      "direction": "max"
    }
  ],
  "options": [
    {
      "id": "a",
      "violations": [],
      "scores": {
        "fit": 7
      }
    },
    {
      "id": "b",
      "violations": [
        "requires unavailable data"
      ],
      "scores": {
        "fit": 10
      }
    }
  ]
}

Example result

{
  "ranked": [
    {
      "id": "a",
      "score": 7
    }
  ],
  "excluded": [
    {
      "id": "b",
      "violations": [
        "requires unavailable data"
      ]
    }
  ],
  "winners": [
    "a"
  ]
}

Boundaries

Caller scores must already use comparable scales. The package does not normalize units, discover constraints, generate scores, or claim an objectively best option. Violations and weights are explicit owner inputs.

This package performs no network calls, executes no submitted commands, and writes no user files. Host applications own authorization, resource budgets, and persistence. Example values are fixtures, not recommended policies or limits.

Acceptance and provenance

cases.json records named expected results and rejection cases. test_baseline.py runs those cases and checks the command-line contract. manifest.json records file digests. The specification, implementation, and evidence are separate files so a replacement implementation can target the same contract.

Original code and examples generated for this Arcomm collection. No third-party code is bundled. Read LICENSE for reuse terms.

Download

Download the file

SHA-256: 6380977043a54ddf3f5c4487910deb38b0e3005c4959cdd433bc4d4f341cc387

Size: 7285 bytes.

Revisions

Revision history