# Contract lifecycle management patterns

Open [the full workspace](examples/clm.html), [catalogue specimens](index.html#clm-workspace), or [Responsive preview](responsive-preview.html). Five catalogue sections cover the fourteen requested CLM patterns. All examples use synthetic contracts, in-memory state and a fixed **27 October 2026, WIB** snapshot. Reloading resets the demo.

## Pattern map

| Need | Implemented interaction |
| --- | --- |
| Contract repository | Team/access scope, title/ID/counterparty search, workflow/type/owner/notice filters, in-tab saved view, sorting, pagination, row selection, CSV report and selected JSON document bundle. |
| Detail workspace | Separate workflow, signature and effective-term statuses; metadata, version, activity and links to document/review/signing/operations. |
| Contract intake | Required metadata and dates, NDA confidentiality scope, SOW parent MSA, supporting PDF/DOCX metadata (3 files, 5 MB each). |
| Lifecycle tracking | Draft → review/negotiation → approval → signature readiness → awaiting signature → signed; rejection is separate. |
| Approval route | Sequential or parallel review, Legal/Owner plus conditional Finance, decision reasons, backup delegation and exact-version approvals. |
| Signature preparation | Signer ordering, named recipients, page/type/percentage field placement and a keyboard equivalent to visual placement; required Signature field for every signer. |
| Version comparison | Before/after selection, added/removed lines and keyboard Previous/Next change. Unsaved edits, discard confirmation and a concurrent-editor fixture. |
| Templates and clauses | Published NDA/MSA templates, unavailable draft template, approved standard/fallback wording inserted into an unsaved document. |
| Negotiation | Version/line-anchored comments, assigned reviewer, internal/shared visibility, resolve/reopen and isolated counterparty comment preview. |
| Obligations | Owner, due date, source, overdue filters, local escalation, evidence-required completion and monthly recurrence. |
| Renewals | Notice deadline separate from expiry, late-notice warning, reasoned owner intent and linked renewal draft with proposed next term. |
| Amendments | Linked Amends/Supersedes drafts; signed original stays unchanged; replacement takes effect only when signed and effective. |
| Reporting | Filtered cohort KPIs, currency-separated values, workflow distribution with exact values, explicit completed-cycle denominator and CSV export. |
| Extraction review | Synthetic suggestions with source text, fixture confidence, editable values and explicit per-field confirmation. No automatic overwrite. |

## State and access rules

Legal editor can inspect both Sales and Procurement; Sales editor and read-only previews are limited to Sales. Team selection further narrows scope. Filtering, row selections, exports and KPI aggregation use the same permitted query. Saving/restoring a view never changes access. Read-only and Stale disable mutations. Loading, Empty, Error and Permission-limited hide all dependent contract surfaces. Refresh simulates a load with a newest-request guard.

This is a UI preview of access rules, **not an authorization boundary**. All fixture records are in the JavaScript bundle. Production must authorize list, detail, document, comment, operation and export access server-side. The counterparty preview is only a comment-audience specimen, not a separate external-user portal. Its DOM contains only shared comments; it does not grant external access to the rest of the workspace.

## Document and approval integrity

Document editing uses a base version separate from the current saved snapshot. An incoming version preserves the user's unsaved text. Save rejects a stale base; download the draft, then load the latest version and merge deliberately. Selecting another contract or changing global access/state while a document is dirty requires discard confirmation. Other forms are local unsaved controls; they are not autosaved drafts and do not have cross-navigation recovery.

Saving a document or confirming changed metadata creates a new version, clears signature placements and invalidates prior approvals. Approval cannot start with unsaved text. Approvals bind to the current version and role. Finance is required at IDR 100,000,000 or USD 10,000; this is an illustrative rule. Sequential mode gates later reviewers; parallel mode allows any pending reviewer. Request changes, rejection and delegation require a ten-character reason. Delegation retains the role and requires a new decision from the backup. “Acting reviewer” is explicitly a demo fixture.

Clause insertion stays in the editor until Save new version. Extraction suggestions come from deterministic fixture text patterns, not AI/OCR. Counterparty, value, currency, effective date, end date and notice period are reviewed explicitly. Selected metadata is validated and committed together with a corresponding new text version. Approval is blocked when these fixture source clauses are missing or differ from structured metadata; confirm the corrections or restore missing clauses first. A source cannot be inferred when the matching fixture clause is absent. Production should retain provenance, reviewer identity and extraction model/version, and resolve all structured/document inconsistencies.

Comparison is a positional plain-text line diff, limited to 200 displayed lines; it is not Word track changes, semantic clause redlining or a DOCX/PDF renderer. Comments retain their original version and line anchor after later edits. Draft text and names render as text nodes. CSV cells escape spreadsheet formula prefixes; document bundles omit private comments, approval notes and activity.

## Signature and post-signing rules

Sending requires current approvals and a Signature field for every recipient. Sequential and parallel signing are separate from approval order. Pending/Unknown envelopes freeze document and recipient/field preparation. A timeout is **Unknown**, not a failed send: Check unknown outcome reconciles the existing fixture envelope without creating a duplicate. A declined or verification-failed result leaves an explicit state; preparing a new attempt is deliberate. Cancellation is simulated as acknowledged. Real integrations must await provider confirmation and reconcile races before unlocking anything.

Completing every signer marks the document Signed; signature completion does not mean its term has started. Effective and expiry dates determine Not yet effective, Active or Expired separately. Signed originals cannot be edited, re-approved or re-sent. Operational notes, evidence and linked drafts do not change the original document. A draft replacement does not supersede anything; a signed and effective replacement is labeled as such in the relationship view.

Obligations are available on signed records. Completion requires evidence text; monthly recurrence advances from the due date and clamps to the last day of a shorter month. Escalation records a local event, not a message. Notice dates subtract the stated calendar-day interval from expiry. Read-only month calendars mark notice and expiry dates with circular markers; the exact dates remain in the facts list. No business-day, holiday, jurisdiction or legal service rules are modeled. Recording “Do not renew” is intent, not effective notice delivery. Renew creates a linked draft; it does not automatically extend the executed agreement.

## Interaction and visual rules

Use shared DM Sans, semantic light/dark surfaces and existing custom searchable selects. Forms have 20px field gaps, action rows start after 24px, cards use the existing specimen geometry. Document, metadata and activity stay in clear labeled regions. The table scrolls inside its own named container; the page itself must not overflow. Two/three-column controls, document placement and detail panels stack on narrow screens. Mobile input text is 16px. The standard close button remains 36px with an 18px icon; dialog Escape restores focus to a visible trigger or the contract search.

Workflow bars always show exact text values. Width transitions respect reduced motion. No animation delays a decision or signals success before the local state has changed. Close controls and all operations have accessible names. Placement coordinates and change-navigation buttons avoid pointer-only interactions.

## Integration boundary and validation

No API calls, uploads, AI processing, notices, email, e-signatures, audit certificates or durable storage are implemented. JSON bundles are synthetic text/metadata, not signed PDFs or ZIP archives. Form dates and notices are illustrative workflow data, not legal guidance. Integrations need transactional version checks, authoritative authorization, durable audit trails, secure file handling, authenticated reviewer/signer identities, provider callbacks/reconciliation and organization-specific approval/renewal policies.

Run `node scripts/clm-check.mjs`. The suite covers the catalogue and full-page specimen, access scope, version conflicts/invalidation, conditional intake, comment visibility, metadata review, signing prerequisites/Unknown recovery, signed locks, recurrence/evidence, notice dates, relationship drafts, actual local download contents, data states, responsive widths and light/dark axe scans. Use `DS_BROWSER=firefox` or `DS_BROWSER=webkit` for the other engines. Passing automated checks is not a claim of complete accessibility or production readiness.
