Skip to content

docs: add STYLE.md documenting unwritten coding conventions - #1335

Merged
TimothyJones merged 3 commits into
mainfrom
docs/add-style-guide-clean
Jul 5, 2026
Merged

docs: add STYLE.md documenting unwritten coding conventions#1335
TimothyJones merged 3 commits into
mainfrom
docs/add-style-guide-clean

Conversation

@TimothyJones

@TimothyJones TimothyJones commented Jul 5, 2026

Copy link
Copy Markdown
Member

Summary

Adds a new STYLE.md guide that documents the coding conventions in ContractCase that are not enforced by lint or covered by the existing CodingStandards.md. This captures the unwritten rules that survive through review — the trade-off reasoning behind key architectural choices — so that future maintainers (and LLMs) understand not just the rules but why they exist.

The guide covers:

  • Function/closure/class role split and dependency injection patterns
  • The preference for .then() chains over async/await
  • The two-error blame taxonomy for better user UX
  • Wire-format namespaced keys and type-tag constants
  • Context threading, location trails, and logging architecture
  • Plugin executor uniform shape and registry patterns
  • Documentation as a build artifact with TSDoc release tags
  • Testing without mocking libraries (DI-driven with real objects)
  • Cross-language binding rules (Java DSL as a mirror structure)
  • Known deviations and migration guidance

Also includes:

  • Removal of a Promise.resolve(() => {}) bug in FunctionResultMatcher.ts
  • Fix for the copyright banner in the function plugin (was incorrectly labeled as HTTP)

This is the companion to CodingStandards.md — one is the machine-checked rules, the other is the hand-maintained conventions.

Test plan

  • Read through STYLE.md for accuracy and completeness
  • Verify link from CodingStandards.md is correct
  • Confirm formatting and markdown render cleanly

I've added the commit override below, since the PR from the fork didn't merge the normal way, we have to override release please somehow.

BEGIN_COMMIT_OVERRIDE
fix(plugins)!: Plugins names are now restricted to be node module names, preventing malicious contracts or clients of the contract server from loading arbitrary code via remote or inline URIs. This is technically a breaking change, as remote and inline URIs for plugins were previously unintentionally supported.
END_COMMIT_OVERRIDE

This document complements CodingStandards.md by capturing the style
conventions that live between the lint rules — the choices that survive
only through review and through documentation.

The guide covers:
- Function/closure/class role split and DI patterns
- `.then()` chains over async/await, with rationale
- The two-error blame taxonomy (CaseConfigurationError vs CaseCoreError)
- Wire-format namespaced keys and type-tag constants
- Context threading and location trails for error messages
- Plugin executor shapes and registry patterns
- Documentation as a build artifact with release tags
- Testing patterns (no mocking library, test-data factories)
- Cross-language mirroring rules for Java and other bindings
- Known deviations (things to migrate opportunistically)

The guide also includes the motivation and trade-offs for each
convention, so future maintainers understand not just the rules but
why they exist.

Distilled from reading ~700 lines of TS source and 25+ files across
all packages.

Co-Authored-By: Timothy Jones <timothy.l.jones@gmail.com>
The function plugin's index.ts file incorrectly listed 'ContractCase Core HTTP
Plugin' in the copyright banner. Corrected to 'ContractCase Core Function Plugin'.

Co-Authored-By: Timothy Jones <timothy.l.jones@gmail.com>
@TimothyJones
TimothyJones enabled auto-merge (squash) July 5, 2026 03:13
@TimothyJones
TimothyJones merged commit caba6aa into main Jul 5, 2026
14 checks passed
@TimothyJones
TimothyJones deleted the docs/add-style-guide-clean branch July 5, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant