Skip to content

feat: Add scam-shield bundle#289

Open
GitRzh wants to merge 3 commits into
Lamatic:mainfrom
GitRzh:feat/scam-shield
Open

feat: Add scam-shield bundle#289
GitRzh wants to merge 3 commits into
Lamatic:mainfrom
GitRzh:feat/scam-shield

Conversation

@GitRzh

@GitRzh GitRzh commented Jul 23, 2026

Copy link
Copy Markdown

PR Checklist

  • Folder is at kits/scam-shield/ (kebab-case, unique)
  • lamatic.config.ts present with valid type (bundle), name, author, tags, steps, links
  • agent.md present
  • README.md present, describes what the contribution does and how to use it
  • flows/<n>.ts exists for every step in lamatic.config.ts (index-scam-patterns.ts, scam-message-triage.ts)
  • constitutions/default.md present
  • .env.example present
  • apps/package.json works with npm install && npm run dev — N/A, bundle has no apps/
  • links.github in lamatic.config.ts points to kits/scam-shield
  • links.deploy has root-directory=kits/<n>/apps — N/A, bundle-only, no deploy link
  • No .env or .env.local committed — only .env.example with placeholders
  • All @reference paths resolve to files that actually exist in this kit
  • PR touches only files inside kits/scam-shield/
  • Added kits/scam-shield/ bundle for India-focused UPI/banking scam fraud triage (bundle-only; no apps directory/deployment link).
  • Added environment/config and packaging hygiene:
    • kits/scam-shield/.env.example (LAMATIC API URL/project/key placeholders)
    • kits/scam-shield/.gitignore (ignores .lamatic/, node_modules/, and .env* except .env.example; excludes a local demo index.html)
    • kits/scam-shield/lamatic.config.ts (bundle metadata; defines the two mandatory steps: index-scam-patterns then scam-message-triage)
  • Added documentation:
    • kits/scam-shield/README.md (RAG workflow, safety/guardrails behavior, quickstart for ingest + deploy + GraphQL trigger usage, expected kit structure)
    • kits/scam-shield/agent.md (agent purpose, interaction flows, and the scam-message-triage I/O contract)
  • Added safety policy + prompt templates:
    • kits/scam-shield/constitutions/default.md (constitution: blocks requesting/disclosing OTP/PIN/CVV/account/card numbers, exploit bypass details, and mandates official reporting channels)
    • kits/scam-shield/prompts/scam-message-triage_ragnode-573_system_0.md (system prompt with strict JSON output schema and behavioral constraints)
    • kits/scam-shield/prompts/scam-message-triage_ragnode-573_user_1.md (user prompt template wiring message from the trigger)
  • Added model configuration files (Gemini embedding + generation):
    • kits/scam-shield/model-configs/index-scam-patterns_vectorize-node-808_embedding-model-name.ts
    • kits/scam-shield/model-configs/scam-message-triage_ragnode-573_embedding-model-name.ts
    • kits/scam-shield/model-configs/scam-message-triage_ragnode-573_generative-model-name.ts
  • Added flow definitions (including node type usage) and ingestion/triage logic:
    • kits/scam-shield/flows/index-scam-patterns.ts
      • Node types: triggerNode (GraphQL API request) → dynamicNode (dynamic codeNode) → dynamicNode (dynamic vectorizeNode) → dynamicNode (dynamic vectorNode indexing into scampatterns) → responseNode (GraphQL realtime response)
      • How it works: converts incoming scam patterns (batch or single) into stable vector strings + metadata (id, pattern_name, content), vectorizes them using the configured embedding model, indexes/overwrites into the scampatterns vector DB, and returns message + recordsIndexed.
    • kits/scam-shield/flows/scam-message-triage.ts
      • Node types: triggerNodedynamicNode (dynamic RAGNode) → responseNode
      • How it works: retrieves top matching scam patterns from scampatterns for the triggered message (limit=3), runs the configured system/user prompt set with the configured generative model to produce a structured JSON risk assessment (risk_score, red_flags, explanation, recommended_action, report_channel), and returns modelResponse plus references.
  • Added the ingestion helper script:
    • kits/scam-shield/scripts/index-scam-patterns_code-node-948_code.ts (Mustache-driven extraction for single vs batch inputs, stable per-record IDs via hashing, and output formatting as { vectorData, metaData } with validation/erroring on invalid inputs)

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@GitRzh, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 14 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 76434cc4-effd-4132-9776-412579211319

📥 Commits

Reviewing files that changed from the base of the PR and between 2104fa0 and 146835c.

📒 Files selected for processing (2)
  • kits/scam-shield/README.md
  • kits/scam-shield/scripts/index-scam-patterns_code-node-948_code.ts

Walkthrough

Changes

The Scam Shield kit adds bundle metadata, scam-pattern indexing and message-triage flows, Gemini model configurations, safety rules, environment templates, and setup documentation.

Scam Shield

