# Loop Worklist 1.0.0 contract

The local command applies the same rules as the browser tool at https://loopxxi.com/tools/follow-up-worklist. Runtime: Node.js 22+. There are no external dependencies, model calls, telemetry, network requests or automatic file writes.

## Input

Standard input must contain valid UTF-8 CSV, at most 250,000 bytes and 1,000 data records. Include at least one record and these six unique headers:

`reference,received_at,status,owner,next_action,due_date`

Headers are trimmed and case-insensitive. Extra columns are ignored. Values are trimmed. Received and due dates use YYYY-MM-DD; valid statuses are new, active, waiting and closed. Blank/malformed record values become review flags. Structural problems such as unclosed quotes, duplicate headers, mismatched column counts or missing required headers reject the whole input; no partial queue is returned. Use internal references and only the information needed for the review.

The review date is mandatory: `--date YYYY-MM-DD`. There is no automatic date or timezone inference inside the command. Two runs with identical input bytes, review date and tool version produce the same output. The input hash is SHA-256 of original bytes, including any UTF-8 BOM and line endings.

## Output

Default output is JSON on standard output, matching `output.schema.json` next to this file. `tool.version` identifies the release. `review_date` is the supplied date. `input_sha256` links the output to exact input bytes. `review_required` is always true and `actions_taken` is always an empty array.

Summary fields: `total_records`, `queue_records`, `closed_excluded`, `flagged_records`. Valid closed records are excluded; malformed closed records remain for review. All remaining records are in `queue`, including scheduled records without a flag. Each row retains the six input fields, adds `review_flags`, `priority_score` and `source_record` (one-based parsed data-record number, not physical file line). Status is normalized to lower case. Embedded newlines and blank CSV lines mean record numbers can differ from line numbers.

Rules add scores for missing/duplicate references, invalid dates or unknown status (100 each), overdue date (50), due today (40), missing owner (30), missing next action (20) and missing due date (10). Open records with no flag receive score zero. Scores order review work; they do not predict lead quality. Ties preserve source order. Duplicate references remain separate and are never merged or deleted. Unknown statuses are retained and flagged. The command does not judge contradictory dates, business relevance or completeness beyond these explicit rules.

`--format csv` emits the six fields plus `review_flags`; it omits JSON metadata and scores. It quotes every cell and prefixes formula-leading characters for spreadsheet safety. Never execute cell contents. For proof of which input was reviewed, retain the JSON result separately.

Exit 0: valid review generated, possibly with flags. Exit 2: invalid arguments, encoding or CSV. Exit 1: internal failure. Failures write one JSON error to standard error and no success output. Error codes are `invalid_arguments`, `invalid_date`, `invalid_format`, `missing_input`, `input_too_large`, `invalid_encoding`, `invalid_csv`, `internal_error`. Pipe/read failures are internal failures. No raw record contents, stack traces or local file paths are included in errors.

## Limits and verification

Check archive SHA-256 against the first-party manifest before extraction. The included `SHA256SUMS` fingerprints bundled files. A checksum detects different bytes; it does not provide independent identity, tamper-proof history or signed attestation.

The example and automated tests use synthetic records. They establish rule behavior, not actual customer time savings, lead conversion or AI accuracy. The caller remains responsible for access, secure local storage, its own AI data policy and human decisions. Loop XXI cannot observe local usage or outcomes through this tool.
