<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: suvendu kumar sahoo</title>
    <description>The latest articles on DEV Community by suvendu kumar sahoo (@suvendukungfu).</description>
    <link>https://dev.to/suvendukungfu</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4162790%2F2a4ab700-a8d0-48d4-bb2f-3c610d9e2e41.jpg</url>
      <title>DEV Community: suvendu kumar sahoo</title>
      <link>https://dev.to/suvendukungfu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/suvendukungfu"/>
    <language>en</language>
    <item>
      <title>Never Lose Your Context Again.</title>
      <dc:creator>suvendu kumar sahoo</dc:creator>
      <pubDate>Thu, 22 Oct 2026 09:43:22 +0000</pubDate>
      <link>https://dev.to/suvendukungfu/never-lose-your-context-again-367</link>
      <guid>https://dev.to/suvendukungfu/never-lose-your-context-again-367</guid>
      <description>&lt;h1&gt;
  
  
  🚀 Hacktoberfest 2026 — Week 4: Building ContextKeeper | Evidence-Driven AI, Local-First Recovery &amp;amp; Engineering Beyond the Demo
&lt;/h1&gt;

&lt;p&gt;This Hacktoberfest, I've been building *&lt;em&gt;ContextKeeper *&lt;/em&gt;, a local-first developer productivity tool designed to help developers reconstruct interrupted coding sessions from repository evidence.&lt;/p&gt;

&lt;p&gt;The central problem is simple, but technically interesting:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What happens when your IDE crashes, your terminal closes, your AI coding-agent session disappears, or you return to a project after losing the context of what you were working on?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You might have uncommitted changes, untracked files, partially implemented functions, stale test logs, incomplete documentation, and no reliable record of the original task.&lt;/p&gt;

&lt;p&gt;Git can show committed history and working-tree changes. Documentation can explain intended architecture. Test logs can describe earlier execution results. A local language model can interpret code and suggest possibilities.&lt;/p&gt;

&lt;p&gt;But none of those sources, individually, necessarily tells you exactly what happened during an interrupted session.&lt;/p&gt;

&lt;p&gt;I wanted to approach this problem from a different engineering perspective:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Instead of asking an AI to guess what happened, reconstruct the observable state first, preserve evidence, distinguish facts from assumptions, and make uncertainty explicit.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That idea became ContextKeeper.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 1. The Problem ContextKeeper Is Trying to Solve
&lt;/h2&gt;

&lt;p&gt;Modern development involves multiple tools, branches, terminals, coding agents, partial implementations, and context switches.&lt;/p&gt;

&lt;p&gt;When a session is interrupted, a developer may need to reconstruct:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which branch and commit they were working on.&lt;/li&gt;
&lt;li&gt;Whether the working tree contains staged, unstaged, untracked, renamed, deleted, or conflicted files.&lt;/li&gt;
&lt;li&gt;Which parts of the implementation appear to have changed recently.&lt;/li&gt;
&lt;li&gt;Which source files, configuration files, and documents are relevant.&lt;/li&gt;
&lt;li&gt;Whether a test log represents the current code or an earlier version.&lt;/li&gt;
&lt;li&gt;Which conclusions are directly supported by repository artifacts.&lt;/li&gt;
&lt;li&gt;Which likely explanations are only inferences.&lt;/li&gt;
&lt;li&gt;Which parts of the original objective cannot be determined without clarification.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Traditional recovery based only on commit history misses uncommitted work. Persistent AI memory can retain useful context, but it may not reflect the actual current filesystem state. Automatically executing the project's tests or scripts may also be inappropriate when inspecting an unfamiliar or sensitive repository.&lt;/p&gt;

&lt;p&gt;ContextKeeper is designed to address this gap with a &lt;strong&gt;deterministic, passive recovery pipeline and optional local AI interpretation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The guiding principle is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Reconstruct what the evidence supports. Explain what can reasonably be inferred. Preserve what remains unknown.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🎯 2. What Is ContextKeeper 2.0?
&lt;/h2&gt;

&lt;p&gt;ContextKeeper is a local-first project recovery application with three main ways to interact with its capabilities:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A command-line interface for developers who prefer scripts, terminals, and structured output.&lt;/li&gt;
&lt;li&gt;An interactive local web dashboard for exploring claims, evidence, changes, and recommendations.&lt;/li&gt;
&lt;li&gt;An optional AI-assisted interpretation mode that uses a locally hosted Ollama model.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The recovery engine is designed to operate independently of AI. Local AI can provide a qualitative narrative, but it is not the authority for determining repository facts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Core capabilities
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Repository inspection&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Git working-tree status.&lt;/li&gt;
&lt;li&gt;Staged and unstaged diffs.&lt;/li&gt;
&lt;li&gt;Untracked files, deletions, renames, and conflicts.&lt;/li&gt;
&lt;li&gt;Recent commit history.&lt;/li&gt;
&lt;li&gt;Selected source files, package manifests, and project documentation.&lt;/li&gt;
&lt;li&gt;Explicitly supplied historical test logs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Evidence and provenance&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Structured evidence records.&lt;/li&gt;
&lt;li&gt;Relative file paths and line locators.&lt;/li&gt;
&lt;li&gt;SHA-256 content digests.&lt;/li&gt;
&lt;li&gt;Stable, content-derived evidence identifiers.&lt;/li&gt;
&lt;li&gt;Evidence freshness and redaction metadata.&lt;/li&gt;
&lt;li&gt;Cross-references between claims and evidence records.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Deterministic recovery&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;FACT&lt;/code&gt;, &lt;code&gt;INFERENCE&lt;/code&gt;, and &lt;code&gt;UNKNOWN&lt;/code&gt; classification.&lt;/li&gt;
&lt;li&gt;Defensive validation of evidence identifiers.&lt;/li&gt;
&lt;li&gt;Explicit limitations and knowledge gaps.&lt;/li&gt;
&lt;li&gt;State-dependent, conservative recovery recommendations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Developer experience&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Markdown recovery dossiers.&lt;/li&gt;
&lt;li&gt;Machine-readable JSON output.&lt;/li&gt;
&lt;li&gt;Interactive dashboard.&lt;/li&gt;
&lt;li&gt;Claim filters and search.&lt;/li&gt;
&lt;li&gt;Evidence inspector.&lt;/li&gt;
&lt;li&gt;Git diff viewer.&lt;/li&gt;
&lt;li&gt;Prioritized next steps.&lt;/li&gt;
&lt;li&gt;Markdown and JSON export.&lt;/li&gt;
&lt;li&gt;Optional light and dark themes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Optional local AI&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ollama integration.&lt;/li&gt;
&lt;li&gt;Loopback-only endpoint policy.&lt;/li&gt;
&lt;li&gt;Bounded, redacted evidence input.&lt;/li&gt;
&lt;li&gt;Structured model responses.&lt;/li&gt;
&lt;li&gt;Evidence-reference validation.&lt;/li&gt;
&lt;li&gt;Deterministic fallback when inference is unavailable, malformed, or too slow.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The intention is to make session recovery useful without requiring a cloud AI account or mandatory remote processing.&lt;/p&gt;




&lt;h2&gt;
  
  
  🏗️ 3. Technology Stack and Engineering Choices
&lt;/h2&gt;

&lt;p&gt;ContextKeeper uses a deliberately lightweight stack.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Area&lt;/th&gt;
&lt;th&gt;Technology&lt;/th&gt;
&lt;th&gt;Responsibility&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Language&lt;/td&gt;
&lt;td&gt;TypeScript&lt;/td&gt;
&lt;td&gt;Typed application logic and domain contracts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Runtime&lt;/td&gt;
&lt;td&gt;Node.js&lt;/td&gt;
&lt;td&gt;Application execution and native APIs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Module system&lt;/td&gt;
&lt;td&gt;ECMAScript modules&lt;/td&gt;
&lt;td&gt;Modular source code and compiled distribution&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Filesystem&lt;/td&gt;
&lt;td&gt;&lt;code&gt;node:fs/promises&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Bounded read-only repository inspection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Git execution&lt;/td&gt;
&lt;td&gt;&lt;code&gt;node:child_process.execFile&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Controlled subprocess calls without shell interpolation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HTTP server&lt;/td&gt;
&lt;td&gt;&lt;code&gt;node:http&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Local dashboard and API&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cryptography&lt;/td&gt;
&lt;td&gt;&lt;code&gt;node:crypto&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;SHA-256 content digest generation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CLI parsing&lt;/td&gt;
&lt;td&gt;&lt;code&gt;node:util.parseArgs&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Command and option parsing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Local AI&lt;/td&gt;
&lt;td&gt;Ollama HTTP API&lt;/td&gt;
&lt;td&gt;Optional locally hosted inference&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tests&lt;/td&gt;
&lt;td&gt;Node.js native test runner&lt;/td&gt;
&lt;td&gt;Unit, integration, security, and evaluation tests&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Type checking&lt;/td&gt;
&lt;td&gt;TypeScript compiler&lt;/td&gt;
&lt;td&gt;Static type validation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Distribution&lt;/td&gt;
&lt;td&gt;npm executable package&lt;/td&gt;
&lt;td&gt;CLI packaging and installation&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;One architectural decision was to avoid production runtime dependencies wherever practical.&lt;/p&gt;

&lt;p&gt;The reported implementation declares zero production dependencies and primarily uses Node.js standard-library APIs. TypeScript and Node.js type declarations are development dependencies.&lt;/p&gt;

&lt;p&gt;This reduces dependency overhead and simplifies distribution, although it does not eliminate every security risk: the application still needs careful input validation, safe subprocess handling, robust HTTP controls, and dependency/build verification.&lt;/p&gt;

&lt;p&gt;The dashboard also uses a self-contained HTML/CSS/JavaScript interface rather than depending on a remote UI service or CDN.&lt;/p&gt;




&lt;h1&gt;
  
  
  📐 4. Architecture Diagram 1 — System Context
&lt;/h1&gt;

&lt;p&gt;This diagram shows how the developer, CLI, dashboard, security controls, inspection subsystems, recovery engine, evidence records, and optional local AI fit together.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TB
    subgraph Users["Users and Interfaces"]
        Dev["Developer using CLI"]
        BrowserDev["Developer using Browser"]
    end

    subgraph Entrypoints["Entrypoints and Presentation"]
        CLI["CLI Entry Point&amp;lt;br/&amp;gt;bin/contextkeeper.js → src/cli.ts"]
        WebUI["Local Dashboard&amp;lt;br/&amp;gt;127.0.0.1:3333"]
        DashServer["Dashboard Server&amp;lt;br/&amp;gt;dashboardServer.ts"]
        DashHTML["Dashboard Client&amp;lt;br/&amp;gt;dashboardHtml.ts"]
        Formatters["Markdown and JSON Formatters"]
    end

    subgraph Security["Security and Boundaries"]
        PathGuard["Path and Symlink Guard"]
        Redactor["Secret Redactor"]
        GitRunner["Restricted Git Runner"]
    end

    subgraph Inspection["Passive Inspection"]
        Inspector["Inspection Orchestrator"]
        GitInspector["Git Inspector"]
        FileInspector["Filesystem Inspector"]
        Digest["SHA-256 and Evidence IDs"]
    end

    subgraph Recovery["Deterministic Recovery"]
        Engine["Recovery Engine"]
        Claims["Claim Generator"]
        Dossier[("Recovery Dossier")]
    end

    subgraph LocalAI["Optional Local AI"]
        Provider["Ollama Provider"]
        Ollama["Local Ollama Daemon"]
    end

    Repo["Selected Repository&amp;lt;br/&amp;gt;Working Tree and Git Data"]

    Dev --&amp;gt; CLI
    BrowserDev --&amp;gt; WebUI
    WebUI &amp;lt;--&amp;gt; DashServer
    DashServer --&amp;gt; DashHTML
    CLI --&amp;gt; Inspector
    DashServer --&amp;gt; Inspector

    CLI --&amp;gt; PathGuard
    DashServer --&amp;gt; PathGuard

    Inspector --&amp;gt; GitInspector
    Inspector --&amp;gt; FileInspector
    GitInspector --&amp;gt; GitRunner
    GitRunner --&amp;gt; Repo
    FileInspector --&amp;gt; Repo
    FileInspector --&amp;gt; PathGuard

    GitInspector --&amp;gt; Redactor
    FileInspector --&amp;gt; Redactor
    Redactor --&amp;gt; Digest

    Inspector --&amp;gt; Engine
    Engine --&amp;gt; Claims
    Claims --&amp;gt; Dossier
    Engine --&amp;gt; Dossier

    Dossier --&amp;gt; Formatters
    Formatters --&amp;gt; CLI
    Dossier --&amp;gt; DashServer

    Engine -.-&amp;gt; Provider
    Provider &amp;lt;--&amp;gt; Ollama
    Provider -.-&amp;gt; Dossier&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;&lt;strong&gt;Architectural takeaway:&lt;/strong&gt; both user interfaces rely on the same recovery foundation. The dashboard is not intended to become a separate source of truth, and optional AI does not replace deterministic evidence collection.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔍 5. The Evidence Pipeline
&lt;/h2&gt;

&lt;p&gt;The core of ContextKeeper is not the dashboard or the model. It is the process of turning repository artifacts into traceable evidence.&lt;/p&gt;

