Improve causal tracing, refund demo, and Next.js roadmap - #55
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 421627a373
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ])], | ||
| ); | ||
|
|
||
| path.insertBefore(t.variableDeclarator(t.cloneNode(traceIdentifier), traceCall)); |
There was a problem hiding this comment.
Keep trace temporaries out of named exports
When a traced binding is declared as export const canRefund = ..., inserting the trace declarator before this VariableDeclarator adds it to the same exported variable declaration. Development output therefore unexpectedly exports the generated _canRefundDerivation value, changing the module namespace between development and production and potentially affecting consumers that enumerate exports or Fast Refresh boundary detection. Insert the temporary in a separate, non-exported declaration instead.
Useful? React with 👍 / 👎.
| const sensitiveResult = typeof result !== "boolean" && sensitiveInputs.size > 0; | ||
| this.#recordExpression( | ||
| input.metadata, | ||
| sensitiveResult ? "[REDACTED]" : result, |
There was a problem hiding this comment.
Preserve the observed value when evaluating conditional renders
When a sensitive derived non-boolean feeds conditional JSX—for example const visible = account.secret.value || ""; return <div>{visible && <Private />}</div>—this replaces the actual expression result with "[REDACTED]" before #recordExpression calls evaluateConditionalRender. Because logical rendering is inferred from the result's truthiness and object type, a genuinely rendered React element is then reported as hidden; ternaries can likewise select the wrong branch when a falsy sensitive operand becomes the truthy redaction marker. Keep the real value for internal condition/outcome evaluation and redact only the stored/displayed trace.
AGENTS.md reference: AGENTS.md:L9-L9
Useful? React with 👍 / 👎.
| if (operator !== "===" && operator !== "!==" && (needsUserCoercion(left) || needsUserCoercion(right))) { | ||
| return COERCION_UNAVAILABLE; |
There was a problem hiding this comment.
Preserve observed ternary tests when coercion is unavailable
For a direct conditional render whose test requires object coercion, such as expiresAt < now ? <Expired /> : <Active /> with Date operands, this now makes the binary evaluation unavailable. evaluateCondition then falls back to the overall JSX result rather than the observed test value; because either ternary branch is a truthy React element, evaluateConditionalRender always reports the consequent even when the alternate was rendered. Capture the test result during the original evaluation or leave the branch explicitly unavailable instead of substituting the rendered branch value.
AGENTS.md reference: AGENTS.md:L9-L9
Useful? React with 👍 / 👎.
Publish the derived-condition tracing, evidence redaction, refund demo, and Vite-first roadmap work from #55 as causescope 1.0.0-beta.8.
What changed
disabled={!canRefund}throughorder.status === "paid"toGET /api/orders/4821 · 200.Why
The previous public demo did not demonstrate CauseScope's strongest value: following a rendered UI decision back through state to the network response that produced it. The tracing engine also needed stronger guarantees for real-world derived expressions, repeated reads, sensitive data, and ambiguous evidence.
Impact
The README now shows the end-to-end refund evidence chain in under eight seconds. Runtime evidence is more accurate and bounded, sensitive values remain redacted, ordinary interactions stay responsive, and unsupported Next.js/RSC behavior is stated explicitly instead of implied.
Validation
pnpm checkgit diff --check