# Repository collaboration rules ## Task boundaries and efficient execution - Before editing, confirm the active repository, worktree, claimed paths, and existing changes. Honor task claims and never override another task's paths. - Read only the files needed for the request. Batch independent local inspections; keep commands bounded and avoid duplicate searches, broad output, unnecessary network calls, polling, retries, and downloads. - Complete the requested outcome and its required checks, then stop. Do not expand into adjacent cleanup or release work. - Keep task-owned processes bounded, stop those no longer needed, and verify they stopped. Never stop user-owned or pre-existing processes. - A file-change request does not authorize commits, pushes, PR creation or merge, deployment, migrations, email sends, or other external writes; do these only when explicitly requested. Report only changes and checks actually performed. ## Product and commercialization scope - Treat Insight and PriorSeal as a three-part commercial portfolio by default: Insight can be sold independently, PriorSeal can be sold independently, and Insight + PriorSeal can be sold as an integrated decision, authorization, execution, and verification evidence workflow. - Do not narrow customer discovery, positioning, partnerships, pricing, or go-to-market work to PriorSeal alone unless the user explicitly asks for PriorSeal-only work. - When evaluating prospects, identify which of the three offers fits the buyer instead of assuming that every prospect should buy both products. ## Public identity and product links - Use `YuTao Peng` as the user's full name. - Add the `YuTao Peng` signature only to emails. Do not add a name/signature closing to GitHub comments, Issues, Discussion replies, direct messages, private messages, chat messages, or similar conversational posts unless the user explicitly requests one for that specific message. - Insight website: `https://www.oracleinsight.xyz/` - Insight GitHub: `https://github.com/imokokok/Insight.git` - PriorSeal website: `https://priorseal.xyz/` - PriorSeal GitHub: `https://github.com/imokokok/PriorSeal.git` ## Email reply workflow For inbox audits and email replies, read and follow [the detailed email workflow](.github/agent-guidance/email-reply-workflow.md). Sending remains the final release step. ## Git identity and publishing - For authorized GitHub work, reuse the existing GitHub CLI authentication with `gh` while `gh auth status` confirms it is valid. Do not ask the user to log in again while that stored session works. If it expires, start the standard `gh auth login --hostname github.com --web --git-protocol https` flow and let the user complete any browser/device authorization. Never ask the user to paste a token into chat, print long-lived credentials, or write GitHub tokens into repository files, project instructions, or Codex memory. - During GitHub device authorization, show the user the current one-time device code and verification URL in the active conversation when needed for their approval. Never store the device code; if it expires, start a fresh device flow. - Before creating or rewriting a commit, verify that both author and committer use `imokokok <145034722+imokokok@users.noreply.github.com>`. - Never use a generated, agent, shared-machine, or other third-party identity for commits in this repository. - Before reporting a push as successful, verify `origin/main` (or the requested remote ref) by SHA. - For GitHub network operations, try the configured direct connection first. If it fails or times out, automatically detect and retry through the user's local proxy without waiting for another instruction. When ClashX is listening on `127.0.0.1:7890`, prefer command-scoped `git -c http.proxy=http://127.0.0.1:7890 -c https.proxy=http://127.0.0.1:7890 ...` settings; do not persist proxy settings globally. - Using a proxy must never change the required author or committer identity. Re-verify both identities before committing and verify the requested remote ref by SHA after pushing. - Preserve remote history by default. Use a force push only when the user explicitly requests a history rewrite, and prefer `--force-with-lease`. ## Local Node.js version - The repository pins Node.js `22.23.2` in `.node-version` and `.nvmrc`. CI reads `node-version-file: .node-version`, the production image uses `node:22.23.2-alpine`, and `engines.node` stays `22.x`. - Run `nvm use` (or `fnm use`) after entering the repository. `npm run prepare` does not install a Node version for you, so a shell that defaults to another major will fail the CI parity step. - A shell hook that switches automatically is optional; if you add one, keep it scoped to this directory. Do not change the machine-wide default Node.js version for other projects. ## TypeScript source policy - Write all new production, integration, deployment, migration, and operational source code in TypeScript. Use `.mts` for Node ESM code and `.ts`/`.tsx` in the SDK and web workspaces. - Treat checked-in `.mjs` files beside `.mts` files as generated runtime artifacts. Edit the TypeScript source and run `npm run core:build`; never edit those generated files directly. - JavaScript is allowed only for reviewed build tooling, frozen portable examples, generated standalone verifiers, and legacy tests that have not yet justified migration. Adding a new JavaScript exception requires an explicit repository-policy change. - Keep runtime validation at every untrusted JSON, signature, RPC, HTTP, environment, and persistence boundary; TypeScript types do not replace protocol validation. ## Local Vercel access - The user authorized reuse of the saved Vercel credential in future tasks. On this workstation, load `VERCEL_TOKEN` from `/Users/imokokok/Documents/insight/.env.vercel.local` for authorized Vercel work; do not ask the user to supply it again while it remains valid. - This private, Git-ignored file also holds the verified Insight Vercel team/project identifiers when available. PriorSeal production runs on Cloudflare; do not change its hosting provider as part of credential configuration. - Never print the credential, put it in tracked files, expose it to browser code, or add it to application runtime variables. For Node commands, use `--env-file=/Users/imokokok/Documents/insight/.env.vercel.local`; API tools should load it privately and use the Authorization header. - Reusing a credential does not authorize unrelated deployments or account changes. If authentication fails, report the failure and request a replacement only when needed. ## Database resource consumption - For every change that reads, writes, scans, batches, retries, or schedules database work, assess the resource dimensions it affects: rows examined and returned, query count, index/scan shape, page depth or cursor use, bytes read and written, batch size, transaction duration, concurrency/fanout, retries, storage growth, compute time, network egress, and schedule frequency. Bound per-request and per-run work where appropriate. A SQL `LIMIT` caps returned rows, not necessarily scanned or billed rows. - Prefer index-backed filters, keyset pagination for sequential history reads, bounded batches, and idempotent writes. Preserve the user-required collection cadence and product capabilities; account for fallback and failover paths when assessing load. - Before introducing provider quotas or hard limits, assess whether exhaustion can suspend service or redirect load to another database. Do not treat application-side row counts as provider-billed usage. - Support resource-savings claims with provider usage metrics and timestamps. Label estimates and application-level counters separately; do not claim a reduction until comparable before/after usage data exists. ## Partner joint-run instructions - For partner integration preparation, rehearsal, fresh bundles, live execution, post-run verification, or replies, first read `/Users/imokokok/Documents/partnerships/AGENTS.md`, then `/Users/imokokok/Documents/partnerships/COLLABORATION-DOCS-STANDARD.md`, then `/Users/imokokok/Documents/partnerships/JOINT-RUN-PLAYBOOK.md`. Continue with the partnerships root README, the partner README, and the current stage fact sources. These rules supplement this repository's rules. - Apply this read order at a new joint-run task/window or context resumption. Within an unchanged continuous task, reuse already-read rules and recheck changed rules and the latest partner status. Dated retrospectives explain historical lessons; current partner facts determine scope, permissions and protocol conditions. - Follow the user's order for rehearsals and live runs: perform the authorized work and preserve raw evidence immediately; deliver complete English and Chinese replies in the conversation, explicitly stating required attachments and final files or no attachment; update formal collaboration documents last. Preserve existing authorization and required per-bundle GO or single-send gates; do not mark a draft as sent. ## Parallel agent worktrees - One task = one branch = one worktree in `~/Documents/insight-worktrees/PriorSeal-`. Never do feature work, `git checkout`, `git reset --hard`, `git clean`, or `git stash` in the primary checkout. - Exactly one agent/session is the write owner of a worktree at a time. Other agents working on that task may do read-only research or review. If multiple agents need to write, give each a separate task branch and worktree with declared, non-overlapping paths; never point concurrent writers at the same worktree or Git index. - Parallelize only tasks whose declared paths and outputs can be integrated independently. Coordinate one owner for overlapping files and keep dependency manifests (`package.json`, any nested lockfile), cron bundles, migration files, and release/deployment configuration serial. Do not bypass a refused path claim with `--override`. - Run the shared tool from this repository's root with `node ~/Documents/insight/scripts/worktree.mjs `. The script prints the exact commands for this repository; there is no `npm run wt` here. - Declare the files a task will touch with `create --paths "..."`. A refused claim means another active task owns that path; coordinate instead of overriding. - Dependency manifests (`package.json`, any nested lockfile), cron bundles, and migration files are serial by category. A dependency change requires `deps --isolate` before `npm install`; never install through the shared `node_modules` symlink. - `status` reports the stage each task is stuck in and the next action. `ship` is the only commit/push/PR/auto-merge path; it verifies the required `release-check` gate before merging and refuses on overlap with another open PR. - Write `.handoff.local` with `handoff --next "..."` before a long pause; resume with `resume ` instead of re-deriving context. - Before a manual rebase, reset, branch replacement/deletion, force push, or forced worktree removal, record the old `HEAD`, create and verify a durable recovery ref such as `codex/rescue--`, and preserve any dirty files. A reflog-only commit is at risk and is not a recovery plan. Prefer the managed `ship`/`finish` flow over manual branch surgery. - Before removing a task worktree or branch, confirm it is clean and its commits are merged into the intended base or protected by a durable recovery ref. Never use `--force` when the task's uncommitted work or unique commits have not been reviewed. - If GitHub/remote status cannot be read, treat PR, CI, and merge state as unknown. A blank status column or network error is not proof that a branch or PR is absent; defer cleanup or branch replacement until the remote state is verified. - After verifying the change is merged on the target remote, check whether `ship` already removed this worktree. If it remains, confirm there are no uncommitted changes or handoff material to keep, then run `node ~/Documents/insight/scripts/worktree.mjs remove --delete-branch`. This releases the task claim and removes that task's worktree and local branch. Keep unmerged or dirty worktrees; never remove another task's worktree.