&lt;p&gt;The pipeline starts by validating the target repository path. The Git and filesystem inspection subsystems then gather bounded observations. Sensitive content is redacted, content is normalized, and evidence identifiers are generated.&lt;/p&gt;

&lt;p&gt;The recovery engine consumes those records and constructs a dossier.&lt;/p&gt;

&lt;p&gt;A typical evidence record may contain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An evidence ID, such as &lt;code&gt;ev_git_status_...&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A source type, such as Git status, commit history, diff hunk, project document, or source file.&lt;/li&gt;
&lt;li&gt;A relative path or other locator.&lt;/li&gt;
&lt;li&gt;A content digest.&lt;/li&gt;
&lt;li&gt;A capture timestamp and freshness classification.&lt;/li&gt;
&lt;li&gt;Redaction status.&lt;/li&gt;
&lt;li&gt;Bounded content or an excerpt.&lt;/li&gt;
&lt;li&gt;Metadata about skipped files or inspection limitations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;SHA-256 helps identify the captured content. It does &lt;strong&gt;not&lt;/strong&gt; prove that the content is semantically correct or that a claim derived from it is true.&lt;/p&gt;

&lt;h3&gt;
  
  
  Architecture Diagram 2 — Component Architecture
&lt;/h3&gt;



&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    Bin["bin/contextkeeper.js"]

    subgraph Entry["Application Entrypoints"]
        CLI["src/cli.ts"]
        Index["src/index.ts"]
    end

    subgraph Presentation["Presentation"]
        Server["src/server/dashboardServer.ts"]
        HTML["src/server/dashboardHtml.ts"]
        Markdown["markdownFormatter.ts"]
        Text["textFormatter.ts"]
    end

    subgraph Recovery["Core Recovery"]
        Engine["recoveryEngine.ts"]
        Generator["claimsGenerator.ts"]
        Types["src/types.ts"]
    end

    subgraph Inspection["Inspection"]
        Inspector["src/inspector.ts"]
        Git["gitInspector.ts"]
        FS["fileInspector.ts"]
        Runner["gitRunner.ts"]
    end

    subgraph Security["Security and Integrity"]
        Guard["pathGuard.ts"]
        Redactor["redactor.ts"]
        Digest["evidence/digest.ts"]
    end

    AI["src/ai/localAiProvider.ts"]

    Bin --&amp;gt; CLI
    Index --&amp;gt; Types
    Index --&amp;gt; Inspector
    Index --&amp;gt; Engine
    Index --&amp;gt; Server

    CLI --&amp;gt; Inspector
    CLI --&amp;gt; Engine
    CLI --&amp;gt; Markdown
    CLI --&amp;gt; Text
    CLI --&amp;gt; Server
    CLI --&amp;gt; AI

    Server --&amp;gt; HTML
    Server --&amp;gt; Guard
    Server --&amp;gt; Inspector
    Server --&amp;gt; Engine
    Server --&amp;gt; Markdown
    Server --&amp;gt; AI

    Inspector --&amp;gt; Guard
    Inspector --&amp;gt; Git
    Inspector --&amp;gt; FS

    Git --&amp;gt; Runner
    Git --&amp;gt; Redactor
    Git --&amp;gt; Digest

    FS --&amp;gt; Guard
    FS --&amp;gt; Redactor
    FS --&amp;gt; Digest

    Engine --&amp;gt; Generator
    Generator --&amp;gt; Digest
    Generator --&amp;gt; Types

    Markdown --&amp;gt; Types
    Text --&amp;gt; Types
    AI --&amp;gt; Types&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;This diagram represents the documented module boundaries. The actual implementation still has some tightly coupled responsibilities, particularly in the CLI, dashboard server, and embedded dashboard asset.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔄 6. Architecture Diagram 3 — Deterministic CLI Recovery
&lt;/h2&gt;

&lt;p&gt;The CLI workflow illustrates how ContextKeeper reconstructs project state without asking an AI model to establish the facts.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;sequenceDiagram
    autonumber
    actor Developer
    participant Bin as bin/contextkeeper.js
    participant CLI as src/cli.ts
    participant Guard as pathGuard.ts
    participant Inspector as inspector.ts
    participant Git as gitInspector.ts
    participant Runner as gitRunner.ts
    participant FS as fileInspector.ts
    participant Redactor as redactor.ts
    participant Digest as digest.ts
    participant Engine as recoveryEngine.ts
    participant Claims as claimsGenerator.ts
    participant Formatter as markdownFormatter.ts

    Developer-&amp;gt;&amp;gt;Bin: contextkeeper recover . --report markdown
    Bin-&amp;gt;&amp;gt;CLI: runCli(argv)
    CLI-&amp;gt;&amp;gt;CLI: Parse and validate options
    CLI-&amp;gt;&amp;gt;Guard: validateTargetRoot(".")
    Guard--&amp;gt;&amp;gt;CLI: Canonical repository root

    CLI-&amp;gt;&amp;gt;Inspector: inspectRepository(root, options)

    Inspector-&amp;gt;&amp;gt;Git: inspectGitRepository(root)
    Git-&amp;gt;&amp;gt;Runner: Read-only Git status and diffs
    Runner--&amp;gt;&amp;gt;Git: Bounded Git output
    Git-&amp;gt;&amp;gt;Redactor: Redact sensitive content
    Git-&amp;gt;&amp;gt;Digest: Generate evidence digest and ID
    Git--&amp;gt;&amp;gt;Inspector: Git evidence records

    Inspector-&amp;gt;&amp;gt;FS: inspectFilesystem(root, options)
    FS-&amp;gt;&amp;gt;Guard: Validate contained file paths
    FS-&amp;gt;&amp;gt;Redactor: Redact selected file content
    FS-&amp;gt;&amp;gt;Digest: Generate evidence identifiers
    FS--&amp;gt;&amp;gt;Inspector: File evidence and warnings

    Inspector--&amp;gt;&amp;gt;CLI: InspectionResult
    CLI-&amp;gt;&amp;gt;Engine: reconstructProjectState(result)
    Engine-&amp;gt;&amp;gt;Claims: generateClaims(result)
    Claims-&amp;gt;&amp;gt;Claims: Classify and validate claims
    Claims--&amp;gt;&amp;gt;Engine: Recovery claims
    Engine-&amp;gt;&amp;gt;Engine: Generate safe recommendations
    Engine--&amp;gt;&amp;gt;CLI: Recovery dossier

    CLI-&amp;gt;&amp;gt;Formatter: Format Markdown
    Formatter--&amp;gt;&amp;gt;CLI: Recovery report
    CLI--&amp;gt;&amp;gt;Developer: Write report to stdout&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;The key design property is the separation between collecting observable state and interpreting it. The CLI should not need to run the inspected project's tests, execute its scripts, or modify its repository to construct the recovery report.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧾 7. The Claim Model: FACT, INFERENCE, UNKNOWN
&lt;/h2&gt;

&lt;p&gt;One of ContextKeeper's central architectural decisions is to make the epistemic status of a statement explicit.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;FACT&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;A directly supported observation.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The repository is on a particular branch.&lt;/li&gt;
&lt;li&gt;A specific file exists.&lt;/li&gt;
&lt;li&gt;A Git status query reports uncommitted changes.&lt;/li&gt;
&lt;li&gt;A captured diff contains particular lines.&lt;/li&gt;
&lt;li&gt;A source file contains a particular exported declaration.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A FACT must cite one or more valid evidence records. A valid identifier is necessary, but identifier existence alone is not sufficient to prove semantic support.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;INFERENCE&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;A reasoned interpretation based on evidence.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Active edits may indicate that work was in progress when a session ended.&lt;/li&gt;
&lt;li&gt;A TODO marker may indicate an unfinished implementation concern.&lt;/li&gt;
&lt;li&gt;Related untracked files may be part of the same development task.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An inference must explain its rationale and limitations. It should never be presented as direct observation.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;UNKNOWN&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;A meaningful limitation of the available evidence.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The original user objective cannot be reconstructed reliably from code alone.&lt;/li&gt;
&lt;li&gt;A test log does not establish the current working tree's test status if code changed after the log was generated.&lt;/li&gt;
&lt;li&gt;A source declaration does not prove successful execution.&lt;/li&gt;
&lt;li&gt;Conflicting documents do not always reveal which intended behavior is correct.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Preserving UNKNOWN is not a failure to reason. It prevents a recovery tool from sending the developer in the wrong direction with unjustified certainty.&lt;/p&gt;

&lt;h3&gt;
  
  
  Architecture Diagram 4 — Evidence-to-Claim Flow
&lt;/h3&gt;



&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart LR
    subgraph Raw["Repository Artifacts"]
        Status["Git Status"]
        Diff["Git Diffs"]
        Log["Commit History"]
        Docs["Documentation"]
        Code["Source Files"]
        TestLog["Approved Historical Test Log"]
    end

    subgraph Sanitize["Sanitization and Normalization"]
        Redact["Secret Redaction"]
        Hash["Normalize Lines and Hash Content"]
        ID["Generate Evidence IDs"]
    end

    Evidence[("Evidence Records")]

    subgraph Synthesis["Claim Generation"]
        Fact["FACT Rules"]
        Infer["INFERENCE Rules"]
        Unknown["UNKNOWN Rules"]
        Verify["Citation Verification"]
    end

    subgraph Ledger["Auditable Claim Ledger"]
        Facts["Evidence-backed facts"]
        Inferences["Explicitly labeled inferences"]
        Unknowns["Documented knowledge gaps"]
    end

    Status --&amp;gt; Redact
    Diff --&amp;gt; Redact
    Log --&amp;gt; Redact
    Docs --&amp;gt; Redact
    Code --&amp;gt; Redact
    TestLog --&amp;gt; Redact

    Redact --&amp;gt; Hash --&amp;gt; ID --&amp;gt; Evidence

    Evidence --&amp;gt; Fact
    Evidence --&amp;gt; Infer
    Evidence --&amp;gt; Unknown

    Fact --&amp;gt; Verify
    Infer --&amp;gt; Verify
    Unknown --&amp;gt; Verify

    Verify --&amp;gt; Facts
    Verify --&amp;gt; Inferences
    Verify --&amp;gt; Unknowns&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;This workflow aims to make each recovery conclusion inspectable rather than relying on a single free-form generated summary.&lt;/p&gt;

&lt;h3&gt;
  
  
  Architecture Diagram 5 — Claim Classification and Validation
&lt;/h3&gt;



&lt;pre data-lang="mermaid"&gt;&lt;code&gt;stateDiagram-v2
    [*] --&amp;gt; CandidateObservation

    state CandidateObservation {
        [*] --&amp;gt; CheckEvidence
        CheckEvidence --&amp;gt; HasEvidence: Evidence exists
        CheckEvidence --&amp;gt; NoEvidence: Evidence missing
    }

    HasEvidence --&amp;gt; EvaluateCertainty

    state EvaluateCertainty {
        DirectObservation: Direct observation
        Deduction: Deductive reasoning
        Conflict: Stale or conflicting evidence
    }

    DirectObservation --&amp;gt; FactCandidate
    Deduction --&amp;gt; InferenceCandidate
    Conflict --&amp;gt; UnknownCandidate
    NoEvidence --&amp;gt; UnknownCandidate

    state FactCandidate {
        [*] --&amp;gt; CitationAudit
        CitationAudit --&amp;gt; CitationsValid: IDs resolve
        CitationAudit --&amp;gt; CitationsInvalid: IDs missing
    }

    CitationsValid --&amp;gt; FACT
    CitationsInvalid --&amp;gt; UNKNOWN
    InferenceCandidate --&amp;gt; INFERENCE
    UnknownCandidate --&amp;gt; UNKNOWN

    FACT --&amp;gt; [*]
    INFERENCE --&amp;gt; [*]
    UNKNOWN --&amp;gt; [*]&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;The classification model is designed to be conservative. Its remaining challenge is semantic validation: ensuring that the wording of a claim is actually justified by the content it cites.&lt;/p&gt;




&lt;h2&gt;
  
  
  🌐 8. The Interactive Dashboard
&lt;/h2&gt;

&lt;p&gt;The CLI is useful for automation, terminal workflows, and piping results into other tools. The dashboard makes the same information easier to explore.&lt;/p&gt;

&lt;p&gt;The local dashboard includes:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Recovery overview&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Repository path, branch, commit, and working-tree state.&lt;/li&gt;
&lt;li&gt;Claim counts by classification.&lt;/li&gt;
&lt;li&gt;Evidence counts and inspection statistics.&lt;/li&gt;
&lt;li&gt;Warnings and skipped-file reasons.&lt;/li&gt;
&lt;li&gt;Recovery recommendations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Claim ledger&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Search by claim text or ID.&lt;/li&gt;
&lt;li&gt;Filter by FACT, INFERENCE, and UNKNOWN.&lt;/li&gt;
&lt;li&gt;Sort and inspect claim details.&lt;/li&gt;
&lt;li&gt;View rationale, limitations, and evidence references.&lt;/li&gt;
&lt;li&gt;Navigate from a claim to its supporting evidence.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Evidence inspector&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Evidence ID and source type.&lt;/li&gt;
&lt;li&gt;File or Git locator.&lt;/li&gt;
&lt;li&gt;SHA-256 digest.&lt;/li&gt;
&lt;li&gt;Freshness and redaction status.&lt;/li&gt;
&lt;li&gt;Bounded content inspection.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Changes viewer&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Staged and unstaged diffs.&lt;/li&gt;
&lt;li&gt;Untracked files.&lt;/li&gt;
&lt;li&gt;Readable, line-oriented change inspection.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Report preview and export&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Markdown recovery report.&lt;/li&gt;
&lt;li&gt;Structured JSON dossier.&lt;/li&gt;
&lt;li&gt;Downloadable outputs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Visual experience&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Light and dark themes.&lt;/li&gt;
&lt;li&gt;Accessible status labels and visible focus states.&lt;/li&gt;
&lt;li&gt;A responsive, self-contained interface without external fonts or CDNs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The design goal is to make a recovery report something a developer can investigate, rather than a wall of text they have to trust blindly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Architecture Diagram 6 — Dashboard Request Sequence
&lt;/h3&gt;



