@haneinfo/app-tooling
v0.5.12
Published
Shared Haneinfo App checks and scaffold tooling
Readme
@haneinfo/app-tooling
RBAC 8 App upgrade
haneinfo-app does not apply database migrations or permission plans. For each App,
upgrade rbac to 8.0.0 after release and run haneinfo build. For Apps using
backend/prisma/schema/, copy the reviewed rbac prisma/role.prisma fragment into that
active schema folder as well (build only emits the composed schema). Add
an App-owned migration before starting the upgraded backend:
ALTER TABLE role_permissions ALTER COLUMN permission TYPE text USING permission::text;Regenerate Prisma Client, deploy the migration, seed, then run integration tests. Deploy
backend/.haneinfo/generated/permissions.json and start with backend/ as the working
directory (or explicitly configure the catalog path). Keep the App Permission enum
as a catalog or supply constant IDs through RBAC_PERMISSION_CATALOG_OPTIONS.
Use the updated frontend-admin, or pass /roles/permission-catalog to custom role UIs.
Seeds must use string[] for mixed App/plugin grants and validate them with
RbacPermissionCatalog.assertGrantable() before insertion. Preserve retired grants.
The enum checker already accepts schemas without Permission; it still validates any
remaining enums and their translations. Do not translate plugin IDs as Prisma enums:
their labels come from the deployed catalog's displayName.
Template synchronization
Scaffolding records the clean template checkout's actual Git commit in .haneinfo/scaffold.json
and initializes an App-owned docs/template-sync.md with that baseline and an immutable link
to upstream history. Dirty checkouts fail before writing. An exported template must supply
--template-commit <full-sha>; both marker and ledger label that revision supplied-unverified.
No old baseline, example mapping or automatic upgrade claim is copied into the new App ledger.
In a local upstream template checkout, list later delivery commits without changing files:
haneinfo-app template changes --since <baseline-commit> --jsonThe baseline must exist locally and be an ancestor of the selected --to commit (default HEAD).
The command uses first-parent deliveries, including merge changes once, and reports every path
with review-required. Documentation and CI can carry migration/security contracts and are
never automatically optional. Business App checkouts, missing history and invalid refs fail.
The planner neither installs nor applies changes. Each fork records applied/equivalent/
not-applicable/pending, package prerequisites, its implementation commit, verification and
rollback; equivalent/not-applicable need a reason. Keep schemas, grants and App UI ownership.
Run haneinfo-app check from an App repository to verify generated plugin artifacts, integration contract runtime files, enum documentation and translations, domain event subscriber wiring, ScopeGuard scope coverage, data dictionary drift, and configured shared-package version policies. haneinfo-app check plugins, integrations, enums, subscribers, scopes, dictionary, or versions runs one gate. Use --root <path> to check another App and --json for machine-readable results. Missing enum translations and documentation fail; orphaned translation keys are warnings.
This package owns App-level checks. The scripts/lint-specs.mjs file remains in each repository under the shared specs governance rule.
Shared-package version policy
haneinfo-app check versions checks the App's @haneinfo/* version declarations and committed
lock metadata without installing packages, executing App scripts, loading runtime configuration,
looking up registry versions or changing files. The root pnpm-workspace.yaml bare, exact
first-party overrides are the authority; no second version-number map is introduced.
Enable the gate with root haneinfo.version-policy.json:
{
"schemaVersion": "haneinfo.version-policy/v1",
"isolatedWorkspaces": ["e2e"]
}The root and each listed isolated workspace must have pnpm-workspace.yaml, package.json
and pnpm v9 pnpm-lock.yaml. Each workspace's packages must explicitly list member
directories; literal paths and a single final child glob such as packages/* are supported.
Child globs exclude hidden/dependency directories and overlapping matches are deduplicated.
Use packages: [] for an isolated workspace with only its root package. The gate
reads every listed member's manifest and matching lockfile importer. Paths use normalized
forward slashes within the App; parent traversal, outside-root symlinks, unsupported glob patterns, duplicate member
paths, unknown policy fields, malformed/duplicate JSON/YAML keys and unsupported YAML tags fail
explicitly. Standard YAML merge aliases are supported with bounded expansion.
Exact and range declarations may differ: each dependencies/devDependencies/optionalDependencies/ peerDependencies range must admit the root pin. Local workspace overrides rewrite importer specifiers, so the comparison uses the effective specifier rather than blindly comparing it with the original caret range. An independent E2E workspace does not inherit root overrides: its own declaration/specifier and resolved version are checked against the same central pin. Peer-only declarations require compatible ranges, not a fabricated install importer.
The gate checks first-party lockfile overrides, declared and stale importer entries, package and
peer-qualified snapshot references, and first-party resolutions for centrally pinned packages.
haneinfo.plugin-lock.json packages and presets beside workspace manifests are checked against
the same pins and pnpm resolutions; an inventory without its plugin lock fails. Digests,
capability resolution and generated artifacts remain the existing plugins gate's responsibility.
Third-party dependency choices are outside this policy. This does not replace frozen installs,
pnpm integrity validation, package tests or business permission review.
Only bare exact first-party overrides and normal SemVer ranges are supported. First-party
aliases, tags, local/workspace protocols, selectors targeting first-party packages and package.json pnpm.overrides
are diagnosed rather than guessed. Review the declaration, pin and lock together, run frozen
installs for every workspace, regenerate plugin artifacts explicitly after a real plugin upgrade,
and repeat the check; the gate never repairs drift automatically.
Scoped overrides targeting third-party dependencies (for example
@haneinfo/oidc-auth>jsonwebtoken) remain outside this first-party version policy.
check all enforces a policy when present. To preserve existing forks, an absent policy yields
an explicit versions-policy-missing coverage warning; standalone check versions treats the
same omission as failure. A malformed configured policy always fails. JSON reports expose the
warning/issue and human diagnostics include input file, line, column and package/field context.
Data dictionary drift
haneinfo-app check dictionary compares docs/data-dictionary.md with the consuming App's
@haneinfo/metadata-schema renderer in memory. It ignores only the generated header date,
UTF-8 BOM and line endings. Models, enum values, fields, descriptions, relationships and dates
inside the document still participate in comparison. Missing documentation and renderer failures
are failing diagnostics, not a successful skipped check. Drift diagnostics identify the file and
first differing line. check all includes this gate; check enums remains a separate contract.
The App must already have a fresh generated Prisma client. The gate compares its embedded
schema.prisma with the App source before rendering, detecting stale clients when fields,
attributes, enum values or /// documentation differ. The schema fingerprint ignores formatting whitespace,
ordinary comments and top-level block order; it retains schema tokens, field order and ///
documentation. It is a text-consistency check, not a replacement for Prisma schema validation.
Unknown or malformed declarations fail explicitly.
Supported schema locations are backend/prisma/schema (including nested .prisma files),
backend/prisma/schema.prisma, or the path in backend/package.json's prisma.schema. Multiple
default locations need an explicit path. Prisma 7 configurations may use an imported
defineConfig from prisma/config and export default defineConfig({ schema: "literal/path", ... }).
The checker parses the path with TypeScript's AST and never executes the configuration or its
datasource expressions. Dynamic paths, spreads, duplicate/computed keys, additional top-level
statements, conflicting paths and multiple config files fail explicitly. Non-default client
outputs are not guessed. Both Prisma 6 and 7 keep using the default @prisma/client layout.
Rendering runs in an isolated Node process with the App backend as cwd, using that App's installed
metadata package and client. Checking several Apps in one process does not share their DMMF cache.
The checker requires no database connection, does not execute App bootstrap/generator scripts,
and never writes source, clients or documentation. After reviewing changes, run the App's
prisma:generate and schema:docs commands explicitly, then repeat the check.
Scope coverage
haneinfo-app check scopes parses App-owned backend/src/**/*.ts / *.tsx (excluding
declaration, spec, and test files) with TypeScript. It reads backend/tsconfig.json when present
for local import/alias resolution. It checks each controller and HTTP method independently:
class and method guards combine, while required scopes follow methodScopes ?? classScopes.
An explicit empty @Scopes() overrides the class and fails on a ScopeGuard-protected route.
All Nest HTTP decorators, including Head, Options, All, Search, QueryMethod, WebDAV methods,
and RequestMapping, are recognized independently of decorator order and line breaks.
Named/namespace imports, import renaming, const aliases, string concatenation, imported const
arrays/objects, enum strings, and array spreads are supported. Constants must be treated as
immutable; this check does not perform whole-program mutation analysis. It never evaluates
App code. Dynamic scopes/guards, multiple Scopes decorators on one declaration, unknown custom
decorators, controller inheritance/mixins, syntax errors, and invalid tsconfig produce failing
diagnostics. Simple custom factories returning only unrelated SetMetadata are supported;
RequirePermissions from @haneinfo/rbac is known unrelated metadata. Use direct decorators
instead of opaque composed decorators. Diagnostics include file, line, column and owner name.
Exit codes follow the existing CLI contract: 0 passed, 1 check failed, 2 bad invocation, 3
unexpected error. Missing backend/src fails instead of returning a vacuous success.
This gate checks direct App controller/method declarations. Global guard registration,
programmatic metadata changes and dynamically created controllers require separate review;
plugin/package controllers belong to their package tests. A template with no App-owned
controller can pass without asserting coverage of its installed plugins. The gate checks scope
presence, not business permission correctness or whether a scope is grantable in the catalog.
[email protected] already denies API-key requests with missing/empty scopes (403); this check
does not alter runtime authorization. TypeScript ships as a production dependency for the CLI.
haneinfo-app scaffold initializes an unmodified template clone. It requires --name,
--display-name, --db-port, --backend-port, and --frontend-port; --description,
--ports-registry <dev-infra/app-ports.json>, --root, and --dry-run are optional. The dry run
checks all expected template patterns and prints a file-level plan without writing. The command
updates package identity, environment examples, Docker port, frontend scripts, and E2E defaults,
the committed Keycloak E2E realm, and the specs index and log headings. It points the
production-e2e job in .github/workflows/verify.yml and docs/e2e.md at the App's Keycloak
client (<name>, secret dev-secret-<name>), the frontend port in the realm's redirect URI, and
the App's own backend and database ports. The production runner refuses occupied ports, so a
running development stack must be stopped or other API and database ports supplied. It writes the App title
and description in frontend/src/config/app-config.ts as the template's Biome formatter would,
using the lineWidth in the template's biome.json, so biome check passes. It creates an ignored .env with a unique local database
password while keeping placeholders in .env.example. A marker prevents a second initialization.
Current templates seed identity and roles without an App-name fallback, so their seed file is left unchanged. Older templates that still contain the fallback have it rewritten to the new App name. Other required template patterns continue to be checked before any files are written.
