Skip to content

fix: align managed agent rules v1.1.6#13

Open
andrei-hasna wants to merge 7 commits into
feat/managed-project-context-rendererfrom
task/d44e99d6-policy-v1-1-6
Open

fix: align managed agent rules v1.1.6#13
andrei-hasna wants to merge 7 commits into
feat/managed-project-context-rendererfrom
task/d44e99d6-policy-v1-1-6

Conversation

@andrei-hasna

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

Copy link
Copy Markdown
Contributor

Summary

  • keep the managed global-agent-rules-standard byte-identical to the accepted hasnaxyz/iapp-identities source at 48168c549cc2945053a4498a9a2b11888419bc94 while separating exact upstream-file SHA-256 (b8e89cdb49e207e5b497ac51384d67022b94fe5645cc9273db60384eb2c2fb32) from selected policy-payload SHA-256 (8b236086b82e94490516e0b00dffa03fb5f6841b68d95f80fc3e3c8fb7087420)
  • preserve unresolved secret/runtime template references during profile dry-run without resolving or exposing values; strict apply remains fail-closed
  • designate the Instructions session renderer as the sole writer for managed provider instruction entrypoints, deduplicate equivalent legacy writers, and exclude retired Gemini/project-scoped Antigravity outputs before validation
  • preserve existing OpenCode settings and unmanaged instruction entries while replacing only Instructions-managed references
  • reconcile managed platform selectors so station01 matches linux-arm64 without dropping custom selectors or variables
  • add a drift-safe session restore <snapshot> command for hasna.configs.session-render-snapshot/v1
  • prove complete, unfiltered profile accounting across Codewith, Codex, Claude, OpenCode, and Cursor for linux-arm64, macos-arm64, and my-setup

Stack and scope

This PR remains intentionally stacked on PR #12 branch feat/managed-project-context-renderer at exact committed head 550a0ff794a9602f6448ac9b7fe6c5c16b017a82. All P1 work stayed in the existing task worktree, branch, task, and PR.

Source and tests changed only. No generated CODEWITH.md, provider render, profile apply, package install, canary, deployment, or fleet rollout was performed. The existing Todos task remains in_progress pending independent review and later controlled rollout work.

Verification

  • full suite: 380 pass, 0 fail, 1,601 expectations
  • bun run typecheck: pass
  • bun run build: pass
  • bun run kit:check: pass
  • git diff --check: pass
  • staged gitleaks git --staged --redact: clean
  • Co-Authored-By scan: clean
  • live source CLI full-profile dry-runs: linux-arm64, macos-arm64, and my-setup each exit 0
  • dry-run evidence preserves unresolved names only (AUTHORIZATION, GUIDE_TEMPLATE, PRIMARYAPIKEY, USAGE_DATA, WINDOW_DAYS) and performs no writes
  • 5 renderers x 3 profiles integration matrix uses every linked profile config, records selected or skipped disposition, keeps the non-overridable policy source exactly once, and preserves OpenCode mcp, model, and manual instruction settings
  • snapshot restore tests cover preview, exact restoration, CLI end-to-end behavior, and refusal after post-apply drift
  • adversarial self-review found and fixed non-overridable policy precedence over newer equivalent noncanonical sources

Live-state boundary

This PR repairs and proves the candidate paths only. It does not claim that persisted cloud profile selectors, live generated provider files, manifests, or installed package state are already reconciled. That remains a separately controlled apply/install/canary/rollout phase.

Rollback

Before merge, close this PR or delete its branch. After merge but before rollout, revert 8b5ff4e292972c1bf53cec7f6b74064d2e5ea5bc for the P1 follow-up and 6b19e1bd37ed945cbb31cfb2d807368c217f38fe for the policy-source commit if a full rollback is required. After any future managed apply, use the recorded snapshot path and instructions session restore <snapshot> --dry-run before restoration; restore refuses drifted applied files.

Independent review

Prior exact-head reviews passed for 6b19e1bd37ed945cbb31cfb2d807368c217f38fe. A fresh independent adversarial review of current head 8b5ff4e292972c1bf53cec7f6b74064d2e5ea5bc is pending and must be reconciled before this task is considered complete.

@andrei-hasna

Copy link
Copy Markdown
Contributor Author

P1 corrections pushed at a6f32706f31910338a45e3001e6ddf933aaf8227.

  • Restore snapshots now distinguish create/update/delete/unchanged and never delete an unchanged fragment.
  • The session renderer is the sole writer for provider instruction entrypoints across library, CLI, MCP, profile, sync, and template paths, including machine-rendered remote-home targets; unrelated OpenCode and Antigravity MCP settings remain writable.
  • General session rendering semantically deduplicates the v1.1.6 operating-rules source across config and identity-export transports, rejecting same-version content conflicts.

Verification: 389 tests / 0 failures / 1662 expectations; typecheck, build, vendor-kit, diff check, staged gitleaks, and live dry-runs for linux-arm64, macos-arm64, and my-setup all pass. No apply/install/canary/rollout was performed. Task remains in progress for fresh independent review.

@andrei-hasna

Copy link
Copy Markdown
Contributor Author

Legacy snapshot P1 repaired at exact head cca14d1d2e3c69fc7b7da62d9c306db79f8205e7.

  • New action-bearing snapshots now write hasna.configs.session-render-snapshot/v2.
  • Existing v1 snapshots with explicit transitional actions remain readable.
  • Actionless legacy v1 snapshots infer only provable update/delete/create intent from before-images plus previousManifest.
  • Same-byte unchanged versus missing/recreated ambiguity fails closed before writes.
  • Real legacy-shape regressions cover restore, unrelated unchanged-file preservation, drift/all-or-nothing, different-hash recreation, equal-hash ambiguity, and required v2 actions.

Verification: sanitized full 393/393 tests (1680 expectations), focused session/integration 40/40, typecheck, build, storage-kit vendor check, diff check, repository package-manager scan, staged gitleaks, and exact commit-range gitleaks all pass. Worktree is clean; local, remote branch, and PR head match. No generated mutation, apply, install, canary, rollout, merge, or main push was performed. Task remains in progress for final review.

@andrei-hasna

Copy link
Copy Markdown
Contributor Author

P1 remediation is ready for fresh exact-head review at 69aa95c3347d6388c4864b383262faea984f08b9.

  • Supports the genuine pre-rollback v1 snapshot shape without targetKind or afterFiles, reconstructing intent only from the matching applied manifest.
  • Fails closed for ambiguous unchanged/recreated files, invalid or missing manifest metadata, and stale snapshots with newer siblings.
  • Aborts an entire config batch before writes when preparation finds duplicate target writers.
  • Validation: sanitized 397/397 tests (1694 expectations), focused hostile regressions, typecheck, build, storage-kit vendor check, diff check, repo package-manager scan, and staged gitleaks.
  • No generated-file mutation, apply, install, canary, rollout, merge, or main push.

@andrei-hasna

Copy link
Copy Markdown
Contributor Author

P1 equivalence correction pushed at exact head b423b707d79d7640dacb8dceae4ba740121f02f2.

  • Centralizes rendered canonical apply behavior across direct generated-output ownership, semantic dedupe, and duplicate-target conflicts.
  • Equivalence includes rendered normalized primary/output targets, rendered primary content, transformed output content, and output agent/transform metadata.
  • Hostile regressions cover rendered direct stale writers, safe templated/literal dedupe, unique-output preservation, and transform-content conflicts.
  • Verification: focused 30/30; full 402/402; typecheck; build; vendor-kit; diff check; staged gitleaks clean.

No merge, install, apply, canary, publish, or rollout performed. Fresh independent review remains pending.

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