&lt;pre data-lang="mermaid"&gt;&lt;code&gt;sequenceDiagram
    autonumber
    actor User as Developer
    participant Browser as Dashboard Browser
    participant Server as dashboardServer.ts
    participant Guard as pathGuard.ts
    participant Inspector as inspector.ts
    participant Engine as recoveryEngine.ts
    participant AI as localAiProvider.ts
    participant Formatter as markdownFormatter.ts

    User-&amp;gt;&amp;gt;Browser: Open local dashboard
    Browser-&amp;gt;&amp;gt;Server: GET /
    Server-&amp;gt;&amp;gt;Server: Validate loopback client and Host
    Server--&amp;gt;&amp;gt;Browser: Self-contained dashboard HTML

    User-&amp;gt;&amp;gt;Browser: Select repository and inspect
    Browser-&amp;gt;&amp;gt;Server: POST /api/inspect
    Server-&amp;gt;&amp;gt;Server: Validate request and Origin
    Server-&amp;gt;&amp;gt;Guard: Validate target root
    Guard--&amp;gt;&amp;gt;Server: Canonical root
    Server-&amp;gt;&amp;gt;Inspector: inspectRepository(root)
    Inspector--&amp;gt;&amp;gt;Server: InspectionResult
    Server-&amp;gt;&amp;gt;Engine: reconstructProjectState(result)
    Engine--&amp;gt;&amp;gt;Server: RecoveryDossier

    opt AI interpretation requested
        Server-&amp;gt;&amp;gt;AI: Interpret bounded redacted evidence
        AI--&amp;gt;&amp;gt;Server: Validated interpretation or fallback
    end

    Server--&amp;gt;&amp;gt;Browser: RecoveryDossier JSON
    Browser-&amp;gt;&amp;gt;Browser: Render claims and evidence

    User-&amp;gt;&amp;gt;Browser: Export Markdown report
    Browser-&amp;gt;&amp;gt;Server: GET /api/export/markdown
    Server-&amp;gt;&amp;gt;Formatter: Format validated dossier
    Formatter--&amp;gt;&amp;gt;Server: Markdown
    Server--&amp;gt;&amp;gt;Browser: Report download&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;The dashboard is intended to run on the local loopback interface at &lt;code&gt;http://127.0.0.1:3333&lt;/code&gt;. Its request boundaries and the recovery engine should be tested independently of the appearance of the interface.&lt;/p&gt;




&lt;h2&gt;
  
  
  🤖 9. Optional Local AI — Interpretation Without Giving Up Provenance
&lt;/h2&gt;

&lt;p&gt;ContextKeeper also supports optional AI-assisted interpretation using a locally hosted Ollama model.&lt;/p&gt;

&lt;p&gt;The architectural intention is not to replace deterministic recovery with an unrestricted autonomous agent.&lt;/p&gt;

&lt;p&gt;Instead, the model receives bounded, redacted evidence and can help produce a qualitative explanation of what may be happening in the project.&lt;/p&gt;

&lt;p&gt;The local AI subsystem is designed around several controls:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Only local loopback inference endpoints are accepted.&lt;/li&gt;
&lt;li&gt;Repository content is treated as untrusted input.&lt;/li&gt;
&lt;li&gt;Prompt construction explicitly isolates repository content.&lt;/li&gt;
&lt;li&gt;Responses are expected to conform to a structured schema.&lt;/li&gt;
&lt;li&gt;Model-generated evidence identifiers are checked against the real evidence set.&lt;/li&gt;
&lt;li&gt;Invalid responses, unavailable models, and timeouts trigger deterministic fallback.&lt;/li&gt;
&lt;li&gt;AI is optional and is not required for the core CLI or dashboard.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ollama has been exercised with a local &lt;code&gt;gemma3:4b&lt;/code&gt; model in the reported validation. However, local inference latency can vary; a larger recovery prompt has previously exceeded the configured 25-second timeout. The fallback behavior is therefore important, and broader latency testing remains useful.&lt;/p&gt;

&lt;h3&gt;
  
  
  Architecture Diagram 7 — Local AI Sequence
&lt;/h3&gt;



&lt;pre data-lang="mermaid"&gt;&lt;code&gt;sequenceDiagram
    autonumber
    participant Caller as CLI or Dashboard
    participant AI as localAiProvider.ts
    participant Ollama as Local Ollama
    participant Dossier as Recovery Dossier

    Caller-&amp;gt;&amp;gt;AI: generateLocalAiInterpretation(dossier)
    AI-&amp;gt;&amp;gt;AI: Validate loopback endpoint

    alt Non-local endpoint
        AI--&amp;gt;&amp;gt;Caller: Reject and fall back
    else Local endpoint accepted
        AI-&amp;gt;&amp;gt;Ollama: GET /api/tags

        alt Daemon unavailable
            AI--&amp;gt;&amp;gt;Caller: UNAVAILABLE / FALLBACK
        else Model available
            Ollama--&amp;gt;&amp;gt;AI: Installed model list
            AI-&amp;gt;&amp;gt;AI: Build bounded redacted prompt
            Note over AI: Repository text is untrusted&amp;lt;br/&amp;gt;Evidence IDs are supplied explicitly

            AI-&amp;gt;&amp;gt;Ollama: POST /api/generate

            alt Timeout or HTTP failure
                AI--&amp;gt;&amp;gt;Caller: Deterministic fallback
            else Response received
                Ollama--&amp;gt;&amp;gt;AI: Structured response
                AI-&amp;gt;&amp;gt;AI: Parse and validate schema
                AI-&amp;gt;&amp;gt;AI: Validate cited evidence IDs

                alt Invalid response or citations
                    AI--&amp;gt;&amp;gt;Caller: Fallback with warning
                else Valid response
                    AI--&amp;gt;&amp;gt;Dossier: Attach AI interpretation
                    AI--&amp;gt;&amp;gt;Caller: SUCCESS
                end
            end
        end
    end&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;An important distinction: a local model producing plausible prose is not the same as a model proving a fact. The model's role is interpretation; verified evidence remains the foundation for factual statements.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔐 10. Security Architecture: Treat Repositories as Untrusted Input
&lt;/h2&gt;

&lt;p&gt;ContextKeeper may inspect repositories cloned from unfamiliar locations or containing sensitive company code. That makes its security boundaries an essential part of the architecture.&lt;/p&gt;

&lt;p&gt;The project implements several layers of defense.&lt;/p&gt;

&lt;h3&gt;
  
  
  Filesystem safety
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Canonical path validation.&lt;/li&gt;
&lt;li&gt;Symlink containment checks.&lt;/li&gt;
&lt;li&gt;File type and path exclusion policies.&lt;/li&gt;
&lt;li&gt;Bounded file count, individual file size, cumulative bytes, directory depth, and inspection time.&lt;/li&gt;
&lt;li&gt;Graceful handling of inaccessible or unsupported files.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Git subprocess safety
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Explicitly allowlisted read-only Git subcommands.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;execFile&lt;/code&gt; with &lt;code&gt;shell: false&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Sanitized Git-related environment variables.&lt;/li&gt;
&lt;li&gt;Defensive Git configuration overrides.&lt;/li&gt;
&lt;li&gt;Timeouts and bounded output buffers.&lt;/li&gt;
&lt;li&gt;Rejection of dangerous arguments outside the supported interface.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Secret handling
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Pattern-based masking of common credential formats.&lt;/li&gt;
&lt;li&gt;High-entropy token screening.&lt;/li&gt;
&lt;li&gt;Redaction before evidence is stored or rendered.&lt;/li&gt;
&lt;li&gt;Regression tests using synthetic credentials.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Dashboard security
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Loopback-only binding.&lt;/li&gt;
&lt;li&gt;Client and Host header validation.&lt;/li&gt;
&lt;li&gt;Origin validation for state-changing requests.&lt;/li&gt;
&lt;li&gt;Request-body size limits.&lt;/li&gt;
&lt;li&gt;Content Security Policy and anti-framing headers.&lt;/li&gt;
&lt;li&gt;Restricted target paths.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  AI security
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Local-only endpoint checks.&lt;/li&gt;
&lt;li&gt;Redacted, bounded prompt payloads.&lt;/li&gt;
&lt;li&gt;Untrusted repository-content isolation.&lt;/li&gt;
&lt;li&gt;Structured response validation.&lt;/li&gt;
&lt;li&gt;Evidence-ID verification.&lt;/li&gt;
&lt;li&gt;Deterministic fallback.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are defense-in-depth controls, not a claim that every conceivable attack or secret format can be detected. ContextKeeper still requires continuing security review, especially as new data sources and dashboard features are introduced.&lt;/p&gt;

&lt;h3&gt;
  
  
  Architecture Diagram 8 — Security Trust Boundaries
&lt;/h3&gt;



&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    subgraph Untrusted["Untrusted Inputs"]
        Args["CLI Arguments and Paths"]
        Requests["Dashboard HTTP Requests"]
        Files["Repository Files and Symlinks"]
        GitConfig["Hostile Git Configuration"]
        ModelOutput["Untrusted Model Output"]
    end

    subgraph HTTPBoundary["HTTP Boundary"]
        Loopback["Loopback IP Check"]
        Host["Host Header Validation"]
        Origin["Origin / CSRF Validation"]
        Body["Request Size Limit"]
    end

    subgraph PathBoundary["Filesystem Boundary"]
        Root["Canonical Root Validation"]
        Symlinks["Symlink Containment"]
        Exclusions["Path and File Exclusions"]
        Limits["File and Time Budgets"]
    end

    subgraph ProcessBoundary["Subprocess Boundary"]
        Allowlist["Git Command Allowlist"]
        Environment["Environment Sanitization"]
        Config["Git Configuration Overrides"]
        Exec["execFile, shell:false, Timeout"]
    end

    subgraph DataBoundary["Evidence Boundary"]
        Redact["Secret Redaction"]
        Digest["SHA-256 Content Identity"]
        Provenance["Evidence Citation Validation"]
    end

    subgraph AIBoundary["AI and Output Boundary"]
        LocalOnly["Local Endpoint Enforcement"]
        PromptIsolation["Untrusted Content Isolation"]
        Schema["Structured Response Validation"]
    end

    Outputs["Recovery Dossier and Reports"]

    Requests --&amp;gt; Loopback --&amp;gt; Host --&amp;gt; Origin --&amp;gt; Body --&amp;gt; Root
    Args --&amp;gt; Root
    Files --&amp;gt; Symlinks
    Root --&amp;gt; Symlinks --&amp;gt; Exclusions --&amp;gt; Limits
    GitConfig --&amp;gt; Environment --&amp;gt; Allowlist --&amp;gt; Config --&amp;gt; Exec
    Limits --&amp;gt; Redact
    Exec --&amp;gt; Redact
    Redact --&amp;gt; Digest --&amp;gt; Provenance
    ModelOutput --&amp;gt; Schema
    Provenance --&amp;gt; LocalOnly --&amp;gt; PromptIsolation --&amp;gt; Schema
    Provenance --&amp;gt; Outputs
    Schema --&amp;gt; Outputs&lt;/code&gt;&lt;/pre&gt;






&lt;h2&gt;
  
  
  📦 11. Packaging and Distribution
&lt;/h2&gt;

&lt;p&gt;ContextKeeper is designed to be distributed as a lightweight npm executable.&lt;/p&gt;

&lt;p&gt;The development workflow uses TypeScript for strict checking and compiles the source into ECMAScript modules for distribution.&lt;/p&gt;

&lt;p&gt;The package build and packaging checks are intended to include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The executable wrapper.&lt;/li&gt;
&lt;li&gt;Compiled JavaScript output.&lt;/li&gt;
&lt;li&gt;README and license.&lt;/li&gt;
&lt;li&gt;Required runtime files.&lt;/li&gt;
&lt;li&gt;No test fixtures or internal development reports in the distributable package.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The CLI supports recovery-report generation and starting the local dashboard. The project documentation also covers typechecking, testing, building, installation, and troubleshooting.&lt;/p&gt;

&lt;h3&gt;
  
  
  Architecture Diagram 9 — Build and Deployment
&lt;/h3&gt;



