Afunana includes an AI assistant that answers questions about your legacy estate in plain business language and backs every factual claim with a citation to the exact source line. It is accessible from a floating panel on every page and as a full-screen page.
This is not a chat window over a context window. The assistant is grounded in Afunana's persistent knowledge graph -- the cross-referenced map of program → program, program → file, and file → field relationships across the whole system, kept current as the code changes. A generic chatbot can explain a snippet you paste into it; Afunana answers questions about the entire system and shows you where the answer comes from.
This page describes what the chat can do for users. For the technical internals -- the retrieval pipeline, planner loop, and tools -- see Chat & RAG System.
Ask What the Business Actually Wants to Know
Because the assistant reasons over documented business rules, cross-references, and field lineage -- not just raw text -- it answers the questions a business, not just a compiler, cares about:
- "Which programs update the customer balance?"
- "What breaks if we lengthen the policy number from 8 to 10 digits?"
- "Where is the rule that caps a discount at 15%, and which programs enforce it?"
- "Which batch jobs touch the accounts-receivable files during month-end?"
- "Show me every program that can delete a payment record."
Each answer names specific programs and lines, so a follow-up is always one click into the real code.
How It Works
The chat answers in tiers so cheap questions stay cheap and hard questions get the full pipeline.
Tiered answering. Every question first goes through an intent classifier. Straightforward questions are routed to a single-pass simple-answer path, which answers directly from retrieved context without running the full planner loop. Questions the classifier judges to need deeper analysis fall through to the iterative planner loop below. This keeps latency and cost low for the common "what does program X do?" case while reserving the expensive multi-round path for genuinely complex questions.
Planner → Executor → Answer loop. For questions that need it, the chat runs a multi-agent loop (PlannerAgent → ExecutorAgent → iterative AnswerBuilder), not a single LLM call:
- Plan -- the planner emits a JSON plan of intents and tool calls: which data sources to search and what to look for.
- Execute -- the executor runs those tools against the source, documentation, vector index, keyword index, and structured cross-reference.
- Compose -- gathered evidence is synthesized into a coherent, cited answer.
- Reflect -- an agentic answer loop evaluates whether the answer is complete; if not, it requests more evidence and iterates, up to a configurable number of rounds.
Simple lookups resolve in one or two rounds -- or short-circuit on the simple-answer path entirely. Complex analytical questions ("how does the entire billing subsystem handle currency conversion?") take several rounds as the system discovers and follows dependency chains.
Query Modes
The panel exposes a mode toggle. Ask and Plan are live; Agent mode appears as a coming-soon option and is currently disabled.
Ask Mode
Read-only question answering. Ask anything about the codebase and get a sourced, cited response drawn from all available evidence -- generated documentation, raw source, cross-reference data, field definitions, and any documents you have uploaded.
Plan Mode
Structured change proposals. Describe a modification and the assistant produces a validated implementation plan, rendered as a card in the chat.
Plan output includes:
| Section | Content |
|---|---|
| Programs to Modify | Programs that need changes, with specific line references |
| Code Changes | Exact source-line edits, in the codebase's own coding style |
| Files Affected | Data files that may need structural changes |
| Dependencies | Other programs impacted by the change |
| Compile Order | Correct sequence for recompilation |
| Testing Scope | What to test after implementing the change |
| Risk Assessment | Potential issues -- data truncation, parameter mismatches, missing error handling |
Plan Mode validates proposed changes against the actual parsed structure and retries once with corrections if the plan is structurally invalid. If a plan suggests modifying a COPY member, it identifies every program that includes that member and flags them for recompilation.
Change plans are the PLAN phase of Afunana's four-phase model, and the default posture is to stop here and hand off to a developer. An approval-gated EXECUTE workflow can apply an approved plan back to the live IBM i in the codebase's own style, but that is a separate, admin-triggered step (off on the public production instance). The COBOL compile step (CRTCBLPGM) is temporarily disabled; the rest of the plan-execution flow runs. See Program Documentation and the admin change-plan workflow for detail. Change plans are never served from cache and are wiped whenever the collection is rebuilt.
Evidence Gathering (Hybrid RAG)
The system uses hybrid retrieval -- semantic and lexical search fused together for higher recall and precision than either alone. Semantic search finds relevant programs even when the question uses different words than the code -- asking about "customer billing" finds programs dealing with CUSTINV and ARPROC -- while lexical search catches exact matches that semantic search may rank lower, such as specific program names, field names, and error codes. All embeddings are computed on the box and never leave the customer network.
Structured and Source Queries
Beyond the two indexes, the executor can query the structured cross-reference directly ("which programs call X," "which programs write to file Y," "which programs use field Z"), search raw source for specific paragraph names or code patterns, and pull generated documentation by program or file name. The planner picks the combination that fits the classified intent.
Response Generation
Streaming
Answers stream to the client via Server-Sent Events (SSE), with live tool-status progress so you can see the assistant planning, searching, and composing in real time rather than waiting for a final block.
Citations
Every factual claim carries a citation in PROGRAM:LINE format, rendered as a clickable badge that opens the referenced program or scrolls to the referenced lines. Grounded, not guessed -- the same citation mechanism that backs every documented business rule.
Confidence Scoring
The assistant indicates when evidence is strong versus when it is inferring. Direct matches from source are high confidence; inferences drawn from multiple indirect sources are flagged as such.
Semantic Cache
A semantic question→answer cache short-circuits repeat and near-duplicate questions for speed and cost. Change plans are never cached, and the entire cache is wiped whenever the collection is rebuilt, so answers never go stale against new code.
Bring Your Own Documents
Existing specifications, manuals, wiki pages, and analysts' notes fold directly into the same searchable, cited knowledge base. Upload PDF, DOCX, TXT, or MD files (up to 20 MB) to a collection or a specific program; the content is chunked and added to both the vector and keyword indexes. From then on, your own documents are retrieved in chat exactly like anything the code itself revealed -- so an answer can draw on both the reconstructed knowledge and your institutional documentation at once. (This is distinct from spec-document generation, which produces new specs; see Program Documentation.)
File Attachments
Attach files to a single chat message for one-off context.
| File Type | Processing |
|---|---|
| Images (PNG, JPG) | A vision model reads the image and extracts visible text, included as query context |
| Text files (.txt) | Content parsed and included directly |
| CSV files | Parsed into structured data; column headers and sample rows included |
Because images are read by a vision-capable model rather than a classic OCR engine, the assistant can read screenshots, error dialogs, and 5250 screens. This is useful for questions like "this screenshot shows an error on screen X -- which program generates this screen and what causes it?"
Common Program Questions
There is no template to fill in -- you ask in plain natural language. The backend recognizes common program questions and takes fast paths for them, such as what a program does, which files a program uses, and who calls a program.
Chat Sessions
Persistence. Every session is saved automatically. Close the panel and return later to continue -- full message history, citations, and evidence trails are preserved.
History. A resizable side panel (toggled from the header) lists previous sessions with titles and timestamps. Click any session to reload it.
Context continuity. Within a session the assistant maintains context across messages, so a follow-up like "what about the error handling in that program?" resolves "that program" from the previous exchange.
Example Queries
| Category | Example |
|---|---|
| Program lookup | "What does CNKOVMTR do?" |
| Business rules | "Which programs update the customer balance?" |
| Impact analysis | "If I change POLICY_NUM from 9(8) to 9(10), what breaks?" |
| Source navigation | "Show me section B-TIPUL in CNKOVDSFL" |
| Field search | "Which files contain a field for identity number?" |
| Dependency trace | "Show me the call chain from ORDRMAIN to ORDRVAL" |
| Field lineage | "Trace the field POLICY_NUM from input to output" |
| File usage | "Which programs write to POLDETAIL?" |
| Subsystem discovery | "What programs belong to the same module as CNKOVMTR?" |
| Comparison | "How does PROGA differ from PROGB?" |
| Parameter checks | "Are there parameter mismatches in POLCALC?" |
| Code patterns | "Find all GO TO statements in the codebase" |
| Duplicate detection | "Find programs with logic similar to POLCALC's validation section" |
| Change planning | "Add a new field EFFECTIVE_DATE to CUSTMAST" |
| Code generation | "Write a new program that validates email addresses" |
| Bug investigation | "POLCALC returns wrong values for large amounts -- help me find the bug" |
Language Support
Ask in any language -- the assistant responds in the same language. Program names, field names, and technical terms always appear in their original left-to-right form regardless of the response language.