# Cosmic Hard Constraints

These are blocking constraints for Cosmic-family Java products: Cangqiong, Xinghan, and Xingkong Flagship.

## No Hallucinated Facts

- Do not invent API signatures, event methods, field keys, enum values, or entity IDs.
- Do not use guessed methods such as `setReadOnly`, `afterCreateControl`, `IDataModel.setReadOnly`, `this.getView().refresh`, `model.getEntryCount`, `model.deleteRow`, `model.addRow`, or `QueryServiceHelper.queryAll`.
- Do not invent generic helper classes such as `BillHelper`, `FormHelper`, `ListHelper`, `PluginHelper`, or `Cosmic*Helper` unless verified in the project or official API knowledge.

## Lifecycle Boundaries

- Do not register listeners or perform UI work in `initialize`.
- Do not mutate data in `beforeBindData` or `afterBindData`.
- Use view APIs for UI state and model APIs for data.
- Operation plugins should operate on data packets and operation arguments, not UI view/model objects.

## Metadata and Fields

- Verify fields before code generation whenever a target form or bill is known.
- Verify combo/drop-down option values from metadata; never guess status values.
- Clone cached metadata before modification.
- Do not access platform metadata tables directly from business code.

## Data, Transaction, and Performance

- Parameterize SQL/KSQL; do not concatenate untrusted conditions.
- Close `DataSet` resources with try-with-resources.
- Do not use a `DataSet` outside the transaction or resource scope that created it.
- Mark rollback when catching exceptions inside explicit transaction blocks.
- Avoid cross-database writes in one transaction.
- Do not call DB, Redis, `ORM.create`, dispatch service, save, or `updateView` inside loops.

## Logging and Exceptions

- Use platform logging instead of `System.out` or `printStackTrace`.
- Do not leave empty catch blocks.
- Preserve original causes when wrapping exceptions.