&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    Source["TypeScript Source"]
    Tests["Automated Tests"]
    Config["tsconfig.json"]

    Typecheck["npm run typecheck"]
    Test["npm test"]
    Build["npm run build"]
    Dist["Compiled dist/src/*.js"]

    Prepack["npm prepack"]
    Allowlist["Package File Allowlist"]
    Tarball["npm Package Tarball"]

    Install["Install Package"]
    Binary["contextkeeper Executable"]
    Runtime["Resolve Compiled CLI"]
    CLI["Run CLI or Dashboard"]

    Source --&amp;gt; Typecheck
    Tests --&amp;gt; Test
    Config --&amp;gt; Typecheck
    Source --&amp;gt; Build
    Build --&amp;gt; Dist
    Typecheck --&amp;gt; Build
    Test --&amp;gt; Build
    Dist --&amp;gt; Prepack
    Prepack --&amp;gt; Allowlist
    Allowlist --&amp;gt; Tarball
    Tarball --&amp;gt; Install
    Install --&amp;gt; Binary
    Binary --&amp;gt; Runtime
    Runtime --&amp;gt; CLI&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;The reported package dry-run included 21 files and retained zero runtime production dependencies. The CLI package was also reported as successfully installed and exercised in an isolated sandbox.&lt;/p&gt;

&lt;p&gt;One issue identified during the architecture audit was the need to ensure the package's public JavaScript import entry point matches the files actually included in the tarball. Programmatic library consumption should be verified separately from executable CLI use.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧪 12. Testing and Evaluation
&lt;/h2&gt;

&lt;p&gt;I wanted the project to go beyond a successful build and a few happy-path demos.&lt;/p&gt;

&lt;p&gt;The reported validation suite covers several distinct categories:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unit tests&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SHA-256 digest stability.&lt;/li&gt;
&lt;li&gt;Line-ending normalization.&lt;/li&gt;
&lt;li&gt;Evidence ID generation.&lt;/li&gt;
&lt;li&gt;Secret-redaction behavior.&lt;/li&gt;
&lt;li&gt;Filesystem path validation.&lt;/li&gt;
&lt;li&gt;Git command argument restrictions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Integration tests&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Git porcelain status parsing.&lt;/li&gt;
&lt;li&gt;Repository inspection lifecycle.&lt;/li&gt;
&lt;li&gt;Non-Git directory handling.&lt;/li&gt;
&lt;li&gt;Recovery claims and recommendations.&lt;/li&gt;
&lt;li&gt;Dashboard HTTP lifecycle.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Security tests&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hostile Git configurations.&lt;/li&gt;
&lt;li&gt;Dangerous environment variable handling.&lt;/li&gt;
&lt;li&gt;Command and option injection attempts.&lt;/li&gt;
&lt;li&gt;Symlink escapes.&lt;/li&gt;
&lt;li&gt;Secret redaction.&lt;/li&gt;
&lt;li&gt;Invalid dashboard Host and Origin requests.&lt;/li&gt;
&lt;li&gt;Non-destructive inspection.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Synthetic evaluation&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Untracked feature files.&lt;/li&gt;
&lt;li&gt;Exported source declarations.&lt;/li&gt;
&lt;li&gt;Staged and unstaged changes.&lt;/li&gt;
&lt;li&gt;Stale documentation.&lt;/li&gt;
&lt;li&gt;Historical test logs.&lt;/li&gt;
&lt;li&gt;Unknown project intent.&lt;/li&gt;
&lt;li&gt;Secret-bearing content.&lt;/li&gt;
&lt;li&gt;Resource-limit enforcement.&lt;/li&gt;
&lt;li&gt;Malformed input.&lt;/li&gt;
&lt;li&gt;Non-Git repositories.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Dogfooding&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Self-inspection of the ContextKeeper repository.&lt;/li&gt;
&lt;li&gt;Synthetic interrupted-session profiles.&lt;/li&gt;
&lt;li&gt;Citation resolution and uncertainty handling.&lt;/li&gt;
&lt;li&gt;Repository immutability.&lt;/li&gt;
&lt;li&gt;Repeat-run determinism.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Optional local AI tests&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Loopback endpoint enforcement.&lt;/li&gt;
&lt;li&gt;Non-local endpoint rejection.&lt;/li&gt;
&lt;li&gt;Unavailable-daemon handling.&lt;/li&gt;
&lt;li&gt;Local model response and citation validation where the runtime is available.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Reported validation results
&lt;/h3&gt;

&lt;p&gt;At the time of the supplied project reports:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;60/60 automated tests passed.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;TypeScript typechecking completed with zero reported errors.&lt;/li&gt;
&lt;li&gt;The production build succeeded.&lt;/li&gt;
&lt;li&gt;The 12-scenario synthetic corpus passed.&lt;/li&gt;
&lt;li&gt;The dogfooding suite reported 9/9 passing scenarios.&lt;/li&gt;
&lt;li&gt;The combined evaluation reported 48/48 eligible files inspected, 202/202 citation references resolving, 24/24 required UNKNOWN classifications preserved, zero seeded-secret exposures, and 59/59 evaluated recommendations matching expected repository state.&lt;/li&gt;
&lt;li&gt;Package generation and an isolated CLI installation were reported successful.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are measured results for the project's implemented test corpus. They should not be interpreted as proof of universal recovery accuracy, complete secret detection, or perfect semantic correctness across arbitrary repositories.&lt;/p&gt;

&lt;h3&gt;
  
  
  Architecture Diagram 10 — Testing and Validation Pipeline
&lt;/h3&gt;



&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TB
    Start["npm test"]

    subgraph Unit["Unit Tests"]
        Digest["Digest Tests"]
        Redactor["Redactor Tests"]
        PathGuard["Path Guard Tests"]
        GitRunner["Git Runner Tests"]
    end

    subgraph Integration["Integration Tests"]
        GitStatus["Git Status Tests"]
        Inspection["Inspection Lifecycle"]
        Recovery["Recovery Engine Tests"]
        Dashboard["Dashboard HTTP Tests"]
    end

    subgraph Security["Security Audits"]
        HostileGit["Hostile Git Config Tests"]
        Arguments["Argument and Environment Tests"]
        Immutability["Non-Destructive Invariants"]
    end

    subgraph Evaluation["Recovery Evaluation"]
        GroundTruth["12 Ground-Truth Archetypes"]
        Dogfooding["9 Dogfooding Scenarios"]
    end

    subgraph AI["Local AI Tests"]
        Locality["Loopback Enforcement"]
        Fallback["Unavailable and Timeout Fallback"]
        Citations["Model Citation Validation"]
    end

    Typecheck["npm run typecheck"]
    Build["npm run build"]
    Release["Review Results and Package"]

    Start --&amp;gt; Unit
    Start --&amp;gt; Integration
    Start --&amp;gt; Security
    Start --&amp;gt; Evaluation
    Start --&amp;gt; AI

    Unit --&amp;gt; Typecheck
    Integration --&amp;gt; Typecheck
    Security --&amp;gt; Typecheck
    Evaluation --&amp;gt; Typecheck
    AI --&amp;gt; Typecheck

    Typecheck --&amp;gt; Build --&amp;gt; Release&lt;/code&gt;&lt;/pre&gt;






&lt;h2&gt;
  
  
  🧩 13. SOLID Principles and Architecture Review
&lt;/h2&gt;

&lt;p&gt;A senior-level project should discuss its weaknesses as openly as its strengths.&lt;/p&gt;

&lt;p&gt;The architecture audit found the following.&lt;/p&gt;

&lt;h3&gt;
  
  
  Single Responsibility Principle — Partial
&lt;/h3&gt;

&lt;p&gt;The CLI handles several responsibilities, including argument parsing, command routing, recovery execution, and dashboard startup.&lt;/p&gt;

&lt;p&gt;The dashboard server also combines transport security, routing, recovery orchestration, and export formatting. The dashboard HTML module embeds a large amount of CSS, HTML, and JavaScript in one source file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Potential improvement:&lt;/strong&gt; split command handlers, route handlers, and frontend assets into focused modules.&lt;/p&gt;

&lt;h3&gt;
  
  
  Open/Closed Principle — Partial
&lt;/h3&gt;

&lt;p&gt;The claim generator contains sequential claim-generation rules. Adding another class of evidence or claim may require modifying the central generator.&lt;/p&gt;

&lt;p&gt;The local AI provider is also closely coupled to the Ollama API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Potential improvement:&lt;/strong&gt; introduce a small claim-rule registry and a local AI provider interface only when extension needs justify the additional abstraction.&lt;/p&gt;

&lt;h3&gt;
  
  
  Liskov Substitution Principle — Not Applicable
&lt;/h3&gt;

&lt;p&gt;The application is primarily functional and data-oriented. It relies on TypeScript interfaces and data structures rather than a class hierarchy.&lt;/p&gt;

&lt;p&gt;Introducing inheritance purely to satisfy a SOLID checklist would add little value.&lt;/p&gt;

&lt;h3&gt;
  
  
  Interface Segregation Principle — Pass
&lt;/h3&gt;

&lt;p&gt;The audit reports that the domain interfaces, including inspection options, content locators, and recommendations, have focused responsibilities.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dependency Inversion Principle — Partial
&lt;/h3&gt;

&lt;p&gt;Some high-level components import concrete filesystem operations and Git-running functions directly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Potential improvement:&lt;/strong&gt; use injected interfaces in the parts that would benefit from easier isolated testing or alternate implementations.&lt;/p&gt;

&lt;p&gt;The wider engineering review also considered DRY, KISS, YAGNI, type safety, error handling, immutability, determinism, separation of concerns, testability, and maintainability.&lt;/p&gt;

&lt;p&gt;The goal is not to maximize abstractions. It is to keep the architecture understandable, testable, and safe as the project grows.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧱 14. Architectural Decisions and Trade-Offs
&lt;/h2&gt;

&lt;p&gt;Several decisions shape the product.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Zero runtime dependencies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using Node.js native APIs keeps the package lightweight. The trade-off is that routing, argument handling, and server behavior must be implemented and tested carefully.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Read-only repository inspection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;ContextKeeper does not automatically stash, commit, clean, or modify the target repository. It also avoids executing arbitrary target-project test scripts during recovery.&lt;/p&gt;

&lt;p&gt;This protects unfinished work but means current runtime correctness cannot be inferred from the repository alone.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Deterministic recovery first&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The recovery pipeline remains useful without a model. AI is an optional layer rather than a required dependency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Evidence-linked claims&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The system requires claims to cite evidence records. This improves traceability, but semantic support still needs careful evaluation: the existence of a citation is not equivalent to proof that the claim is correct.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Local-only dashboard and AI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The dashboard uses loopback access controls, and the AI provider is designed for local Ollama inference. This limits the deployment model but supports a privacy-oriented experience for developers working with sensitive source code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Bounded inspection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;File-count, byte-size, depth, and time limits control resource usage. The trade-off is incomplete evidence when a repository exceeds those limits. Skipped files must remain visible through warnings rather than disappearing silently.&lt;/p&gt;

&lt;p&gt;These decisions are documented in the project's architecture decision records and threat model.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚠️ 15. What ContextKeeper Cannot Guarantee
&lt;/h2&gt;

&lt;p&gt;Being explicit about limitations is part of building reliable developer tools.&lt;/p&gt;

&lt;p&gt;ContextKeeper cannot reliably reconstruct the original task from arbitrary code changes alone. A developer may need to clarify the intended outcome.&lt;/p&gt;

&lt;p&gt;A valid SHA-256 digest establishes content identity, not semantic truth. A source declaration does not establish runtime correctness. A historical test log does not establish that subsequently changed code passes.&lt;/p&gt;

&lt;p&gt;Secret detection relies on patterns and heuristics, so unusual, custom, or low-entropy secrets may evade detection.&lt;/p&gt;

&lt;p&gt;Concurrent external processes may also change a repository while it is being inspected. Read-only content operations can update operating-system access timestamps, depending on filesystem behavior.&lt;/p&gt;

&lt;p&gt;Local model inference may time out or return invalid output; deterministic fallback remains essential.&lt;/p&gt;

&lt;p&gt;Finally, the evaluation results are bounded by the repositories and scenarios tested so far. More diverse real-world sessions and independent evaluations are needed to establish how useful the tool is across different projects and workflows.&lt;/p&gt;




&lt;h2&gt;
  
  
  🗺️ 16. Development Roadmap
&lt;/h2&gt;

&lt;p&gt;The next stages are about improving reliability and usability rather than adding features without evidence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Priority 1 — Real-world recovery quality&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Evaluate actual interrupted coding sessions and record missed changes, weak recommendations, ambiguous claims, and cases where UNKNOWN should be preserved.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Priority 2 — Package and public API correctness&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Keep the installed CLI reliable and ensure that any advertised programmatic library interface resolves to actual packaged JavaScript and type declarations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Priority 3 — Architecture modularity&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Split the largest modules into clearer units when doing so demonstrably improves testability and maintainability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Priority 4 — Local AI latency and resilience&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Measure inference time on real hardware, minimize redundant prompt content, and improve bounded payload construction without removing provenance controls.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Priority 5 — Developer onboarding and community contribution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Maintain useful diagrams, installation instructions, architectural decision records, contributor documentation, reproducible tests, and accessible issue reports.&lt;/p&gt;




&lt;h2&gt;
  
  
  💻 17. Quick Start
&lt;/h2&gt;

&lt;p&gt;For developers who want to explore the project, the documented commands include:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Run in the ContextKeeper repository&lt;/span&gt;
npm &lt;span class="nb"&gt;install&lt;/span&gt;

&lt;span class="c"&gt;# Typecheck&lt;/span&gt;
npm run typecheck

&lt;span class="c"&gt;# Run the automated tests&lt;/span&gt;
npm &lt;span class="nb"&gt;test&lt;/span&gt;