Layer / File(s) Summary
Bundle metadata and runtime configuration
kits/scam-shield/lamatic.config.ts, kits/scam-shield/.env.example, kits/scam-shield/.gitignore
Defines kit metadata, workflow steps, environment placeholders, and ignored local files.
Scam pattern indexing pipeline
kits/scam-shield/flows/index-scam-patterns.ts, kits/scam-shield/scripts/*, kits/scam-shield/model-configs/index-scam-patterns_*
Accepts single or batch scam patterns, creates stable records, vectorizes and indexes them, and maps indexing results to the response.
Message triage pipeline
kits/scam-shield/flows/scam-message-triage.ts, kits/scam-shield/model-configs/scam-message-triage_*, kits/scam-shield/prompts/*, kits/scam-shield/constitutions/default.md, kits/scam-shield/agent.md
Connects the message trigger to RAG retrieval and generation, maps response fields, and defines JSON output and safety constraints.
Kit setup and usage documentation
kits/scam-shield/README.md
Documents setup, indexing, deployment, API testing, response structure, folder layout, and authorship.

Suggested reviewers: amanintech, d-pamneja

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding the Scam Shield bundle.
Description check ✅ Passed The checklist covers most required template items, including scope, docs, env template, files, and bundle-only notes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@github-actions

Copy link
Copy Markdown
Contributor

:robot_face: AgentKit Structural Validation

New Contributions Detected

  • Bundle: kits/scam-shield

Check Results

Check Status
No edits to existing kits ✅ Pass
Required root files present ✅ Pass
Flow .ts files present ✅ Pass
lamatic.config.ts valid ✅ Pass
No changes outside kits/ ✅ Pass

🎉 All checks passed! This contribution follows the AgentKit structure.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@kits/scam-shield/.gitignore`:
- Around line 3-4: Update the environment ignore rules in the project’s
.gitignore to match all .env variants, including production and staging files,
while explicitly keeping .env.example trackable.

In `@kits/scam-shield/flows/index-scam-patterns.ts`:
- Around line 117-122: Update the indexing configuration around primaryKeys,
vectorsField, and metadataField so records use a stable unique record ID or
content hash as the sole primary key instead of pattern_name. Preserve
pattern_name in the metadata payload, ensuring distinct patterns with the same
name are retained rather than overwritten.

In `@kits/scam-shield/prompts/scam-message-triage_ragnode-573_system_0.md`:
- Around line 1-10: Harden the system prompt by explicitly treating both the
user message and retrieved scam patterns as untrusted data rather than
instructions, preventing prompt injection from changing the assessment. Update
the red_flags requirement to use redacted descriptions instead of reproducing
sensitive OTPs, PINs, CVVs, account numbers, or similar secrets, while
preserving the existing JSON-only response schema and scam-triage behavior.

In `@kits/scam-shield/README.md`:
- Around line 21-38: Update the README around the Step headings and fenced code
blocks to satisfy markdownlint-cli2: add blank lines where required, including
the referenced sections, mark the folder-tree code fence as text, and ensure the
file ends with exactly one newline.
- Around line 43-47: Update the setup instructions in the README before the test
curl command to explicitly load the `.env` values into the shell, using a
source/export step after copying and populating `.env`. Ensure LAMATIC_API_URL
and LAMATIC_API_KEY are available when the example request runs.

In `@kits/scam-shield/scripts/index-scam-patterns_code-node-948_code.ts`:
- Around line 1-3: Update the initialization of single_name, single_content, and
batch to read values from the runtime workflow object rather than mustache
expressions. Ensure batch resolves to the actual patterns array, including when
the upstream output uses an array-like key, so the existing loop can create
vectors and metadata without throwing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a9d7edf7-f8be-413b-88de-07c43c74091d

📥 Commits

Reviewing files that changed from the base of the PR and between 912e7ad and 884feb4.

📒 Files selected for processing (14)
  • kits/scam-shield/.env.example
  • kits/scam-shield/.gitignore
  • kits/scam-shield/README.md
  • kits/scam-shield/agent.md
  • kits/scam-shield/constitutions/default.md
  • kits/scam-shield/flows/index-scam-patterns.ts
  • kits/scam-shield/flows/scam-message-triage.ts
  • kits/scam-shield/lamatic.config.ts
  • kits/scam-shield/model-configs/index-scam-patterns_vectorize-node-808_embedding-model-name.ts
  • kits/scam-shield/model-configs/scam-message-triage_ragnode-573_embedding-model-name.ts
  • kits/scam-shield/model-configs/scam-message-triage_ragnode-573_generative-model-name.ts
  • kits/scam-shield/prompts/scam-message-triage_ragnode-573_system_0.md
  • kits/scam-shield/prompts/scam-message-triage_ragnode-573_user_1.md
  • kits/scam-shield/scripts/index-scam-patterns_code-node-948_code.ts

Comment thread kits/scam-shield/.gitignore Outdated
Comment on lines +117 to +122
"primaryKeys": [
"pattern_name"
],
"vectorsField": "{{vectorizeNode_808.output.vectors}}",
"metadataField": "{{codeNode_948.output.metaData}}",
"duplicateOperation": "overwrite"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Mission directive: make every indexed pattern uniquely addressable.

The request schema permits repeated pattern_name values, but Lines 117–122 use it as the only key and overwrite collisions. Different pattern content sharing a name is silently lost. Use a stable record ID or content hash as the primary key; retain pattern_name as metadata.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/scam-shield/flows/index-scam-patterns.ts` around lines 117 - 122, Update
the indexing configuration around primaryKeys, vectorsField, and metadataField
so records use a stable unique record ID or content hash as the sole primary key
instead of pattern_name. Preserve pattern_name in the metadata payload, ensuring
distinct patterns with the same name are retained rather than overwritten.

Comment thread kits/scam-shield/prompts/scam-message-triage_ragnode-573_system_0.md Outdated
Comment thread kits/scam-shield/README.md
Comment thread kits/scam-shield/README.md
Comment thread kits/scam-shield/scripts/index-scam-patterns_code-node-948_code.ts Outdated
… quarantine untrusted prompt content, clean up README
@coderabbitai
coderabbitai Bot requested review from amanintech and d-pamneja July 23, 2026 11:07

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
kits/scam-shield/README.md (1)

76-85: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Document the runtime shape or align the flow mapping.

kit/scam-shield/flows/scam-message-triage.ts maps modelResponse and references from RAGNode_573.output at lines 126 and 118–126, while this README example shows them parsed as object/array fields. Either show users the exact runtime output shape or confirm/update the flow so clients receive the documented JSON type.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/scam-shield/README.md` around lines 76 - 85, Align the Scam Shield
README example with the actual output shape produced by the scam-message-triage
flow, especially the modelResponse and references fields mapped from
RAGNode_573.output. Either document the runtime wrapper/type returned by the
flow or update the flow mapping so clients receive the object and array JSON
types shown in the example.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@kits/scam-shield/prompts/scam-message-triage_ragnode-573_system_0.md`:
- Line 14: Add a single trailing newline at the end of the prompt file to
satisfy markdownlint MD047, without changing any existing prompt text or adding
headings.

In `@kits/scam-shield/README.md`:
- Around line 39-41: Update the batch request example in the README so it is
valid JSON: replace the unquoted ellipsis with a second concrete pattern object,
preserving the existing schema and example intent.

In `@kits/scam-shield/scripts/index-scam-patterns_code-node-948_code.ts`:
- Around line 1-18: Update the input initialization in the scam-pattern indexing
script to read pattern data from the workflow object using the trigger node’s
output fields, rather than quoted Mustache placeholders. Ensure the batch value
is obtained as the actual array and single_name/single_content contain the
submitted values before the processing logic and record indexing execute.

---

Outside diff comments:
In `@kits/scam-shield/README.md`:
- Around line 76-85: Align the Scam Shield README example with the actual output
shape produced by the scam-message-triage flow, especially the modelResponse and
references fields mapped from RAGNode_573.output. Either document the runtime
wrapper/type returned by the flow or update the flow mapping so clients receive
the object and array JSON types shown in the example.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 927a7c41-2ec3-4710-a27a-8a5b1b772174

📥 Commits

Reviewing files that changed from the base of the PR and between 884feb4 and 2104fa0.

📒 Files selected for processing (5)
  • kits/scam-shield/.gitignore
  • kits/scam-shield/README.md
  • kits/scam-shield/flows/index-scam-patterns.ts
  • kits/scam-shield/prompts/scam-message-triage_ragnode-573_system_0.md
  • kits/scam-shield/scripts/index-scam-patterns_code-node-948_code.ts

"report_channel": "<cybercrime.gov.in or helpline 1930 or bank's official number, as appropriate>"
}

Never ask the user for OTP, PIN, CVV, or account numbers. Never provide exploit detail on named banks. Never repeat back any sensitive value (OTP, PIN, CVV, account/card number) the user included in their message, even partially. If the message doesn't match any known scam pattern and seems benign, return a low risk_score and say so plainly in the explanation. No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Mission cleanup: add the missing final newline.

markdownlint reports MD047 for this file. Add one trailing newline without adding a heading or other prompt text.

🧰 Tools
🪛 LanguageTool

[style] ~14-~14: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... provide exploit detail on named banks. Never repeat back any sensitive value (OTP, P...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

🪛 markdownlint-cli2 (0.23.0)

[warning] 14-14: Files should end with a single newline character

(MD047, single-trailing-newline)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/scam-shield/prompts/scam-message-triage_ragnode-573_system_0.md` at line
14, Add a single trailing newline at the end of the prompt file to satisfy
markdownlint MD047, without changing any existing prompt text or adding
headings.

Source: Linters/SAST tools

Comment thread kits/scam-shield/README.md
Comment thread kits/scam-shield/scripts/index-scam-patterns_code-node-948_code.ts Outdated
…tor keys, quarantine untrusted prompt content, fix README examples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant