Skip to content

docs: rewrite prompt techniques, add nondet rules, rename nav#370

Merged
MuncleUscles merged 2 commits intomainfrom
docs/improve-prompt-techniques-and-nondet-rules
Mar 20, 2026
Merged

docs: rewrite prompt techniques, add nondet rules, rename nav#370
MuncleUscles merged 2 commits intomainfrom
docs/improve-prompt-techniques-and-nondet-rules

Conversation

@MuncleUscles
Copy link
Member

@MuncleUscles MuncleUscles commented Mar 20, 2026

Summary

  • Rewrite "Crafting Prompts" → "Prompt & Data Techniques" with 5 concrete techniques:
    1. Always return JSON (response_format="json")
    2. Extract stable fields from web data
    3. Compare derived status, not raw data
    4. Ground LLM judgments with programmatic eval (spawn_sandbox)
    5. Classify errors ([EXPECTED] vs [EXTERNAL])
  • Add "What Goes Inside vs Outside" to non-determinism.mdx — documents the rules enforced by GenVM linter (E010, E023, E024, E025, E026) with code examples
  • Rename nav: "Decentralized Applications" → "Frontend & SDK Integration"

Test plan

  • Verify lint passes: python scripts/lint-code-examples.py
  • Check Netlify preview renders correctly
  • Verify nav titles display properly

Summary by CodeRabbit

  • Documentation
    • Renamed navigation labels: "Decentralized Applications" → "Frontend & SDK Integration" and "Crafting Prompts" → "Prompt & Data Techniques."
    • Expanded intelligent-contract docs with structured-output guidance, deterministic web-data extraction, a three-step grounding workflow for AI logic, and new error-class conventions.
    • Clarified nondeterminism placement rules with examples and linting reference.
    • Updated validator setup examples to show v0.5.6 as the default available build.

@netlify
Copy link

netlify bot commented Mar 20, 2026

Deploy Preview for genlayer-docs ready!

Name Link
🔨 Latest commit 9dadc20
🔍 Latest deploy log https://app.netlify.com/projects/genlayer-docs/deploys/69bd214bf7b5d300079ee671
😎 Deploy Preview https://deploy-preview-370--genlayer-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 20, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c998a382-31cb-4fbf-8db3-7a6b4b1abd49

📥 Commits

Reviewing files that changed from the base of the PR and between b66fc01 and 9dadc20.

📒 Files selected for processing (5)
  • pages/developers/_meta.json
  • pages/developers/intelligent-contracts/_meta.json
  • pages/developers/intelligent-contracts/crafting-prompts.mdx
  • pages/developers/intelligent-contracts/features/non-determinism.mdx
  • pages/validators/setup-guide.mdx

📝 Walkthrough

Walkthrough

Updated navigation metadata labels and substantially revised intelligent-contract documentation: renamed a couple of menu entries, replaced the “Crafting Prompts” doc with a new “Prompt & Data Techniques” focused on LLM-grounding and deterministic checks, and added nondeterminism placement rules; validator setup example versions were updated.

Changes

Cohort / File(s) Summary
Navigation & Metadata
pages/developers/_meta.json, pages/developers/intelligent-contracts/_meta.json
Updated display labels: "Decentralized Applications""Frontend & SDK Integration", and "Crafting Prompts""Prompt & Data Techniques".
Prompt & Data Techniques Documentation
pages/developers/intelligent-contracts/crafting-prompts.mdx
Replaced prior prompt guidance with a new document on intelligent-contract reliability: enforces machine-parseable JSON outputs, deterministic web-data extraction, consensus-normalized comparisons, a three-step LLM-grounding workflow (JSON checks → deterministic sandbox eval → compliance prompt with ground truth), and standardized error classification ([EXPECTED] vs [EXTERNAL]).
Nondeterminism Constraints
pages/developers/intelligent-contracts/features/non-determinism.mdx
Added “What Goes Inside vs Outside” rules: require gl.nondet.* calls inside nondet blocks (leader/validator/strict_eq), forbid side-effecting operations inside nondet blocks, and referenced genvm-lint check for static detection.
Validator Setup Example
pages/validators/setup-guide.mdx
Updated validator build list and default example version to include v0.5.6 (removed v0.5.1, default export version changed to v0.5.6).

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer (writes prompts/rules)
    participant LLM as LLM (generates checks)
    participant Sandbox as Sandbox Eval (deterministic)
    participant API as External API (leader/validator)
    participant Contract as Compliance Prompt / Contract

    Dev->>LLM: send rule-generation prompt
    LLM->>Dev: return JSON-formatted check expressions
    Dev->>Sandbox: pass JSON checks for deterministic eval
    Sandbox->>API: fetch deterministic fields (independent leader/validator calls)
    API-->>Sandbox: return normalized deterministic fields
    Sandbox->>Sandbox: evaluate checks -> produce verified results
    Sandbox->>Contract: inject verified "ground truth" into compliance prompt
    Contract->>LLM: request final compliance judgement (with ground truth)
    LLM-->>Contract: final, structured decision
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • cristiam86
  • kp2pml30

Poem

🐰 I hop through docs, nibbling old lines away,

New labels gleam bright for developers at play,
Prompts now speak JSON, checks run in a row,
Sandbox verifies truth before answers can go,
Hooray for reliable contracts — hip, hop, hooray!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title concisely and accurately summarizes the three main changes: rewriting prompt techniques documentation, adding nondet rules, and renaming navigation entries.
Description check ✅ Passed The description comprehensively outlines all three major changes with specific details about the five techniques, the nondet rules documentation, and navigation rename, plus includes a clear test plan.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/improve-prompt-techniques-and-nondet-rules
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

…ections