&lt;span class="c"&gt;# Build the distribution&lt;/span&gt;
npm run build

&lt;span class="c"&gt;# Generate a Markdown recovery dossier&lt;/span&gt;
node bin/contextkeeper.js recover &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;--report&lt;/span&gt; markdown

&lt;span class="c"&gt;# Generate JSON&lt;/span&gt;
node bin/contextkeeper.js recover &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;--report&lt;/span&gt; json

&lt;span class="c"&gt;# Start the local dashboard&lt;/span&gt;
node bin/contextkeeper.js ui &lt;span class="nb"&gt;.&lt;/span&gt;

&lt;span class="c"&gt;# Optional: request local AI interpretation&lt;/span&gt;
node bin/contextkeeper.js recover &lt;span class="nb"&gt;.&lt;/span&gt; &lt;span class="nt"&gt;--report&lt;/span&gt; markdown &lt;span class="nt"&gt;--ai&lt;/span&gt; &lt;span class="nt"&gt;--ai-model&lt;/span&gt; gemma3:4b

&lt;span class="c"&gt;# Inspect package contents without publishing&lt;/span&gt;
npm pack &lt;span class="nt"&gt;--dry-run&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The AI command requires a working local Ollama service and the selected model to be installed. Without it, deterministic recovery remains the fallback.&lt;/p&gt;




&lt;h2&gt;
  
  
  📚 18. Open-Source Documentation and Architecture Artifacts
&lt;/h2&gt;

&lt;p&gt;The project includes a set of engineering documents designed to make the implementation inspectable and easier to contribute to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;docs/PROJECT_DEEP_DIVE.md&lt;/code&gt; — system architecture and workflow walkthroughs.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;docs/ARCHITECTURE_DECISION_RECORDS.md&lt;/code&gt; — architectural choices and trade-offs.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;docs/SOLID_AND_CODE_QUALITY_AUDIT.md&lt;/code&gt; — design-principle assessment and remediation proposals.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;docs/DEVELOPER_GUIDE.md&lt;/code&gt; — development setup, CLI, dashboard, testing, packaging, and troubleshooting.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;docs/FINAL_MVP_COMPLETION_REPORT.md&lt;/code&gt; — recorded acceptance and validation results.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;docs/diagrams/01_system_context.mmd&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;docs/diagrams/02_component_architecture.mmd&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;docs/diagrams/03_cli_recovery_sequence.mmd&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;docs/diagrams/04_dashboard_request_sequence.mmd&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;docs/diagrams/05_evidence_claim_flow.mmd&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;docs/diagrams/06_local_ai_sequence.mmd&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;docs/diagrams/07_claim_classification_state.mmd&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;docs/diagrams/08_security_trust_boundaries.mmd&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;docs/diagrams/09_packaging_deployment_flow.mmd&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;docs/diagrams/10_testing_validation_pipeline.mmd&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These diagrams illustrate the system context, component architecture, CLI recovery, dashboard request flow, evidence-to-claim pipeline, local AI lifecycle, claim classification, security boundaries, packaging, and testing.&lt;/p&gt;

&lt;p&gt;The diagrams are authored as Mermaid source files. Their syntax should be validated with an actual renderer before describing them as independently render-tested.&lt;/p&gt;




&lt;h2&gt;
  
  
  🌱 19. What I Learned Building ContextKeeper
&lt;/h2&gt;

&lt;p&gt;This project has reinforced several lessons for me as a developer working at the intersection of AI, developer tools, and open source.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First, deterministic systems still matter in AI products.&lt;/strong&gt; Collecting reliable physical facts about a repository is often more valuable than generating an elaborate explanation without provenance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Second, security needs to shape the architecture.&lt;/strong&gt; Path validation, subprocess restrictions, redaction, bounded processing, and read-only behavior are core design decisions—not features that should be added only after the interface is complete.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Third, uncertainty deserves an explicit representation.&lt;/strong&gt; Keeping UNKNOWN as a first-class outcome makes it possible to recover project state without pretending to understand a developer's intentions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fourth, passing tests are necessary but not sufficient.&lt;/strong&gt; Packaging, failure handling, actual model behavior, interface usability, semantic claim support, and real-world validation all matter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finally, good architecture includes trade-offs.&lt;/strong&gt; Zero runtime dependencies, embedded dashboard assets, a deterministic-first engine, and a locally hosted AI provider each offer benefits while introducing limitations that should be documented and revisited as the product matures.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 20. The Vision
&lt;/h2&gt;

&lt;p&gt;My goal with ContextKeeper is to make interrupted development less painful by helping developers recover their working context from observable evidence.&lt;/p&gt;

&lt;p&gt;I want to keep improving the experience while preserving its core engineering principles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Local-first operation.&lt;/li&gt;
&lt;li&gt;Read-only inspection.&lt;/li&gt;
&lt;li&gt;Bounded resource usage.&lt;/li&gt;
&lt;li&gt;Redacted evidence.&lt;/li&gt;
&lt;li&gt;Traceable conclusions.&lt;/li&gt;
&lt;li&gt;Explicit uncertainty.&lt;/li&gt;
&lt;li&gt;Optional, locally hosted AI.&lt;/li&gt;
&lt;li&gt;Reproducible validation.&lt;/li&gt;
&lt;li&gt;Clear architectural documentation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;ContextKeeper is not meant to pretend it knows everything about a project. It is meant to help developers establish what can be known, understand what is likely, and recognize what still requires their judgment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The principle behind the project is simple:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Don't let AI invent your project's history. Reconstruct the evidence, preserve uncertainty, and help the developer take the next step.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I'm continuing to improve ContextKeeper and welcome constructive feedback, architectural review, security feedback, testing ideas, and contributions from the developer and open-source community.&lt;/p&gt;

