You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 387bf15
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: .claude/agent-memory/archgate-developer/project_rules_engine_internals.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,3 +16,7 @@ metadata:
16
16
- **Scanner walk drops any node `AstNodeSchema.safeParse` rejects — WITH its whole subtree — so an over-strict schema is a silent security false-negative, not a validation nicety. Now ADR-governed (ARCH-024 clause 7).** `parseNode()` returns null on schema failure and the walk skips it (`if (child) walk(child)`), so a banned global/eval/import nested inside a rejected node goes unscanned and `check` reports pass. `type` is always present and every typed child field recurses, so a `Literal`'s `value` is the ONLY leaf that can independently fail — keep it `z.unknown().optional()` (read only via `typeof … === "string"` guards). Fired twice: null `source` on `export`-without-`from` (#493), and exotic `value` — meriyah emits `{}` for a RegExpLiteral and a `bigint` for `123n` (#494, e.g. `/x/.constructor.constructor` = Function ctor off a regex receiver). Always fix by WIDENING the schema (the block already exists, it's just unreached), never by adding a new check. Zod gotcha: `z.unknown()` is NON-optional in this Zod (v4) — bare `z.unknown()` made every node lacking `value` fail; needs `.optional()`.
17
17
-**`Bun.Transpiler` strips provably-dead code before the scanner sees it — this is correct, not a gap.**`const y = /x/ || import("node:child_process")` transpiles to `const y = /x/;` (a RegExp literal is always truthy, so the `||` right side is unreachable and eliminated). Unreachable payloads genuinely never run, so not scanning them is right. When writing an escape regression test, put the payload in a REACHABLE position (`[/x/, import(...)]`, comma operator, a separate statement) and confirm `transformSync` keeps it — else the test passes for the wrong reason.
18
18
- **Spawning a language interpreter to parse an untrusted project file is an RCE surface — the specifics are now ADR-governed (ARCH-022), noted here for any FUTURE interpreter-subprocess feature.** (1) `python -c` puts the target project cwd on `sys.path`, so a planted `ast.py`/`json.py` executes when the serializer imports stdlib — always pass `-I` (isolated). Verified: without `-I`, `import ast` resolves to a cwd shadow. (2) Python's plain `utf-8` codec keeps the BOM as U+FEFF and `ast.parse` then errors — read with `utf-8-sig` (`r:bom|utf-8` for Ruby). (3) `meriyah` `loc` after `Bun.Transpiler` is transpiled-relative, NOT original-source lines (type-only/comment/blank lines dropped) — re-locate via `readFile`+`indexOf` for the TS path; JS is parsed untranspiled so its `loc` is accurate. (4) Windows: probe the `py` launcher too (python.org registers it even when PATH opt-in is unchecked). The single sanctioned meriyah call site is `src/engine/js-parser.ts`; interpreter probe/spawn is `src/engine/ast-support.ts`.
19
+
-**Fire-test a guard in BOTH directions: that it blocks the bad case AND still permits the legitimate one.** Proving a guard is load-bearing (stub it out → test fails) only shows the gate closes; it says nothing about over-rejection. 2026-07-25: the ARCH-024 ancestor-symlink guard (#499) passed a green suite while rejecting _every_ symlinked component below the project root, including links pointing back INSIDE the project — which breaks workspace monorepos (pnpm/npm/yarn/bun symlink `node_modules/<pkg>` → `packages/<pkg>`) and symlinked shared source dirs. It reached main before the false positive was caught; fixed in #500 by gating on the link's resolved TARGET rather than its existence. For any boundary check, write the allow-case test alongside the deny-case one.
20
+
-**`realpath` comparisons must be realpath-against-realpath, never realpath-against-lexical.**`realpathSync` case-canonicalizes on Windows and macOS, so comparing its output against a lexically-built path rejects case-mismatched-but-legitimate paths. Resolve both sides — see `realRootOf` in `src/engine/safe-path.ts`. This is why the first version of the symlink walk deliberately used boolean `lstat` instead.
21
+
-**When testing an "empty X" case, test the degenerate form, not a near-empty variant.** A test named "returns {} for an empty frontmatter block" used `---\n\n---` — a blank line the body group can capture — and passed, hiding that the truly empty `---\n---` did not match at all. The near-miss variant exercises a different path than the one the test name claims.
22
+
-**Never chain cleanup of a temp script with `&&`, and never `git add -A` after using one.**`python fix.py && rm -f fix.py` leaves the script behind whenever it exits non-zero — exactly when a failed edit makes cleanup most necessary — and a later `git add -A` commits it. A throwaway `fix-sec-test.py` reached PR #500 this way (2026-07-25) and the maintainer caught it in review; nothing in `validate` flags a stray root-level `.py` (not linted, not in `src/`, invisible to knip). Use `; rm -f` or a `trap`, prefer `git add <explicit paths>`, and check `git diff --name-only origin/main...HEAD | grep -v /` before pushing.
0 commit comments