- Rewrite crafting-prompts.mdx → "Prompt & Data Techniques" with 5 concrete
  techniques: JSON responses, stable field extraction, derived status comparison,
  LLM grounding with programmatic eval, error classification
- Add "What Goes Inside vs Outside" section to non-determinism.mdx explaining
  what must/cannot happen inside nondet blocks (storage writes, contract calls,
  message emission, nesting)
- Rename "Decentralized Applications" → "Frontend & SDK Integration" in nav
@MuncleUscles MuncleUscles force-pushed the docs/improve-prompt-techniques-and-nondet-rules branch from b66fc01 to 9dadc20 Compare March 20, 2026 10:28
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
pages/developers/intelligent-contracts/crafting-prompts.mdx (1)

32-32: Small wording polish for docs quality.

Use “Markdown” (proper noun) at Line [32], and “error-handling” (hyphenated compound adjective) at Line [198].

Also applies to: 198-198

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pages/developers/intelligent-contracts/crafting-prompts.mdx` at line 32,
Update the wording in the sentence that currently reads 'Without
`response_format="json"`, LLMs may wrap output in markdown code fences, add
commentary, or return malformed JSON. With it, you get a parsed dict directly.'
to use the proper noun "Markdown" (capitalized). Also change the compound
adjective at the other location that references error handling to the hyphenated
form "error-handling". Locate these phrases in the document by searching for the
exact sentence about response_format="json" and the occurrence of "error
handling" (or similar) and apply the two small wording edits.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pages/developers/intelligent-contracts/features/non-determinism.mdx`:
- Around line 21-31: The example references validator_fn but never defines it;
add a validator function (e.g., validator_fn) alongside leader_fn inside
fetch_price that accepts the leader result (or the raw response) and returns a
boolean indicating validity (for example by verifying parse_price(result)
succeeds and the price is within expected bounds), then pass that validator_fn
to gl.vm.run_nondet_unsafe; ensure the symbols match (leader_fn, validator_fn,
fetch_price, gl.vm.run_nondet_unsafe) so the snippet is runnable.
- Around line 54-58: The validator_fn currently divides by leaders_res.calldata
which can be zero; update validator_fn to guard against divide-by-zero by first
checking if leaders_res.calldata is zero (or near-zero) before performing the
ratio compute — e.g., if leaders_res.calldata == 0 (or abs(leaders_res.calldata)
< small_epsilon) return comparison using direct equality or a tolerance-based
absolute difference, otherwise perform the existing relative check using
abs(leaders_res.calldata - my_price) / leaders_res.calldata <= 0.02; reference
validator_fn, leader_fn, and leaders_res.calldata when implementing the guard.

---

Nitpick comments:
In `@pages/developers/intelligent-contracts/crafting-prompts.mdx`:
- Line 32: Update the wording in the sentence that currently reads 'Without
`response_format="json"`, LLMs may wrap output in markdown code fences, add
commentary, or return malformed JSON. With it, you get a parsed dict directly.'
to use the proper noun "Markdown" (capitalized). Also change the compound
adjective at the other location that references error handling to the hyphenated
form "error-handling". Locate these phrases in the document by searching for the
exact sentence about response_format="json" and the occurrence of "error
handling" (or similar) and apply the two small wording edits.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e0495290-6eeb-468b-8ccd-0718e9177841

📥 Commits

Reviewing files that changed from the base of the PR and between 9728f8c and b66fc01.

📒 Files selected for processing (4)
  • pages/developers/_meta.json
  • pages/developers/intelligent-contracts/_meta.json
  • pages/developers/intelligent-contracts/crafting-prompts.mdx
  • pages/developers/intelligent-contracts/features/non-determinism.mdx

Comment on lines +54 to +58
def validator_fn(leaders_res) -> bool:
if not isinstance(leaders_res, gl.vm.Return):
return False
my_price = leader_fn()
return abs(leaders_res.calldata - my_price) / leaders_res.calldata <= 0.02
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Guard against divide-by-zero in validator ratio check.

Line [58] divides by leaders_res.calldata; if that value is 0, this example throws.

Suggested fix
-        return abs(leaders_res.calldata - my_price) / leaders_res.calldata <= 0.02
+        denom = max(abs(leaders_res.calldata), 1e-9)
+        return abs(leaders_res.calldata - my_price) / denom <= 0.02
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def validator_fn(leaders_res) -> bool:
if not isinstance(leaders_res, gl.vm.Return):
return False
my_price = leader_fn()
return abs(leaders_res.calldata - my_price) / leaders_res.calldata <= 0.02
def validator_fn(leaders_res) -> bool:
if not isinstance(leaders_res, gl.vm.Return):
return False
my_price = leader_fn()
denom = max(abs(leaders_res.calldata), 1e-9)
return abs(leaders_res.calldata - my_price) / denom <= 0.02
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pages/developers/intelligent-contracts/features/non-determinism.mdx` around
lines 54 - 58, The validator_fn currently divides by leaders_res.calldata which
can be zero; update validator_fn to guard against divide-by-zero by first
checking if leaders_res.calldata is zero (or near-zero) before performing the
ratio compute — e.g., if leaders_res.calldata == 0 (or abs(leaders_res.calldata)
< small_epsilon) return comparison using direct equality or a tolerance-based
absolute difference, otherwise perform the existing relative check using
abs(leaders_res.calldata - my_price) / leaders_res.calldata <= 0.02; reference
validator_fn, leader_fn, and leaders_res.calldata when implementing the guard.

@MuncleUscles MuncleUscles merged commit c074800 into main Mar 20, 2026
7 of 8 checks passed
@MuncleUscles MuncleUscles deleted the docs/improve-prompt-techniques-and-nondet-rules branch March 20, 2026 10:32
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