&lt;p&gt;🔗 &lt;strong&gt;GitHub:&lt;/strong&gt; [&lt;a href="https://github.com/suvendukungfu/contextkeeper-ai" rel="noopener noreferrer"&gt;https://github.com/suvendukungfu/contextkeeper-ai&lt;/a&gt;]&lt;/p&gt;

&lt;h1&gt;
  
  
  Hacktoberfest #hf26challenge #devchallenges #OpenSource
&lt;/h1&gt;

</description>
      <category>devchallenge</category>
      <category>hf26challenge</category>
      <category>opensource</category>
    </item>
    <item>
      <title>ScopeGhost: An Open-Weight AI Scope Auditor for Freelancers and Agencies</title>
      <dc:creator>suvendu kumar sahoo</dc:creator>
      <pubDate>Wed, 14 Oct 2026 09:18:02 +0000</pubDate>
      <link>https://dev.to/suvendukungfu/scopeghost-an-open-weight-ai-scope-auditor-for-freelancers-and-agencies-56cj</link>
      <guid>https://dev.to/suvendukungfu/scopeghost-an-open-weight-ai-scope-auditor-for-freelancers-and-agencies-56cj</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/hacktoberfest-week2-2026-10-12"&gt;Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  ScopeGhost: Building a Local-First AI Scope Auditor with Gemma 3
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;What if freelancers could challenge scope creep with verified evidence instead of uncomfortable arguments?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A client asks for one more feature. Then another revision. Then a native mobile application that was never included in the original agreement.&lt;/p&gt;

&lt;p&gt;For freelance developers and small software agencies, these requests can turn a profitable project into weeks of unpaid work.&lt;/p&gt;

&lt;p&gt;I built &lt;strong&gt;ScopeGhost&lt;/strong&gt;, an open-source, local-first AI scope auditor that helps developers compare incoming client requests against an agreed project scope, verify contractual evidence, and prepare reviewable change-order drafts.&lt;/p&gt;

&lt;p&gt;The interesting part isn't simply putting an LLM behind a web interface. It's engineering the boundaries around the model so that its conclusions can be checked.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. What I Built
&lt;/h2&gt;

&lt;p&gt;ScopeGhost is designed for freelance software engineers, independent consultants, and boutique agencies managing fixed-scope projects.&lt;/p&gt;

&lt;p&gt;It compares project requirements and client communications against baseline contract clauses, then produces structured findings that can be reviewed by a human.&lt;/p&gt;

&lt;h3&gt;
  
  
  Core capabilities
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Scope classification:&lt;/strong&gt; Categorizes requests as &lt;code&gt;IN_SCOPE&lt;/code&gt;, &lt;code&gt;POTENTIALLY_OUT_OF_SCOPE&lt;/code&gt;, &lt;code&gt;AMBIGUOUS&lt;/code&gt;, or &lt;code&gt;INSUFFICIENT_EVIDENCE&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Evidence-linked findings:&lt;/strong&gt; Connects an assessment to supplied source excerpts and contract clauses.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Citation verification:&lt;/strong&gt; Checks whether quoted evidence actually exists in the supplied source text.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Topic-relevance safeguards:&lt;/strong&gt; Helps prevent an unrelated exclusion clause from being used to justify an out-of-scope classification.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deterministic financial calculations:&lt;/strong&gt; Calculates estimated costs using integer-cent arithmetic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Change-order workflow:&lt;/strong&gt; Helps prepare change-order drafts for human review and client discussion.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local model inference:&lt;/strong&gt; Uses Gemma 3 through Ollama instead of requiring a hosted LLM API for the core inference workflow.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Who could pay for it?
&lt;/h3&gt;

&lt;p&gt;The target market is independent developers, freelance consultants, and small software agencies.&lt;/p&gt;

&lt;p&gt;Potential business models include individual subscriptions, per-audit pricing, or agency plans. These are commercial hypotheses that need validation with actual users; I have not established customer demand or revenue.&lt;/p&gt;

&lt;p&gt;The value proposition is straightforward: make it easier to identify potentially out-of-scope work before it becomes unpaid work.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Code and Project Links
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;GitHub repository:&lt;/strong&gt; &lt;a href="https://github.com/suvendukungfu/ScopeGhost" rel="noopener noreferrer"&gt;https://github.com/suvendukungfu/ScopeGhost&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;License:&lt;/strong&gt; MIT&lt;/p&gt;

&lt;p&gt;The project uses Next.js, React, TypeScript, Tailwind CSS, SQLite, Zod, Ollama, Gemma 3, Vitest, and Playwright.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Product Workflow
&lt;/h2&gt;

&lt;p&gt;The application takes a project scope and new client requests, analyzes their relationship, checks the evidence, and presents findings for review.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    A["Project Scope and Contract Clauses"] --&amp;gt; C["ScopeGhost"]
    B["Client Emails, Tickets and Notes"] --&amp;gt; C
    C --&amp;gt; D["Local AI-Assisted Analysis"]
    D --&amp;gt; E["Citation and Relevance Checks"]
    E --&amp;gt; F{"Evidence Supports Finding?"}
    F --&amp;gt;|Yes| G["Grounded Scope Finding"]
    F --&amp;gt;|Unclear or Conflicting| H["Ambiguous or Insufficient Evidence"]
    G --&amp;gt; I["Human Review"]
    H --&amp;gt; I
    I --&amp;gt; J["Reviewable Change-Order Draft"]&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;The goal is not to automate legal judgment. It is to give the developer a clearer, evidence-based starting point for a conversation about scope.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. System Architecture
&lt;/h2&gt;

&lt;p&gt;ScopeGhost separates probabilistic model interpretation from deterministic validation and persistence.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TB
    subgraph INPUT["Input Layer"]
        A["Contract Clauses"]
        B["Client Communications"]
    end

    subgraph APP["ScopeGhost Application"]
        C["Next.js Interface"]
        D["Input Parsing"]
        E["Analysis Service"]
        G["Citation Verification"]
        H["Topic-Relevance Gates"]
        I["Financial Engine"]
        J["Human Review"]
    end

    subgraph AI["Local Inference"]
        F["Ollama"]
        K["Gemma 3 4B"]
        F --&amp;gt; K
    end

    subgraph DATA["Persistence"]
        L["SQLite"]
        M["Analysis and Audit Records"]
        L --&amp;gt; M
    end

    A --&amp;gt; D
    B --&amp;gt; D
    C --&amp;gt; D
    D --&amp;gt; E
    E --&amp;gt; F
    K --&amp;gt; E
    E --&amp;gt; G
    G --&amp;gt; H
    H --&amp;gt; I
    I --&amp;gt; J
    J --&amp;gt; L
    J --&amp;gt; N["Reviewable Findings"]&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;This is a logical view of the architecture. The model proposes an analysis; the application remains responsible for validation and financial calculations.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Deep Dive: Gemma 3 4B and Local Inference
&lt;/h2&gt;

&lt;p&gt;ScopeGhost uses &lt;strong&gt;Google Gemma 3 4B (&lt;code&gt;gemma3:4b&lt;/code&gt;) through Ollama&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Gemma 3 is an open-weight model family. The 4B variant offers a practical starting point for developers experimenting with local inference and structured natural-language analysis.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the model does
&lt;/h3&gt;

&lt;p&gt;Gemma 3 helps interpret client requests, propose scope classifications, identify candidate evidence, and produce structured analysis for the application to validate.&lt;/p&gt;

&lt;p&gt;It does not serve as the final authority on whether a quotation exists, whether a clause was supplied, or whether a financial calculation is correct.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Responsibility&lt;/th&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Interpret natural-language requests&lt;/td&gt;
&lt;td&gt;Gemma 3 4B&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Propose scope classifications&lt;/td&gt;
&lt;td&gt;Gemma 3 4B&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Extract candidate evidence and clause references&lt;/td&gt;
&lt;td&gt;Gemma 3 4B&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Validate structured output&lt;/td&gt;
&lt;td&gt;Zod and application code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Verify citations against source text&lt;/td&gt;
&lt;td&gt;Deterministic citation verifier&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Check clause existence&lt;/td&gt;
&lt;td&gt;Application validation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Apply topic-relevance safeguards&lt;/td&gt;
&lt;td&gt;Deterministic service logic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Calculate estimated monetary values&lt;/td&gt;
&lt;td&gt;Integer-cent financial engine&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Persist findings and audit records&lt;/td&gt;
&lt;td&gt;SQLite-backed workflow&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  The inference sequence
&lt;/h3&gt;



&lt;pre data-lang="mermaid"&gt;&lt;code&gt;sequenceDiagram
    actor User
    participant UI as ScopeGhost UI
    participant S as Analysis Service
    participant O as Ollama
    participant G as Gemma 3 4B
    participant V as Validation Layer
    participant DB as SQLite

    User-&amp;gt;&amp;gt;UI: Submit scope and client request
    UI-&amp;gt;&amp;gt;S: Start analysis
    S-&amp;gt;&amp;gt;S: Prepare structured evidence
    S-&amp;gt;&amp;gt;O: Send local inference request
    O-&amp;gt;&amp;gt;G: Generate proposed analysis
    G--&amp;gt;&amp;gt;O: Return model completion
    O--&amp;gt;&amp;gt;S: Return proposed result
    S-&amp;gt;&amp;gt;V: Validate structure and citations
    V-&amp;gt;&amp;gt;V: Check clause references and relevance
    V--&amp;gt;&amp;gt;S: Validated finding or error
    S-&amp;gt;&amp;gt;DB: Persist records where applicable
    S--&amp;gt;&amp;gt;UI: Return result for review
    UI--&amp;gt;&amp;gt;User: Display findings and evidence&lt;/code&gt;&lt;/pre&gt;



&lt;h3&gt;
  
  
  Model limitations
&lt;/h3&gt;

&lt;p&gt;Actual inference latency and output quality depend on hardware, model version, prompt length, inference settings, and input complexity.&lt;/p&gt;

&lt;p&gt;The reported integration suite tests specific scenarios using live local inference. Four integration tests cannot establish universal accuracy across contracts, languages, or adversarial inputs.&lt;/p&gt;

&lt;p&gt;Local inference offers greater control over data handling, but it is not automatically a complete privacy guarantee. Application configuration and optional integrations also matter.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. SOLID Principles and Engineering Decisions
&lt;/h2&gt;

&lt;p&gt;ScopeGhost applies several software engineering principles to make its behavior more maintainable and testable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Single Responsibility Principle
&lt;/h3&gt;

&lt;p&gt;Analysis, citation verification, topic-relevance checks, financial calculations, and persistence have distinct responsibilities. The model should not need to calculate invoice totals, and the financial engine should not need to interpret client intent.&lt;/p&gt;

&lt;h3&gt;
  
  
  Separation of Concerns
&lt;/h3&gt;

&lt;p&gt;Probabilistic reasoning is separated from deterministic business rules. This makes it easier to improve prompts or change the inference client without intentionally changing the rules governing citation verification or financial arithmetic.&lt;/p&gt;

&lt;h3&gt;
  
  
  Fail Safely and Preserve Uncertainty
&lt;/h3&gt;

&lt;p&gt;Missing evidence should not automatically become an out-of-scope conclusion. Where the service cannot establish a relevant contractual exclusion, it can return an ambiguous result instead of presenting an unsupported claim with unjustified confidence.&lt;/p&gt;

&lt;h3&gt;
  
  
  Defense in Depth
&lt;/h3&gt;

&lt;p&gt;The application uses multiple layers rather than relying on one prompt instruction:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Untrusted evidence framing.&lt;/li&gt;
&lt;li&gt;Structured output validation.&lt;/li&gt;
&lt;li&gt;Clause-reference validation.&lt;/li&gt;
&lt;li&gt;Citation verification.&lt;/li&gt;
&lt;li&gt;Topic-relevance filtering.&lt;/li&gt;
&lt;li&gt;Exclusion eligibility checks.&lt;/li&gt;
&lt;li&gt;Human review.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These controls address different failure modes. None guarantees protection against every attack or incorrect conclusion.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deterministic Financial Logic
&lt;/h3&gt;

&lt;p&gt;Financial calculations use integer-cent arithmetic rather than relying on generated floating-point totals.&lt;/p&gt;

&lt;p&gt;For example, at an illustrative rate of $150 per hour, a 20-hour task represents $3,000 in estimated labor. The developer remains responsible for reviewing the estimate and approving the final commercial proposal.&lt;/p&gt;

&lt;h3&gt;
  
  
  Testability and Reproducibility
&lt;/h3&gt;

&lt;p&gt;Synthetic fixtures, unit tests, a regression harness, and opt-in local inference tests make different parts of the system easier to validate independently.&lt;/p&gt;

&lt;p&gt;The following diagram summarizes these design relationships:&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TB
    A["ScopeGhost Application"]
    A --&amp;gt; B["Analysis Service"]
    A --&amp;gt; C["Citation Verifier"]
    A --&amp;gt; D["Topic-Relevance Gate"]
    A --&amp;gt; E["Financial Engine"]
    A --&amp;gt; F["Persistence Layer"]
    A --&amp;gt; G["Inference Client"]

    B --&amp;gt; C
    B --&amp;gt; D
    B --&amp;gt; E
    B --&amp;gt; F
    B --&amp;gt; G

    C --&amp;gt; H["Verifiable Evidence"]
    E --&amp;gt; I["Reproducible Calculations"]
    G --&amp;gt; J["Replaceable Inference Boundary"]&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;This illustrates the intended component boundaries, rather than claiming that every SOLID principle has been formally proven across the codebase.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Security and Prompt-Injection Handling
&lt;/h2&gt;

&lt;p&gt;Client communications are untrusted input. A message might contain text that attempts to override the model's instructions or fabricate a contractual exception.&lt;/p&gt;

&lt;p&gt;ScopeGhost uses explicit untrusted-evidence framing and deterministic checks to help prevent such content from becoming an accepted contractual finding.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    A["Untrusted Client Message"] --&amp;gt; B["Evidence Encapsulation"]
    B --&amp;gt; C["Local Model Inference"]
    C --&amp;gt; D["Proposed Structured Output"]
    D --&amp;gt; E{"Clause ID Exists?"}
    E --&amp;gt;|No| F["Reject Unknown Clause"]
    E --&amp;gt;|Yes| G["Verify Citation and Relevance"]
    G --&amp;gt; H{"Checks Pass?"}
    H --&amp;gt;|No| I["Reject or Downgrade"]
    H --&amp;gt;|Yes| J["Evidence-Grounded Finding"]
    F --&amp;gt; K["Human Review or Error Handling"]
    I --&amp;gt; K
    J --&amp;gt; K&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;In the reported live integration test, an adversarial prompt attempted to introduce an invented clause ID. The production validation layer rejected that unknown reference.&lt;/p&gt;

&lt;p&gt;This demonstrates a specific safeguard working in a tested scenario. It does not mean Gemma 3 is immune to prompt injection or that every possible adversarial request will be caught.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Financial Calculation Workflow
&lt;/h2&gt;

&lt;p&gt;The financial engine turns reviewed effort estimates into reproducible cost ranges.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    A["Candidate Scope Change"] --&amp;gt; B["Review Estimated Hours"]
    B --&amp;gt; C["Set Hourly Rate"]
    C --&amp;gt; D["Convert Monetary Values to Integer Cents"]
    D --&amp;gt; E["Calculate Minimum Cost"]
    D --&amp;gt; F["Calculate Maximum Cost"]
    E --&amp;gt; G["Build Cost Range"]
    F --&amp;gt; G
    G --&amp;gt; H["Human Reviews Estimate"]
    H --&amp;gt; I["Change-Order Draft"]&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;The underlying relationship is:&lt;/p&gt;

&lt;p&gt;[&lt;br&gt;
\text{Estimated Cost}=\text{Estimated Hours}\times\text{Hourly Rate}&lt;br&gt;
]&lt;/p&gt;

&lt;p&gt;At $150 per hour, a 20-hour task produces a $3,000 labor estimate. The result is a calculation from supplied inputs, not a guarantee of actual implementation effort or the final project price.&lt;/p&gt;
&lt;h2&gt;
  
  
  9. SDLC: From Problem Definition to Release Review
&lt;/h2&gt;

&lt;p&gt;I approached ScopeGhost through an iterative software development lifecycle rather than treating it as a one-shot AI code-generation exercise.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TD
    A["Problem Definition"] --&amp;gt; B["Requirements"]
    B --&amp;gt; C["Architecture and Threat Modeling"]
    C --&amp;gt; D["Incremental Implementation"]
    D --&amp;gt; E["Unit and Regression Tests"]
    E --&amp;gt; F["Live Integration Tests"]
    F --&amp;gt; G["Build and E2E Verification"]
    G --&amp;gt; H["Documentation and Release Review"]
    H --&amp;gt; I["User Feedback"]
    I --&amp;gt; B&lt;/code&gt;&lt;/pre&gt;



&lt;h3&gt;
  
  
  Phase 1 — Requirements
&lt;/h3&gt;

&lt;p&gt;I defined the central problem as scope creep in fixed-scope freelance engagements. The requirements included evidence-linked classifications, conservative handling of missing evidence, and reviewable change-order workflows.&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase 2 — Architecture and threat modeling
&lt;/h3&gt;

&lt;p&gt;I separated inference from deterministic validation and financial calculations. I also considered failure cases involving fabricated quotations, unknown clause IDs, irrelevant exclusions, and adversarial instructions inside client-provided text.&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase 3 — Incremental implementation
&lt;/h3&gt;

&lt;p&gt;The application was built in reviewable increments using typed interfaces, structured schemas, an inference client, analysis services, persistence, and user-facing workflows.&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase 4 — Verification
&lt;/h3&gt;

&lt;p&gt;The testing strategy includes unit tests, synthetic regression tests, opt-in live inference tests, browser tests, type checking, and production builds.&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase 5 — Documentation and release review
&lt;/h3&gt;

&lt;p&gt;The repository includes setup instructions, evaluation fixtures, a testing framework, and technical documentation. The M4.9 evaluation framework and Hacktoberfest submission materials have been committed to the repository.&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase 6 — User validation
&lt;/h3&gt;

&lt;p&gt;The next step is to obtain feedback from real freelancers and small agencies. Their experiences will help determine whether the evidence presentation and change-order workflow solve a sufficiently important problem to support a sustainable product.&lt;/p&gt;

&lt;p&gt;This is an iterative SDLC approach, not a claim of formal certification or completion of every possible release process.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Testing Architecture and Evaluation Results
&lt;/h2&gt;

&lt;p&gt;ScopeGhost separates deterministic safeguards, mock-based regression evaluation, and live model integration.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TB
    A["ScopeGhost Verification"]

    A --&amp;gt; B["Tier 1: Deterministic Safeguards"]
    A --&amp;gt; C["Tier 2: Synthetic Regression"]
    A --&amp;gt; D["Tier 3: Live Ollama Integration"]
    A --&amp;gt; E["Build and Browser Verification"]

    B --&amp;gt; B1["Schema and Citation Checks"]
    B --&amp;gt; B2["Clause and Topic Gates"]
    B --&amp;gt; B3["Financial Invariants"]

    C --&amp;gt; C1["36 Synthetic Cases"]
    C1 --&amp;gt; C2["Pre-Recorded Completions"]
    C2 --&amp;gt; C3["Production Analysis Service"]

    D --&amp;gt; D1["Gemma 3 4B"]
    D1 --&amp;gt; D2["Four Reported Integration Tests"]

    E --&amp;gt; E1["TypeScript"]
    E --&amp;gt; E2["Production Build"]
    E --&amp;gt; E3["Playwright E2E"]&lt;/code&gt;&lt;/pre&gt;



&lt;h3&gt;
  
  
  Synthetic regression benchmark
&lt;/h3&gt;

&lt;p&gt;The reported &lt;code&gt;npm run test:eval&lt;/code&gt; results on the versioned corpus &lt;code&gt;v2.0.0-synthetic&lt;/code&gt; are:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Synthetic evaluation cases&lt;/td&gt;
&lt;td&gt;36&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Strict exact accuracy&lt;/td&gt;
&lt;td&gt;97.2% (35/36)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Acceptable classification rate&lt;/td&gt;
&lt;td&gt;100% (36/36)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;False exclusion rate on in-scope fixtures&lt;/td&gt;
&lt;td&gt;0% (0/6)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Important limitation:&lt;/strong&gt; The benchmark uses &lt;code&gt;DeterministicHarnessModel&lt;/code&gt; and pre-recorded completions passed through the production &lt;code&gt;ScopeAnalysisService&lt;/code&gt;. It evaluates regression behavior and deterministic safeguards. It is not a benchmark of 36 independent live model responses or proof of real-world contract accuracy.&lt;/p&gt;

&lt;h3&gt;
  
  
  Live Ollama integration tests
&lt;/h3&gt;

&lt;p&gt;The repository includes four opt-in tests using local &lt;code&gt;gemma3:4b&lt;/code&gt; inference:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Live clause-citation extraction and verification.&lt;/li&gt;
&lt;li&gt;Analysis orchestration and SQLite persistence.&lt;/li&gt;
&lt;li&gt;Preservation of uncertainty when evidence is insufficient.&lt;/li&gt;
&lt;li&gt;A prompt-injection scenario involving an invented contractual clause reference.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These tests exercise specific scenarios, not universal model robustness.&lt;/p&gt;

&lt;h3&gt;
  
  
  Reproduce the checks
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Unit test suite&lt;/span&gt;
npm &lt;span class="nb"&gt;test&lt;/span&gt;

&lt;span class="c"&gt;# Synthetic regression evaluation&lt;/span&gt;
npm run &lt;span class="nb"&gt;test&lt;/span&gt;:eval

&lt;span class="c"&gt;# Live Ollama integration suite&lt;/span&gt;
npm run &lt;span class="nb"&gt;test&lt;/span&gt;:integration

&lt;span class="c"&gt;# TypeScript type checking&lt;/span&gt;
npm run typecheck

&lt;span class="c"&gt;# Production build&lt;/span&gt;
npm run build

&lt;span class="c"&gt;# Browser end-to-end tests&lt;/span&gt;
npm run &lt;span class="nb"&gt;test&lt;/span&gt;:e2e
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The live integration suite requires Ollama and the &lt;code&gt;gemma3:4b&lt;/code&gt; model. Consult the repository README for the exact opt-in requirements.&lt;/p&gt;

&lt;h2&gt;
  
  
  11. Local Deployment and Data Flow
&lt;/h2&gt;

&lt;p&gt;The local-first design allows developers to run the core inference workflow on their own machines.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart TB
    subgraph DEVICE["Developer Machine"]
        A["Browser"]
        B["Next.js Application"]
        C["Ollama Service"]
        D["Gemma 3 4B"]
        E["Local SQLite Database"]
    end

    A &amp;lt;--&amp;gt; B
    B &amp;lt;--&amp;gt; C
    C &amp;lt;--&amp;gt; D
    B &amp;lt;--&amp;gt; E

    F["Optional External Services"]
    B -. "If configured and invoked" .-&amp;gt; F&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;This diagram describes the intended local deployment. Optional integrations and application configuration can change the data-flow boundary, so local inference should not be interpreted as an automatic guarantee that every kind of data always remains on-device.&lt;/p&gt;

&lt;h2&gt;
  
  
  12. Why Does Open Innovation Matter?
&lt;/h2&gt;

&lt;p&gt;Open-weight AI makes it possible to experiment with local inference, inspect application behavior, and adapt the model workflow without tying the entire product to one hosted API.&lt;/p&gt;

&lt;p&gt;For ScopeGhost, three benefits stand out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data control:&lt;/strong&gt; Local inference offers a way to process sensitive project evidence without sending model prompts to a hosted LLM endpoint, when the application is configured appropriately.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cost flexibility:&lt;/strong&gt; Local inference can reduce dependence on per-request API pricing, although hardware, electricity, and maintenance still have costs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Freedom to experiment:&lt;/strong&gt; Developers can test alternative models, adjust prompts, and improve the application while keeping the validation layer under their control.&lt;/p&gt;

&lt;p&gt;Open innovation also makes the engineering more inspectable. Other developers can explore the source code, examine the evaluation fixtures, and understand what the system checks and where its limitations remain.&lt;/p&gt;

&lt;h2&gt;
  
  
  13. What's Next?
&lt;/h2&gt;

&lt;p&gt;The next milestone is practical validation with real users.&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart LR
    A["Current Foundation"] --&amp;gt; B["Validate with Freelancers"]
    B --&amp;gt; C["Improve Audit Usability"]
    C --&amp;gt; D["Broader Contract Formats"]
    D --&amp;gt; E["Additional Export Workflows"]
    E --&amp;gt; F["Expanded Evaluation Corpus"]&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;These are potential next steps, not claims that all of these features are already implemented.&lt;/p&gt;

&lt;p&gt;I want to learn whether freelancers find the audit results useful, whether evidence-backed findings make scope discussions easier, and whether the workflow saves enough time to justify a paid product.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;ScopeGhost is my exploration of how open-weight AI can support a real business problem without asking users to trust an LLM blindly.&lt;/p&gt;

&lt;p&gt;The model helps interpret natural language. Deterministic safeguards validate critical evidence. Financial logic remains reproducible. Human review stays part of the decision process.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The goal isn't to replace professional judgment. It's to give independent developers better evidence before they agree to do more work.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Explore the code and share your feedback:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt; &lt;a href="https://github.com/suvendukungfu/ScopeGhost" rel="noopener noreferrer"&gt;https://github.com/suvendukungfu/ScopeGhost&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  devchallenge #hf26challenge #opensource #ai
&lt;/h1&gt;

</description>
      <category>devchallenge</category>
      <category>hf26challenge</category>
      <category>opensource</category>
      <category>ai</category>
    </item>
    <item>
      <title>I Built an AI That Wants You to Stop Using It</title>
      <dc:creator>suvendu kumar sahoo</dc:creator>
      <pubDate>Thu, 08 Oct 2026 09:06:56 +0000</pubDate>
      <link>https://dev.to/suvendukungfu/i-built-an-ai-that-wants-you-to-stop-using-it-2003</link>
      <guid>https://dev.to/suvendukungfu/i-built-an-ai-that-wants-you-to-stop-using-it-2003</guid>
      <description>&lt;h1&gt;
  
  
  I Built an AI That Wants You to Stop Using It
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;TrailLens — Look beyond the screen.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Most AI products are designed to keep you inside the interface.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TrailLens was designed to do the opposite.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You find something outside.&lt;/p&gt;

&lt;p&gt;You capture it.&lt;/p&gt;

&lt;p&gt;Local &lt;strong&gt;Gemma 3 4B&lt;/strong&gt; helps understand it.&lt;/p&gt;

&lt;p&gt;TrailLens turns that observation into a short, structured field mission.&lt;/p&gt;

&lt;p&gt;And then it tells you:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;PHONE DOWN.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The most important part of the experience begins when the screen stops being the center of attention.&lt;/p&gt;




&lt;h2&gt;
  
  
  🌿 What Is TrailLens?
&lt;/h2&gt;

&lt;p&gt;TrailLens is a &lt;strong&gt;local AI field-experiment engine&lt;/strong&gt; for outdoor exploration.&lt;/p&gt;

&lt;p&gt;Its core loop is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SEE
  ↓
GEMMA UNDERSTANDS
  ↓
MISSION READY
  ↓
PHONE DOWN
  ↓
EXPLORE
  ↓
RETURN
  ↓
REFLECT
  ↓
FIELD RECORD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The idea is intentionally simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Use AI to create curiosity, then get out of the way.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;TrailLens is not trying to become another chatbot.&lt;/p&gt;

&lt;p&gt;It is trying to give you a reason to &lt;strong&gt;look more closely at the physical world&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧭 The Problem
&lt;/h2&gt;

&lt;p&gt;A lot of digital products optimize for attention:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;more scrolling&lt;/li&gt;
&lt;li&gt;more notifications&lt;/li&gt;
&lt;li&gt;more interactions&lt;/li&gt;
&lt;li&gt;more time on the screen&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But when you're outside, the interesting thing is usually already there.&lt;/p&gt;

&lt;p&gt;A leaf.&lt;/p&gt;

&lt;p&gt;A piece of bark.&lt;/p&gt;

&lt;p&gt;A flower.&lt;/p&gt;

&lt;p&gt;A stone.&lt;/p&gt;

&lt;p&gt;A texture.&lt;/p&gt;

&lt;p&gt;A pattern you normally walk past.&lt;/p&gt;

&lt;p&gt;So I started with a simple question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What if AI could help someone notice the physical world, then deliberately disappear from the experience?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That became TrailLens.&lt;/p&gt;




&lt;h2&gt;
  
  
  🌲 The TrailLens Experience
&lt;/h2&gt;

&lt;h3&gt;
  
  
  01 — SEE
&lt;/h3&gt;

&lt;p&gt;You notice something interesting outside.&lt;/p&gt;

&lt;h3&gt;
  
  
  02 — CAPTURE
&lt;/h3&gt;

&lt;p&gt;TrailLens uses the camera to capture the observation.&lt;/p&gt;

&lt;h3&gt;
  
  
  03 — GEMMA UNDERSTANDS
&lt;/h3&gt;

&lt;p&gt;The image enters the local analysis pipeline.&lt;/p&gt;

&lt;p&gt;Gemma 3 4B analyzes the visual input and produces structured information that TrailLens can turn into a field mission.&lt;/p&gt;

&lt;h3&gt;
  
  
  04 — MISSION READY
&lt;/h3&gt;

&lt;p&gt;Instead of returning only an identification, TrailLens generates a structured &lt;code&gt;FieldMission&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Find another nearby leaf with a similar shape and compare the number of lobes and the pattern of its main veins.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The important difference is:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;the output becomes an action, not just an answer.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  05 — PHONE DOWN
&lt;/h3&gt;

&lt;p&gt;Once the mission starts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PHONE DOWN.

Put your phone away.
Look.
Walk.
Notice.
Compare.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pocket Mode intentionally minimizes the interface.&lt;/p&gt;

&lt;h3&gt;
  
  
  06 — EXPLORE
&lt;/h3&gt;

&lt;p&gt;The user spends a short, bounded period investigating the physical environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  07 — RETURN
&lt;/h3&gt;

&lt;p&gt;When they come back:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What did you notice?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The reflection is written by the user.&lt;/p&gt;

&lt;p&gt;Gemma does not invent the experience for them.&lt;/p&gt;

&lt;h3&gt;
  
  
  08 — FIELD RECORD
&lt;/h3&gt;

&lt;p&gt;The session becomes a compact record containing the mission, session information, and the user's own reflection.&lt;/p&gt;

&lt;p&gt;The application becomes a record of something the person actually did, rather than another chat transcript.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 Why Gemma Matters
&lt;/h2&gt;

&lt;p&gt;Gemma is not just an API call hidden somewhere inside the project.&lt;/p&gt;

&lt;p&gt;It is the reasoning layer connecting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;VISUAL OBSERVATION
        ↓
LOCAL AI REASONING
        ↓
STRUCTURED FIELD MISSION
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;TrailLens uses &lt;strong&gt;Google Gemma 3 4B through Ollama&lt;/strong&gt; for local inference.&lt;/p&gt;

&lt;p&gt;That choice matters because the intended environment is the real world, where connectivity may be unreliable.&lt;/p&gt;

&lt;p&gt;The local architecture allows the core AI inference path to run on the user's machine rather than depending on a remote AI inference service.&lt;/p&gt;

&lt;p&gt;That gives TrailLens an architecture centered around:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;local inference&lt;/li&gt;
&lt;li&gt;reduced dependence on cloud AI availability for the core model step&lt;/li&gt;
&lt;li&gt;a privacy-oriented image-processing path&lt;/li&gt;
&lt;li&gt;an open-weight model that can run within a local stack&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For this project, open innovation isn't just a licensing detail.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;It changes the product architecture.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🏗️ System Architecture
&lt;/h2&gt;



&lt;pre data-lang="mermaid"&gt;&lt;code&gt;flowchart LR
    U[User Outdoors]
    C[Camera]
    B[Browser]
    A[Next.js /api/analyze]
    V[Payload Validation]
    O[Local Ollama]
    G[Gemma 3 4B]
    M[FieldMission]
    S[Safety Gate]
    Q[Mission Quality]
    P[Pocket Mode]
    X[Outdoor Session]
    R[Reflection]
    F[Field Record]

    U --&amp;gt; C
    C --&amp;gt; B
    B --&amp;gt; A
    A --&amp;gt; V
    V --&amp;gt; O
    O --&amp;gt; G
    G --&amp;gt; M
    M --&amp;gt; S
    S --&amp;gt; Q
    Q --&amp;gt; B
    B --&amp;gt; P
    P --&amp;gt; X
    X --&amp;gt; R
    R --&amp;gt; F&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;The major boundaries are intentionally explicit:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Browser → Validation → Local Inference → Structured Mission → Safety → Quality → Outdoor Activity&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  🔬 What Happens After Gemma Responds?
&lt;/h2&gt;

&lt;p&gt;I didn't want a naive:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MODEL OUTPUT
     ↓
SHOW IT TO USER
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;pipeline.&lt;/p&gt;

&lt;p&gt;Instead:&lt;br&gt;
&lt;/p&gt;

&lt;pre data-lang="mermaid"&gt;&lt;code&gt;sequenceDiagram
    participant User
    participant Browser
    participant Next as Next.js
    participant Ollama
    participant Gemma

    User-&amp;gt;&amp;gt;Browser: Capture outdoor subject
    Browser-&amp;gt;&amp;gt;Next: POST /api/analyze
    Next-&amp;gt;&amp;gt;Next: Validate payload
    Next-&amp;gt;&amp;gt;Ollama: Structured inference request
    Ollama-&amp;gt;&amp;gt;Gemma: Multimodal analysis
    Gemma--&amp;gt;&amp;gt;Ollama: Structured FieldMission
    Ollama--&amp;gt;&amp;gt;Next: Model response
    Next-&amp;gt;&amp;gt;Next: Safety validation
    Next-&amp;gt;&amp;gt;Next: Mission quality evaluation
    Next--&amp;gt;&amp;gt;Browser: Analysis + Mission
    Browser--&amp;gt;&amp;gt;User: Mission Ready&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;A generated mission therefore passes through application-level validation before it reaches the user experience.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛡️ Safety Is Part of the AI Design
&lt;/h2&gt;

&lt;p&gt;An outdoor AI assistant shouldn't blindly turn every plausible model output into an activity.&lt;/p&gt;

&lt;p&gt;TrailLens includes a deterministic safety layer that can reject unsafe challenge language and substitute a safe fallback.&lt;/p&gt;

&lt;p&gt;The system explicitly accounts for categories such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;wild plant or mushroom ingestion&lt;/li&gt;
&lt;li&gt;harvesting or collecting specimens&lt;/li&gt;
&lt;li&gt;dangerous terrain&lt;/li&gt;
&lt;li&gt;inappropriate wildlife interaction&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The principle is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;AI can create curiosity without creating unnecessary risk.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Safety is therefore treated as an application boundary, not as something the model is simply expected to get right.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧪 A Plausible Mission Isn't Necessarily a Good Mission
&lt;/h2&gt;

&lt;p&gt;One of the biggest lessons from building TrailLens was:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;A mission sounding plausible does not mean it is a good field mission.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So I built a deterministic &lt;strong&gt;Mission Quality Evaluator&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Every mission can be evaluated across five dimensions:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Dimension&lt;/th&gt;
&lt;th&gt;What it asks&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Grounding&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Is the mission connected to what was actually observed?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Specificity&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Does it contain concrete actions and observable details?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Safety&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Does it avoid known hazards?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Executability&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Can a person realistically perform it?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Outdoor Value&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Does it require real-world observation instead of screen-only thinking?&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each dimension is scored from &lt;strong&gt;0–20&lt;/strong&gt;, for a total of &lt;strong&gt;100&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The fixture suite contains &lt;strong&gt;10 deterministic scenarios&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The benchmark produced an average score of &lt;strong&gt;85.4 / 100&lt;/strong&gt;, while &lt;strong&gt;Specificity&lt;/strong&gt; was the weakest dimension at &lt;strong&gt;14.6 / 20&lt;/strong&gt; average.&lt;/p&gt;

&lt;p&gt;That result was valuable.&lt;/p&gt;

&lt;p&gt;I did &lt;strong&gt;not&lt;/strong&gt; change the rubric to make the numbers look better.&lt;/p&gt;

&lt;p&gt;The failures showed exactly where generated missions still needed improvement.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;That is the point of an evaluator.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  ⚙️ Engineering the Local Model
&lt;/h2&gt;

&lt;p&gt;TrailLens includes a reproducible Gemma benchmark suite covering:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;cold vs. warm inference&lt;/li&gt;
&lt;li&gt;model residency&lt;/li&gt;
&lt;li&gt;token ceilings&lt;/li&gt;
&lt;li&gt;prompt compression&lt;/li&gt;
&lt;li&gt;image-resolution experiments&lt;/li&gt;
&lt;li&gt;structured output&lt;/li&gt;
&lt;li&gt;reproducibility&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One repeated finding was the effect of keeping the local model resident:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Warm model-load overhead was in the tens of milliseconds in the tested runs, versus multi-second cold loading.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The project also makes an important distinction:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;model-load latency is not the same thing as total end-to-end inference latency.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Absolute inference time varied across repeated runs on the same test machine, so the benchmark is documented as empirical testbed evidence rather than a universal performance guarantee.&lt;/p&gt;




&lt;h2&gt;
  
  
  ✅ Verification
&lt;/h2&gt;

&lt;p&gt;TrailLens is backed by a real automated verification suite.&lt;/p&gt;

&lt;p&gt;Current project verification includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;100 automated tests&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;ESLint with zero errors&lt;/li&gt;
&lt;li&gt;successful Next.js production build&lt;/li&gt;
&lt;li&gt;deterministic safety tests&lt;/li&gt;
&lt;li&gt;Mission Quality fixture evaluation&lt;/li&gt;
&lt;li&gt;structured &lt;code&gt;FieldMission&lt;/code&gt; validation&lt;/li&gt;
&lt;li&gt;local Gemma benchmark artifacts&lt;/li&gt;
&lt;li&gt;reproducibility evidence&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The repository deliberately separates different forms of evidence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Functional Correctness
        ↓
Contract Validation
        ↓
Safety Validation
        ↓
Mission-Quality Evaluation
        ↓
Performance Benchmarking
        ↓
Reproducibility
        ↓
Real-World Field Validation
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That distinction matters.&lt;/p&gt;

&lt;p&gt;A passing unit test is not the same thing as proving that a person enjoyed a field mission.&lt;/p&gt;




&lt;h2&gt;
  
  
  🌿 Why This Fits "Touch Grass"
&lt;/h2&gt;

&lt;p&gt;The challenge is about using open-source AI to create something that gets people away from the screen and into the real world.&lt;/p&gt;

&lt;p&gt;TrailLens was built around that requirement from the beginning.&lt;/p&gt;

&lt;h3&gt;
  
  
  Typical AI interaction
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;QUESTION
   ↓
AI ANSWER
   ↓
MORE QUESTIONS
   ↓
MORE SCREEN TIME
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  TrailLens
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;OBSERVATION
   ↓
GEMMA
   ↓
FIELD MISSION
   ↓
PHONE DOWN
   ↓
REAL WORLD
   ↓
REFLECTION
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The screen is supposed to be the &lt;strong&gt;shortest part of the experience&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;That is the product.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🏕️ What Makes the Idea Different?
&lt;/h2&gt;

&lt;p&gt;The interesting part isn't simply:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Gemma can identify a leaf."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The interesting part is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What happens after the identification?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Instead of ending with:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"This is probably an oak leaf."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;TrailLens can turn that observation into:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Find another nearby leaf and compare its lobes and main veins."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That changes AI from an &lt;strong&gt;answer engine&lt;/strong&gt; into a &lt;strong&gt;field-experiment trigger&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;And then the phone is supposed to disappear from the experience.&lt;/p&gt;




&lt;h2&gt;
  
  
  📖 The Field Record
&lt;/h2&gt;

&lt;p&gt;The end product is not a chat history.&lt;/p&gt;

&lt;p&gt;It is a &lt;strong&gt;field record&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A compact memory of:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;what was investigated&lt;/li&gt;
&lt;li&gt;what mission was attempted&lt;/li&gt;
&lt;li&gt;session information&lt;/li&gt;
&lt;li&gt;what the user personally noticed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The reflection is intentionally &lt;strong&gt;user-authored&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;TrailLens doesn't ask the model to fabricate what the person experienced.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛠️ Built With
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Frontend
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Next.js&lt;/li&gt;
&lt;li&gt;React&lt;/li&gt;
&lt;li&gt;TypeScript&lt;/li&gt;
&lt;li&gt;Tailwind CSS&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  AI
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Google Gemma 3 4B&lt;/li&gt;
&lt;li&gt;Ollama&lt;/li&gt;
&lt;li&gt;structured JSON / JSON Schema output&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Engineering
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Zod&lt;/li&gt;
&lt;li&gt;Vitest&lt;/li&gt;
&lt;li&gt;ESLint&lt;/li&gt;
&lt;li&gt;Turbopack&lt;/li&gt;
&lt;li&gt;deterministic safety rules&lt;/li&gt;
&lt;li&gt;deterministic Mission Quality evaluation&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📈 What I Actually Built
&lt;/h2&gt;

&lt;p&gt;The project evolved through concrete engineering milestones.&lt;/p&gt;

&lt;h3&gt;
  
  
  M1 — Field Mission Contract
&lt;/h3&gt;

&lt;p&gt;A structured contract between model output and physical-world activity.&lt;/p&gt;

&lt;h3&gt;
  
  
  M2 — Local Gemma Latency Engineering
&lt;/h3&gt;

&lt;p&gt;Cold/warm benchmarking, model residency, prompt compression, token boundaries, resolution experiments, and structured output testing.&lt;/p&gt;

&lt;h3&gt;
  
  
  M2.1 — Reproducibility Evidence
&lt;/h3&gt;

&lt;p&gt;A second complete benchmark run to separate reproducible engineering behavior from variable wall-clock latency.&lt;/p&gt;

&lt;h3&gt;
  
  
  M3 — Pocket Mode + Reflection + Field Records
&lt;/h3&gt;

&lt;p&gt;The physical immersion and reflection loop.&lt;/p&gt;

&lt;h3&gt;
  
  
  M4 — Mission Quality + Grounding
&lt;/h3&gt;

&lt;p&gt;A deterministic 5-dimension evaluator backed by a 10-fixture test suite.&lt;/p&gt;

&lt;h3&gt;
  
  
  Productization
&lt;/h3&gt;

&lt;p&gt;An editorial field-guide interface, camera-pipeline hardening, SDLC documentation, contributor documentation, and engineering evidence.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔍 What I Learned
&lt;/h2&gt;

&lt;p&gt;The biggest lesson wasn't:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;"Make the model smarter."&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It was:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Design the system around what the model is good at — and explicitly constrain what it isn't.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That led to several architectural decisions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;structured model output&lt;/li&gt;
&lt;li&gt;deterministic safety gates&lt;/li&gt;
&lt;li&gt;deterministic mission-quality evaluation&lt;/li&gt;
&lt;li&gt;performance benchmarking&lt;/li&gt;
&lt;li&gt;reproducibility checks&lt;/li&gt;
&lt;li&gt;Pocket Mode&lt;/li&gt;
&lt;li&gt;user-authored reflection&lt;/li&gt;
&lt;li&gt;explicit evidence boundaries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The result is less like a chatbot and more like an &lt;strong&gt;AI-powered field instrument&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚠️ What TrailLens Does Not Claim
&lt;/h2&gt;

&lt;p&gt;I want the project to be honest about its limits.&lt;/p&gt;

&lt;p&gt;The Mission Quality system is a deterministic lexical and structural proxy. It is not a semantic judge of the physical world.&lt;/p&gt;

&lt;p&gt;The 10-fixture benchmark is not a human user study.&lt;/p&gt;

&lt;p&gt;Benchmark latency is measured on a specific local test environment and should not be interpreted as a universal hardware guarantee.&lt;/p&gt;

&lt;p&gt;Actual outdoor engagement depends on people, terrain, weather, curiosity, and context.&lt;/p&gt;

&lt;p&gt;Those limitations are documented deliberately.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Reproducibility is more useful than inflated claims.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🌎 Open Source
&lt;/h2&gt;

&lt;p&gt;TrailLens is open source:&lt;/p&gt;

&lt;h3&gt;
  
  
  GitHub
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/suvendukungfu/traillens" rel="noopener noreferrer"&gt;https://github.com/suvendukungfu/traillens&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The repository includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;application source&lt;/li&gt;
&lt;li&gt;architecture documentation&lt;/li&gt;
&lt;li&gt;SDLC documentation&lt;/li&gt;
&lt;li&gt;evaluation reports&lt;/li&gt;
&lt;li&gt;benchmark artifacts&lt;/li&gt;
&lt;li&gt;Mission Quality fixtures&lt;/li&gt;
&lt;li&gt;contributor instructions&lt;/li&gt;
&lt;li&gt;changelog&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🚀 Run TrailLens Locally
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Requirements
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Node.js&lt;/li&gt;
&lt;li&gt;Ollama&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Install Gemma:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ollama pull gemma3:4b
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Clone:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/suvendukungfu/traillens.git
&lt;span class="nb"&gt;cd &lt;/span&gt;triallens
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then open:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:3000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🧭 The Philosophy
&lt;/h2&gt;

&lt;p&gt;The entire project can be reduced to one sentence:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Use AI once. Then go outside.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Or even shorter:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;AI is the bridge. The real product is outside.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is why TrailLens exists.&lt;/p&gt;




&lt;h2&gt;
  
  
  🌱 Hacktoberfest 2026 — Touch Grass
&lt;/h2&gt;

&lt;p&gt;TrailLens was built for the &lt;strong&gt;Hacktoberfest Open-Source AI Challenge — Week 1: Touch Grass&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The challenge asks builders to create something with open-source AI at its core that gets people away from the screen and into the world.&lt;/p&gt;

&lt;p&gt;TrailLens was designed around exactly that constraint.&lt;/p&gt;

&lt;p&gt;The most important screen in the product is the one that tells you:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;PHONE DOWN.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then the app gets out of the way.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔗 Links
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;GitHub:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://github.com/suvendukungfu/traillens" rel="noopener noreferrer"&gt;https://github.com/suvendukungfu/traillens&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hacktoberfest Week 1:&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://dev.to/challenges/hacktoberfest-week1-2026-10-05"&gt;https://dev.to/challenges/hacktoberfest-week1-2026-10-05&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;License:&lt;/strong&gt; MIT&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thought
&lt;/h1&gt;

&lt;p&gt;Most AI assistants try to keep you talking to them.&lt;/p&gt;

&lt;p&gt;TrailLens has a different goal:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Say something useful.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Give you something to investigate.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Then get out of the way.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🌿 Look beyond the screen.
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>devchallenge</category>
      <category>hf26challenge</category>
      <category>gemma</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
