Skip to content

feat: Align open-attachments with @hasna/contracts - #24

Merged
andrei-hasna merged 3 commits into
mainfrom
factory/75c2ed55-2728-4184-a4a6-0d67d276-0b12593a
Jul 28, 2026
Merged

feat: Align open-attachments with @hasna/contracts#24
andrei-hasna merged 3 commits into
mainfrom
factory/75c2ed55-2728-4184-a4a6-0d67d276-0b12593a

Conversation

@andrei-hasna

@andrei-hasna andrei-hasna commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Objective

Align open-attachments with @hasna/contracts

Run the @hasna/contracts conformance check for this repo and fix every violation until it passes — ensure a valid hasna.contract.json, published_artifact_gate satisfied (artifact-scan wired into prepack), storage waiver where applicable, and all required metadata/scripts present. Keep changes minimal and conformant. Open a PR; do not merge.

Verification

  • policy source: base 634e78b (immutable commit — agent-proof)
  • ⚠️ GATE-INTEGRITY: agent touched verify-bearing config — REVIEW (scripts.prepack, scripts.scan:artifact, scripts.verify:release)
  • install: pass
  • typecheck: pass
  • build: pass
  • test: pass

Run run_12b4d7e0ae31 · backend codewith · task 75c2ed55-2728-4184-a4a6-0d67d276e0f9
🏭 Generated by @hasnaxyz/factory


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

… it in tests

The scan:artifact gate was pinned to @hasna/contracts@0.8.3, which is not
published (latest is 0.8.2), so `bun run scan:artifact` exited 1 — and since
verify:release ends with it and prepack/prepublishOnly run verify:release,
every pack and publish of @hasna/attachments failed. Pin the scanner, the
contract manifest, the vendored storage kit and the dependency range to 0.8.2
so they all agree instead of the manifest asserting an alignment the repo did
not have.

- scripts/scan-artifact.ts: pin CONTRACTS_KIT_VERSION to the published 0.8.2,
  drop the HASNA_CONTRACTS_ARTIFACT_SCAN override (it replaced the scanner
  wholesale, so `HASNA_CONTRACTS_ARTIFACT_SCAN=true bun publish` shipped with
  the gate silently disabled), echo the resolved scanner command so a no-op
  scan is visible in publish logs, and export the pieces behind an
  import.meta.main guard so the gate is testable.
- hasna.contract.json / package.json / bun.lock / pnpm-workspace.yaml: move
  kitVersion, the @hasna/contracts range and the release-age exclusion to
  0.8.2; regenerate src/generated/storage-kit with
  `bunx @hasna/contracts@0.8.2 vendor-kit` (content is byte-identical to the
  0.4.1 kit — only the version stamps move), so
  `contracts vendor-kit --check` is consistent again.
- scripts/scan-artifact.test.ts + scripts/test.sh: the suite globbed only
  src/ and sdk/, so nothing this change touches was covered. Collect
  scripts/ too and add tests that packs the artifact, run the pinned scanner,
  assert there is no env bypass, and assert the kit version stays in lockstep
  across the manifest, the vendored kit and the dependency range.

Verified: bash scripts/test.sh -> 51 total, 51 passed, 0 failed (1932 expect()
calls); bun run verify:release -> exit 0 with
`pass artifact-scan hasna-attachments-1.1.5.tgz (packed_artifact, 11 members
scanned, 0 excluded, 0 unreadable)`; bunx @hasna/contracts@0.8.2
repo-conformance . -> ok, published_artifact_gate pass; vendor-kit --check ok
at 0.8.2.
… broken

The gates this PR adds were not guarded by anything that could go red.

- scan-artifact.test.ts asserted scannerCommand() against a poked env var the
  implementation never reads, so a real `process.env` bypass kept it green.
  Assert the invariant the module header claims instead: scan-artifact.ts has
  no environment input path at all.
- Nothing asserted that prepack still reaches scan:artifact, so the whole
  deliverable could be deleted with a green suite. Walk the package.json script
  graph the same way `contracts repo-conformance` does, and pin the declared
  script name in hasna.contract.json to it.
- storage.pgTestGate pointed at `bun test src/serve src/db`: every src/serve
  test runs on InMemoryAttachmentsStore and src/db had no test files, so the
  gate returned 40 pass against a closed port. Add live-PostgreSQL coverage for
  ATTACHMENTS_MIGRATIONS (including the hasna_auth_0003 api_keys.tid column the
  @hasna/contracts bump introduces) and PgAttachmentsStore, each run isolated in
  its own schema, and point the gate at them. The command now fails when the
  database URL is unset and when the database is unreachable.
- Add CI so repo-conformance, the release gate and the live-PG gate run on every
  push instead of only when a reviewer types them, including a step that proves
  the live-PG gate still fails against a dead database.
@andrei-hasna
andrei-hasna merged commit 57e8739 into main Jul 28, 2026
2 checks passed
@andrei-hasna
andrei-hasna deleted the factory/75c2ed55-2728-4184-a4a6-0d67d276-0b12593a branch July 28, 2026 02:27
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