Skip to content

fix: prepare native API prerequisites without packaging - #291

Merged
pranems merged 1 commit into
masterfrom
vprane/scimserver/containers-native-prerequisite-preparation-20261124
Nov 25, 2026
Merged

pranems merged 1 commit into
masterfrom
vprane/scimserver/containers-native-prerequisite-preparation-20261124

Conversation

@pranems

@pranems pranems commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Summary

Reuse the existing standalone builder with explicit -PrepareOnly to install locked API dependencies, generate Prisma without a real datasource and compile the API before native development or a Fast push.

Base: normally merged master fc99388f5109802ff2255ba07527510e94eef644 (#290).
Head: 3d88ddce9875c13de547a440bb53866d82a1fd23.

The existing builder already checked install/generate/compile order. The invocation gap was its packaging side effects and caller-provided generation configuration. The new mode returns before package cleanup/assembly, web builds, downloads and runtime work. Generation temporarily uses a deliberately nonconnecting loopback URL and restores the caller datasource even on failure. Local Prisma/TypeScript CLI files are required after npm ci, and missing tools or native command failures stop explicitly.

No hooks, existing tests/assertions, configuration, locks, deadlines, application source, version, database, Azure/Graph, Desktop or images changed. Root/web immutable dependency restoration remains separate. No new runtime/browser qualification is claimed.

Linked Defect / Plan Reference

  • DELIVERY_PLAN.md defect ID: N/A; this is the outstanding fresh-worktree native preparation follow-up, not a new numbered product feature.
  • Audit doc reference: Native API preparation follow-up and R46-R49 execution RCA.
  • ADR (if applicable): N/A; existing builder stages reused, no new architecture.

TDD Process

  • RED test written first; observed it fail for the expected reason
  • GREEN: minimal implementation that turns the test green
  • Refactor (if any) keeps the test green
  • Permanent regression guard added (where applicable - see existing patterns in api/src/security/)

The new on-demand PowerShell execution contracts observe 41 assertion failures against the exact base builder, then 97 passing assertions against the correction. Initial test-double scope/fixture errors were corrected and retained, not passed off as valid RED. An independent real owned install succeeds with 660 packages; ci-only API build then exits 2 with TS2307 at ignored generated Prisma imports. Actual preparation without DATABASE_URL exits 0, generates Prisma 7.8.0 and emits the compiled entry without a package.

Feature / Bug-Fix Commit Checklist (standing rule)

Every behavioral change must include all that apply. Tick or strike through with N/A + reason.

  • Unit Tests - service-level and controller-level coverage of the new behavior. N/A for application services/controllers; 97 new on-demand setup execution assertions cover order, failure propagation, missing host/local tools, environment/location restoration, immutable lock and retained output.
  • E2E Tests - end-to-end spec under api/test/e2e/ exercising the feature through HTTP. N/A for setup-only behavior; unchanged Fast hook ran the existing reduced InMemory HTTP suite.
  • Live Integration Tests - new section in scripts/live-test.ps1 runnable against local + Docker + Azure. N/A; no live behavior changed or runtime started.
  • Feature Documentation - dedicated doc in docs/ with architecture, RFC references, Mermaid diagrams, test coverage. Existing README, infrastructure and removal-readiness records updated; no new feature doc or diagram needed for two reused build stages.
  • INDEX.md Update - add the new doc reference to docs/INDEX.md. N/A; only existing indexed documents updated.
  • CHANGELOG.md Update - [Unreleased] entry with full test counts and feature summary.
  • Session & Context Updates - Session_starter.md and docs/CONTEXT_INSTRUCTIONS.md.
  • Version Management - bump api/package.json (and any other version refs) when behavior changed. N/A; setup tooling only, no product/version/lock change.
  • Response Contract Tests - API responses contain ONLY documented fields (key allowlist assertion at unit + E2E + live). N/A; no API response changed.

Validation Output

New preparation contract: 97 assertions PASS, exit 0.
Base preparation contract: 41 assertion failures, exit 1, expected RED.
Existing standalone contracts: 59 assertions PASS, exit 0.
Actual immutable API install: 660 packages, exit 0.
ci-only API build: TS2307, exit 2, expected RED.
Actual PrepareOnly: Prisma 7.8.0 generated, compiled API present,
                   package absent, no DATABASE_URL, exit 0.
API lint: 0 errors / 507 existing warnings, exit 0.
Normal Fast push: 29/29 gates PASS, exit 0, 897.2 seconds.
Unit: 220 suites / 6,274 PASS.
Reduced HTTP: 120 suites / 2,519 PASS, 4 suites / 45 known skips.
Web TypeScript: 66 existing errors, accepted unchanged ceiling 96.
Web production build: PASS.
Documentation freshness: 29 documents PASS, exit 0.
Infrastructure documentation: PASS, exit 0.
Mermaid render and unchanged hook contracts: PASS.
All three source locks: unchanged SHA-256.

Exact commands and actual results:

Command Result
pwsh -NoProfile -File scripts\test\native-preparation.contract.ps1 -BuilderPath <private exact-base builder> Expected RED: exit 1, 41 assertion failures
pwsh -NoProfile -File scripts\test\native-preparation.contract.ps1 PASS: exit 0, 97 assertions
pwsh -NoProfile -File scripts\test\standalone-migrations.contract.ps1 PASS: exit 0, 59 unchanged assertions
npm --prefix api ci --no-audit --no-fund --registry=https://packagefeedproxy.microsoft.io/npm/ PASS: exit 0, immutable 660-package install
npm --prefix api run build after ci only Expected RED: exit 2, TS2307
pwsh -NoProfile -File scripts\build-standalone.ps1 -PrepareOnly PASS: exit 0, no real datasource/package/runtime
npm --prefix api run lint PASS: exit 0, zero errors / 507 warnings
pwsh -NoProfile -File scripts\audit-doc-freshness.ps1 -SkipCoupling PASS: exit 0, 29 documents
pwsh -NoProfile -File scripts\audit-deployment-doc.ps1 PASS: exit 0, source/doc coupling satisfied
git diff --cached --check PASS: exit 0
$env:PREPUSH_MODE='Fast'; git push --set-upstream origin HEAD:refs/heads/vprane/scimserver/containers-native-prerequisite-preparation-20261124 PASS: exit 0, unchanged owning Fast hook 29/29

Full suites were not manually duplicated before the hook. No full deployment, actual DB migration/connection, runtime startup or new live/browser run was executed. New setup contracts are on-demand; automatic test registry integration was not changed or claimed. The prior three 1,845-assertion live runs and two 353-test browser runs remain separately pinned to their original source/runtime/image evidence.

Private bounded logs and hash manifest remain in the supplied parent session evidence root, subfolder files\native-prerequisite-preparation-20261124. Original failures are retained. Key receipt SHA-256 values:

  • ci-only compile RED: 0f28dad8b5fe7cfe6366e8cfda084a7712eef7e1d5e213ecd4b60207023c5ab4
  • actual preparation GREEN: d2b5c81363a46c13899f5ac1a342054ea3771ce9be07a318f6fa5e6ad634dbe7

Standing Rules Acknowledgment

  • No em-dash (Unicode U+2014) anywhere in the diff. Verified via Select-String -Pattern ([char]0x2014).
  • No git commit --amend on history that has been pushed.
  • No new credentials, tokens, or secrets committed to source. Forbidden patterns regression spec at api/src/security/forbidden-source-patterns.spec.ts will catch known anti-patterns. The build-only datasource is deliberately nonconnecting, not a real credential.
  • Migrations are additive-only (expand-contract for column changes). Migration linter at api/src/scripts/lint-migrations.ts enforces this. N/A; no migration changed.

Destructive Migration Override (skip if not applicable)

  • This PR contains a NEW destructive Prisma migration (DROP TABLE/COLUMN, ALTER COLUMN ... TYPE, RENAME, INSERT ... SELECT FROM)
  • I have set ALLOW_DESTRUCTIVE_MIGRATION=1 in the CI environment for this PR
  • Justification (required if box above is ticked):
    <!-- Why this destructive change is necessary, what the rollback path is, and which release window it ships in -->
    N/A; no migration or database operation.
    

Reviewer Hint

Diff areas worth special attention from the reviewer:

  • scripts/build-standalone.ps1: checked shared order, generation-only environment restoration, local CLI guards, preparation return before package cleanup.
  • scripts/test/native-preparation.contract.ps1: actual builder invocation with test-owned doubles; positive/error paths and retained output. No old assertion changed.
  • Existing readiness RCA: R46-R49 and bounded evidence scopes, not fabricated complete historical/native qualification.
  • Self-improvement applied: executable outcome/failure contracts instead of documentation alone. Design accepted: reuse cohesive existing stages; no parallel installer or hook redesign.
  • Owner COMMENTED self-review is not independent approval. Parent direct review and normal merge remain required. No merge/deployment is requested by this implementation turn.

Reuse checked immutable install, DB-free Prisma generation and API compilation through explicit PrepareOnly. Preserve hook and lock behavior; add focused order, failure and caller-state contracts.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@pranems pranems left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Owner source self-review at 3d88ddc: reviewed the shared checked install/generate/compile sequence, local CLI guards, scoped generation datasource and restoration, and PrepareOnly return before package cleanup. New on-demand execution contracts pass 97 assertions after 41 failures on the base; unchanged standalone contracts pass 59. Actual ci-only compile reproduces TS2307/exit 2, and actual DB-free preparation exits 0. Normal owning Fast hook passes 29/29, API units 220/6274 and reduced HTTP 2519 with 45 known skips. Three lock hashes and application/hook/config sources remain unchanged. Design accepted: reuse cohesive stages without another installer. This COMMENTED owner self-review is not independent approval; parent direct review and normal merge remain required. No runtime, DB, cloud, Desktop or image operation was performed.

@pranems pranems left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parent direct source review at exact head 3d88ddc: reviewed the complete nine-file delta against fc99388, the original PR template and published body, and the builder context surrounding the changed stages. No blocking correctness finding identified.

Independently authenticated all 30 supplied evidence artifacts. Independently ran the exact-tip preparation contract: actual exit 0, 97 passing assertions plus the final completion line. Verified all three source lock hashes and zero delta in API/web application sources, Dockerfile and protected hook sources. The owning ordinary Fast push receipt contains 29/29 passing gates. Original expected RED and test-harness development failures remain retained.

The preparation-only boundary returns before package cleanup/assembly, web builds, downloads and runtime work. Generation restores the caller datasource before compilation and on failure; install and local-tool failures stop explicitly. Existing full packaging reuses these stages. The real preparation receipt was captured during implementation; final-source behavior is additionally covered by the exact-tip execution contract. This is setup evidence, not a new database, image, live HTTP, browser or Azure qualification.

Test/gate improvement applied: executable ordering, failure, state-restoration and retained-output assertions. Automatic integration of the new on-demand contract is not claimed. Architecture disposition accepted: the existing builder is a large packaging orchestrator, but this change reuses its cohesive preparation stages without adding a second installer, runtime concern or speculative abstraction. No knowledge graph was present; this was direct source review, not graph-based analysis.

This COMMENTED source review is not an independent GitHub approval. Five observed exact-head checks have succeeded; build-and-push is still running. Normal merge remains conditional on the complete exact-tip CI result, without bypass or override.

@pranems
pranems merged commit a72f95b into master Nov 25, 2026
6 checks passed
@pranems

pranems commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Delivery verified: normal expected-head merge completed at a72f95b on 2026-11-25T01:33:18Z after all six exact-head CI checks succeeded. Remote master and the complete reviewed 3d88ddc tree match (614ec6617bf6d9d1ce97baf297983be47cf7e1f5). Parent source review is COMMENTED, not independent GitHub approval. Parent independently executed 97 focused preparation assertions with actual exit 0 and authenticated all 30 owner artifacts; no new live/browser, database, bridge, Azure or Desktop operation was performed. Original implementation evidence and failed receipts remain unchanged.

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