# Policy Retrieval via Input Routing

This page explains how to dynamically retrieve the correct policy file (e.g., `.docx`, `.json`, or `.yaml`) based on user-provided context like `user_region`, `submission_type`, and `user_role`.

This is a **core pattern** in the Global Control Copilot template, where logic and validation depend on loading the right ruleset for the right user at the right time.

Whether you're pulling from a **static dataset**, using **in-memory config**, or accessing **GLIK Knowledge**, this page shows you exactly how to route logic and retrieve the right file — without hardcoding anything.

***

### 🧩 What This Pattern Enables

* ✅ Load MiCA, SOX, or fallback policies based on `user_region`
* ✅ Adjust document-based compliance logic dynamically per session
* ✅ Inject policy text into downstream LLM blocks, classifiers, and decisions
* ✅ Enable jurisdiction-aware automation at runtime
* ✅ Keep workflows modular, reusable, and future-proof

***

### 🔁 High-Level Pattern

```
IF/ELSE → SET VARIABLE → GET POLICY → (use in logic / LLM)
```

This means:

1. You detect the input conditions
2. You set a policy key (e.g., `policy_reference = "SOX"`)
3. You fetch the associated file or memory chunk using that key
4. You inject the contents downstream

***

### 🖼️ Example Logic (Visual from Studio)

**IF/ELSE Conditions:**

* `region == EU`
* `submission_type == Disclosure`
* `user_role == Finance Manager`\
  → then `SET policy_reference = "MiCA"`

**GET POLICY Block:**

* File name or memory key: `{{policy_reference}}.docx`

***

### 📂 Example Policy Files

These files live in your GLIK Cloud Dataset or are registered in memory/knowledge.

| policy\_reference | File Name                | Source Type       |
| ----------------- | ------------------------ | ----------------- |
| `MiCA`            | `MiCA_EU.docx`           | Dataset           |
| `SOX`             | `SOX_Controls_2025.json` | Dataset or Memory |
| `GDPR`            | `GDPR-Disclosure.yaml`   | Knowledge         |
| `Fallback_Policy` | `InternalPolicy.pdf`     | Static default    |

Best practice: Keep the file name aligned with the variable (e.g., `policy_reference = SOX` → `SOX.docx`).

***

### 💡 Tips for Builders

#### ✅ Save Point Logging

Always log the policy name for auditability and traceability.

```json
{
  "user_region": "US",
  "submission_type": "Attestation",
  "user_role": "Legal Counsel",
  "policy_reference": "SOX"
}
```

#### ✅ Add `session_label` or `policy_source` tags in memory:

```yaml
session_label: "SOX US Submission"
policy_source: "Dataset"
```

***

### 🛡️ Fallback Handling

If no policy matches the user's inputs:

1. Use a default case in your `IF/ELSE` block:

```yaml
ELSE → SET policy_reference = "Fallback_Policy"
```

2. Add a logic check before GET POLICY:

```yaml
IF policy_reference == null → route to escalation or system error handling
```

***

### 🔐 Dataset Access & Security

#### ✅ Public or Shared Dataset Policies:

* Easy to reuse
* Visible across workspaces (read-only recommended)

#### ✅ Private Dataset Policies:

* Best for sensitive rules
* Assign roles in the GLIK Workspace permissions

#### ✅ In-Memory Policies:

* Fastest for demos
* Good for SDK-based dynamic injection

***

### 🔄 Common Questions (and Clear Answers)

#### ❓ What if I want to store the policy in memory instead of a dataset?

You can. Just assign `policy_reference = "MiCA"` and use the `Memory Get` or direct memory block instead of `GET POLICY`. Same pattern applies.

***

#### ❓ Can I use `Knowledge Retrieval` instead of `GET POLICY`?

Yes. If your policies are stored as chunks in GLIK Knowledge, use the `Knowledge Retrieval` block and query by `policy_reference`.

```yaml
retriever_query:
  policy_name: {{policy_reference}}
```

***

#### ❓ What if my file isn’t found?

Handle this gracefully with a fallback route:

```yaml
IF policy_reference == null OR file not found:
  escalate = true
  error_message = "Policy not found for session"
```

***

#### ❓ Can I pass the full contents of the file into the LLM?

Yes. After `GET POLICY`, pipe the output into your `LLM` block prompt like:

```txt
Here is the policy content:
{{policy_document.text}}

Review this submission against the rules above...
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.glik.ai/templates/compliance-advisors/global-control-copilot-cross-jurisdiction-policy-interpreter/policy-retrieval-via-input-routing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
