Skip to content

feat: add managed project context renderer#12

Open
andrei-hasna wants to merge 5 commits into
mainfrom
feat/managed-project-context-renderer
Open

feat: add managed project context renderer#12
andrei-hasna wants to merge 5 commits into
mainfrom
feat/managed-project-context-renderer

Conversation

@andrei-hasna

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

Copy link
Copy Markdown
Contributor

Task

  • Worker task: e537518a-43a7-4131-a5b5-84492115c247 (OPE12-00014)
  • Coordinating Projects task: 6c878cbb-d635-4354-9af1-566bb850a3d3
  • Canonical repository: hasna/instructions; hasna/configs and hasna/open-configs are aliases, not separate landing targets.

Summary

  • Add the strict hasna.projects.project_context_bundle.v1 consumer through file, stdin, and in-process library surfaces. Enforce the 8 KiB input cap, strict allowlists/additionalProperties:false, source hash and revision consistency, enums/link identity consistency, six fixed argv commands, and no provider CLI lookups.
  • Make Instructions the sole derived-context writer with one bounded canonical fragment and deterministic Claude, Codewith, and AGENTS adapters. Preserve every byte outside managed markers, reject malformed/duplicate/nested/mismatched markers, retain symlink rejection, and enforce Codewith override/root/AGENTS precedence with PROJECT_CONTEXT_SHADOWED.
  • Compose durable project context into routine session renders without permitting stale plans or older revisions to overwrite newer context. Replace project-context /dev/fd provenance with durable cache provenance and migrate the stale Executive Assistant fixture without a contradictory second block.
  • Add same-project bounded stale-cache behavior, metadata-only manifests/snapshots, manifest-last CAS ordering, per-workspace locks with process-start identity, directory-anchored atomic replacement, one hash-race retry, crash recovery, and no-replace deletion rollback.
  • Preserve portable legacy session re-renders on platforms without atomic exchange when no project-context guard is active; guarded project-context replacement still fails closed.

Compatibility contract

  • Keeps legacy @hasna/configs 0.2.45 compatibility, the configs executable alias, hasna.configs.session-render/v1, Managed by @hasna/configs markers, and ownedBy: open-configs.
  • Adds canonicalOwner: instructions without a flag-day manifest v2.
  • Dual-reads legacy markers and existing manifests while validating their bounded project-context metadata.
  • Codewith stays flattened by default and uses native imports only behind HASNA_CONFIGS_CODEWITH_NATIVE_IMPORTS=1 or the explicit CLI/runtime option.
  • Existing guarded project-context CAS updates require Linux renameat2 or macOS renameatx_np. Unsupported platforms can create the first managed output but fail closed before guarded replacement.

Validation

  • env -u HASNA_INSTRUCTIONS_API_URL -u HASNA_INSTRUCTIONS_API_KEY bun test src/lib/project-context.test.ts src/lib/session-apply.test.ts src/cli/project-context.test.ts src/cli/session.test.ts — 88 pass, 0 fail, 456 expectations.
  • env -u HASNA_INSTRUCTIONS_API_URL -u HASNA_INSTRUCTIONS_API_KEY bun test — 352 pass, 0 fail, 1186 expectations across 30 files.
  • bun run typecheck — pass.
  • bun run build — pass.
  • git diff --check and git diff --cached --check — pass.
  • gitleaks staged scan — 44.29 KB scanned, no leaks.
  • gitleaks origin/main..HEAD — 5 commits / 253.17 KB scanned, no leaks.
  • Repository package-manager scan reported eight pre-existing untracked machine-home findings in ~/.bunfig.toml and ~/.npmrc. It printed no secret values; those prohibited, out-of-scope files were not changed.
  • Fresh read-only adversarial reviews were reconciled for post-guard CAS, anchored rollback, create-only platforms, large legacy session outputs, portable re-renders, stale-lock identity fallback, and no-replace deletion recovery. Final review found no actionable defects.

Rollback

Before merge, close this PR and delete only the task branch if desired. If landed, revert the PR merge commit; for commit-by-commit rollback, revert 550a0ff, ccdb9f6, eb60aeb, f7fcbbf, and a1b9a6f newest-first. No schema migration or production state is involved, and prior Instructions versions continue to read the preserved legacy contract.

Operational state

No package publish, deploy, merge, production mutation, or push to main occurred.

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