DueCare Harness Ecosystem¶
DueCare should not be described as one monolithic harness. The codebase has a core content-safety harness, but it also has multiple repeatable workflows that wrap Gemma 4 with preprocessing, post-processing, tools, retrieval, evaluation, training, graphing, privacy checks, and export contracts.
For project language, use this definition:
A DueCare harness is any named, repeatable set of steps around Gemma 4 or a trust boundary that transforms inputs, adds context, calls tools, evaluates outputs, protects privacy, generates training data, or emits auditable artifacts for a specific goal.
Canonical implementation sources¶
| Source | Role |
|---|---|
packages/duecare-llm-chat/src/duecare/chat/harness/__init__.py |
Legacy singular module that still holds the canonical GREP rules, RAG corpus, tool dispatch, and combined grading primitives used by Kernel 01 and A-00. |
packages/duecare-llm-chat/src/duecare/chat/harnesses/ |
Registered reviewer-facing harness surfaces with name, applied_layers, consumes, emits, spec, and register_routes(app). |
packages/duecare-llm-chat/src/duecare/chat/harnesses/model_interface.py |
Provider-neutral model request/response helper for harnesses that need local Gemma, DueCare adapters, Ollama, OpenAI-compatible endpoints, Anthropic, Gemini, HF endpoints, frontier APIs, or test callables. |
packages/duecare-llm-chat/src/duecare/chat/gemma4_runtime.py |
Shared Gemma 4 runtime primitive for loading, unloading, and generating with Unsloth FastModel. |
packages/duecare-llm-chat/src/duecare/chat/experiment_contracts.py |
Shared experiment profiles for harness comparison, synthetic data, training, and comparison matrices. |
kaggle/01-duecare-exploration-workbench/kernel.py |
Canonical live exploration and harness comparison workbench. |
kaggle/A-00-omni-experiment-workbench/kernel.py |
Quantitative control plane for benchmark runs, synthetic data, LoRA training, judging, reports, and research graphs. |
The harness documentation trinity¶
Three documents define the DueCare harness system. Read them as a set:
docs/harness_ecosystem.md(this file) — vocabulary, inventory of registered harnesses, broader harness families, naming conventions. The "what we have" view.docs/harness_pattern.md— required module contract (name,applied_layers,register_routes), per-task JSONL training-data flow, and the 10-step recipe for adding a new registered harness. The "how to build one" view.docs/harness_standard_contract.md— theHarnessSpecfield shape:logic_paths,knowledge_packs,logic_packs,model_io,model_targets,input_verification,output_verification,privacy_boundaries. The "fields each harness declares" view.
If the three documents disagree about a registered harness, this file is authoritative for the inventory. Update the others to match.
Universal model-target layer¶
Every registered harness now declares model_targets in its HarnessSpec.
This separates the harness workflow from the model provider:
- local Kaggle proof runs use
gemma4_runtimeand the shared UnslothFastModelloader; - local/private deployments can route through
ollama,llama_cpp,transformers,unsloth, or a genericduecare_model_adapter; - cloud or frontier judging can route through
openai_compatible,anthropic,google_gemini,hf_inference_endpoint, orfrontier_api; - deterministic gates such as anonymization, search safety, search, and
import explicitly declare
nonetargets so they remain usable without an LLM.
The privacy boundary travels with the target. External targets should receive only redacted, generalized, or policy-approved content.
Registered harness surfaces¶
These are the modules exposed through duecare.chat.harnesses.
| Harness | Purpose | Gemma 4 role | Status |
|---|---|---|---|
chat |
Free-form content prompt processing with persona, GREP, RAG, tools, optional official-source checks, optional online, imports, traces, and grading hooks. | Required for real answers. | Implemented. |
process |
Bulk file review, case-bundle parsing, graph extraction, and graph-chat over local evidence. | Hybrid: deterministic parsing first, Gemma for graph-chat and deeper extraction. A fine-tuned Gemma 4 adapter can improve document classification and bulk edge generation. | Implemented. |
extraction |
Draft typed KnowledgeObject envelopes from source text, documents, or process outputs. | Optional drafter; deterministic hints remain available without a model. | Implemented. |
anonymization |
PII and confidential-data gate before sharing or submission. | Optional second review over already-redacted text. | Implemented. |
search_safety |
Convert raw search intent into redacted or generalized search phrases before third-party search. | Optional rephrase over already-redacted query. | Implemented as a gate. |
post_search_verification |
Verify search result candidates for source quality, relevance, contradictions, and deanonymization risk before prompt injection. | Optional local review over sanitized snippets; deterministic gate first. | Implemented as a gate. |
triage |
Batch safety screening on ONE model: GREP rules, then one flag/clear verdict from the already-loaded Gemma (the chat page's model — no second model, no endpoint, no switch), with an optional deeper GREP/RAG/tools-grounded pass on flagged items (same model). | Model is optional; degrades honestly to passed_grep_only with no model loaded. The verdict routes, it never answers. |
Implemented. |
search |
Run a selected search backend after query sanitization and return result cards. | Downstream only; search itself is not a model call. | Implemented utility. |
import_corpus |
Store local uploaded evidence and snippets for later use by chat, process, and extraction. | No model call; supplies context to other harnesses. | Implemented utility. |
Broader harness families¶
The following are also harnesses under the broader DueCare definition because they encapsulate repeatable logic around Gemma 4, a trust boundary, or an auditable proof artifact.
| Harness family | Current code path | What it does | Status |
|---|---|---|---|
| Core layer composer | harness/__init__.py, harnesses/_layers.py |
Composes persona, GREP, RAG, tools, official-source checks, online, and imports into the grounding Gemma receives. | Implemented. |
| Content safety response harness | harnesses/chat, Kernel 01 compare, A-00 chat_no_online |
Runs prompts with and without the safety stack, captures traces, and produces comparable outputs. | Implemented. |
| Offline default proof harness | A-00 preconfigured pipeline | Uses chat_no_online: persona + GREP + RAG/context + deterministic tools, with internet/import disabled for the default reproducible run. |
Implemented. |
| Search anonymization harness | harnesses/search_safety |
Redacts private facts and can ask Gemma to generalize the query before it reaches a search provider. | Implemented. |
| Official-source checking harness | chat official_sources layer, harnesses/search_safety, harnesses/post_search_verification |
Runs targeted internet checks against allowlisted official domains such as DMW/POEA, Hong Kong Labour/e-Legislation, ILO, IOM, and UNODC. Non-official results are discarded before prompt injection. | Implemented; off by default. |
| Online grounding harness | harnesses/search, harnesses/search_safety, harnesses/post_search_verification, chat online layer, A-00 documented path |
Intended path: prompt -> Gemma-anonymized query -> search -> page markdown/snippets -> verification -> KnowledgeObjects -> prompt injection. | Partially implemented; default A-00 run keeps it off. |
| Post-search verification harness | harnesses/post_search_verification |
Reviews downloaded/search-result candidates for relevance, source quality, contradictions, and deanonymization risk before any result is injected. | Implemented first deterministic gate; deeper page-markdown review can be added. |
| Anonymization/deanonymization review harness | harnesses/anonymization, A-00 _redact |
Redacts PII, records hashes, and can run local residual-PII review before hub submission or external calls. | Implemented; external-boundary policy should stay strict. |
| Knowledge ingestion harness | harnesses/import_corpus, harnesses/extraction, harness/_governance.py |
Turns local files, snippets, or source bundles into reviewable, versioned knowledge objects. | Implemented. |
| Civil-society fact intake harness | Contribute flow plus import/extraction/anonymization modules | Should process NGO/civil-society emails or submissions into sanitized fact proposals and knowledge objects. | Partially implemented through generic import/extraction; dedicated email intake remains a specialization to build. |
| Research graph harness | harnesses/process, A-00 _extract_research_graph |
Extracts entities, edges, timeline signals, amounts, risks, and graph artifacts from local bundles. Uses typed edge schemas, pointed edge questions, and edge-quality dimensions; fine-tuned Gemma 4 can improve classification and edge proposals when available. | Implemented. |
| Synthetic data generator harness | A-00 _generate_synthetic, SYNTHETIC_GENERATION_PROFILES |
Generates SFT rows, DPO pairs, test prompts, and candidate knowledge facts from harnessed/adversarial prompts. | Implemented. |
| Rubric-polish harness | A-00 _polish_training_response |
Rewrites training rows toward the DueCare response contract: cited, bounded, privacy-safe, and structured. | Implemented. |
| Fine-tuning harness | A-00 _training_script, TrainRequest, TRAINING_PROFILES, duecare-llm-training |
Builds LoRA training jobs, checkpoint/resume paths, adapter outputs, and training logs. | Implemented. |
| Evaluation/judge harness | grade_response_universal, grade_response_combined, A-00 judge selection |
Combines deterministic rules with local Gemma or external judge options for final scoring. | Implemented. |
| Report/export harness | A-00 report and activity artifacts | Saves JSON, Markdown, HTML, run outputs, traces, activity events, and comparison summaries for writeups. | Implemented and still being improved. |
| Model runtime primitive | gemma4_runtime.py |
Standardizes Unsloth FastModel load/unload/generate behavior across notebooks. |
Implemented primitive; not a user-facing safety harness. |
Search and online grounding policy¶
Online grounding can be valuable, but it must not bypass the privacy and verification harnesses.
The safe target flow is:
- Identify what public fact is missing.
- Redact or generalize the search intent locally.
- Let Gemma produce a sanitized query from the redacted intent.
- Search only with that sanitized query.
- Convert pages to bounded snippets or markdown.
- Run a post-search verification pass for relevance, source quality, conflict, and deanonymization risk.
- Convert accepted facts into KnowledgeObjects.
- Inject only accepted knowledge objects or cited snippets into the final prompt.
The chat workbench also has a narrower official-source layer for targeted checks against allowlisted public authority sites. It is separate from generic online search: it keeps a per-check plan, records accepted official results, and discards non-official domains before the model sees them.
For the A-00 preconfigured proof run, online and official-source grounding remain off by default because the demo needs reproducibility and a clean privacy boundary.
Naming guidance¶
Use "harness ecosystem" for the full DueCare system. Use "core content-safety harness" or "chat harness" when referring specifically to persona + GREP + RAG + tools + optional official-source/online grounding around a prompt.
Avoid saying DueCare is "one harness" unless the sentence is explicitly about one runtime surface. Better wording:
- "DueCare is a Gemma 4 harness ecosystem for migrant-worker safety."
- "The chat harness is one harness in the ecosystem."
- "A-00 runs the benchmark, synthetic-data, fine-tuning, judging, and report harnesses in sequence."
- "The online harness is privacy-gated and should verify search results before they become context."
Current gaps to avoid overstating¶
- A dedicated civil-society email intake harness is not a separate first-class module yet. The current path is generic import -> anonymization -> extraction -> reviewer promotion.
- Post-search verification now exists as a registered deterministic gate, but deeper page-markdown review should be added before online grounding becomes a default benchmark layer.
- External frontier judges can be configured, but the competition default must remain runnable without paid API keys.