|
| 1 | +# Agent Guide |
| 2 | + |
| 3 | +This file is the canonical instruction entry point for coding agents working with `indexer-core`. |
| 4 | + |
| 5 | +It is intentionally lean. Use it to build a correct mental model quickly, then open the linked repo docs instead of inferring behavior from scattered source files. |
| 6 | + |
| 7 | +## What This Library Is |
| 8 | + |
| 9 | +`indexer-core` is a Kotlin library for building VeChainThor indexers. |
| 10 | + |
| 11 | +At a high level it provides: |
| 12 | + |
| 13 | +- `IndexerProcessor` as the application persistence boundary |
| 14 | +- `IndexerFactory` as the only supported way to configure and build indexers |
| 15 | +- `IndexerRunner` to initialise, fast-sync when possible, coordinate dependencies, and keep indexers running through retries and reorg recovery |
| 16 | +- two runtime modes: |
| 17 | + - `LogsIndexer` for fast log-based catch-up when you only need decoded events / transfers |
| 18 | + - `BlockIndexer` when you need full block context or dependency ordering |
| 19 | + |
| 20 | +Do not ask users to construct indexers manually from implementation classes unless they are working on the library internals themselves. For normal usage, all indexers should be built with `IndexerFactory`. |
| 21 | + |
| 22 | +## Who This Guide Is For |
| 23 | + |
| 24 | +This guide is for both: |
| 25 | + |
| 26 | +- agents changing `indexer-core` itself |
| 27 | +- agents helping a consumer integrate `indexer-core` into another service |
| 28 | + |
| 29 | +If the task is library maintenance, preserve public behavior documented in the repo docs unless the change explicitly updates that behavior. |
| 30 | + |
| 31 | +If the task is consumer guidance, optimize for correct mode selection and integration advice before discussing internals. |
| 32 | + |
| 33 | +## Required Onboarding Path |
| 34 | + |
| 35 | +Before making claims about library behavior, read in this order: |
| 36 | + |
| 37 | +1. [`README.md`](README.md) |
| 38 | +2. [`docs/README.md`](docs/README.md) |
| 39 | +3. one targeted guide based on the task: |
| 40 | + - runtime model and lifecycle: [`docs/IndexerOverview.md`](docs/IndexerOverview.md) |
| 41 | + - log-based mode and fast sync: [`docs/LogsIndexerOverview.md`](docs/LogsIndexerOverview.md) |
| 42 | + - ABI loading and decoded events: [`docs/EventsAndABIHandling.md`](docs/EventsAndABIHandling.md) |
| 43 | + - business event design: [`docs/BusinessEvents.md`](docs/BusinessEvents.md) |
| 44 | + - upgrade / compatibility questions: [`docs/MIGRATION-8.0.0.md`](docs/MIGRATION-8.0.0.md) |
| 45 | + |
| 46 | +The repo markdown docs are the source of truth. Prefer them over memory, ad hoc code reading, or external copies. |
| 47 | + |
| 48 | +## Mental Model To Keep In Mind |
| 49 | + |
| 50 | +- `IndexerProcessor` is where consumers persist progress and domain data. |
| 51 | +- The runtime may emit either `IndexingResult.LogResult` or `IndexingResult.BlockResult`; processors should handle both when relevant to the configuration. |
| 52 | +- Startup rollback is intentional. It is a data-integrity feature, not a bug. |
| 53 | +- Reorg recovery is part of the runtime contract. Consumers are expected to implement deterministic rollback behavior. |
| 54 | +- Dependencies affect execution semantics, not just throughput. Adding `dependsOn(...)` changes how the runtime must coordinate indexers. |
| 55 | + |
| 56 | +## Mode Selection Checklist |
| 57 | + |
| 58 | +Use this checklist before recommending or editing indexer configuration. |
| 59 | + |
| 60 | +Choose the default factory-built log mode when: |
| 61 | + |
| 62 | +- the consumer only needs decoded ABI events, business events, or VET transfers |
| 63 | +- fastest catch-up is the priority |
| 64 | +- there is no same-block dependency on another indexer |
| 65 | + |
| 66 | +Choose `includeFullBlock()` when the consumer needs: |
| 67 | + |
| 68 | +- full block contents |
| 69 | +- reverted transaction visibility |
| 70 | +- gas / fee metadata from full block processing |
| 71 | +- clause inspection results from `callDataClauses(...)` |
| 72 | + |
| 73 | +Choose `dependsOn(...)` when: |
| 74 | + |
| 75 | +- one indexer must finish a block before another processes that same block |
| 76 | + |
| 77 | +Important: |
| 78 | + |
| 79 | +- `LogsIndexer` and `BlockIndexer` are not interchangeable modes. |
| 80 | +- `dependsOn(...)` forces block-based execution semantics. |
| 81 | +- `includeFullBlock()` forces block-based execution semantics. |
| 82 | + |
| 83 | +Choose business events when: |
| 84 | + |
| 85 | +- downstream consumers care about higher-level actions rather than every raw event |
| 86 | + |
| 87 | +Choose raw ABI events when: |
| 88 | + |
| 89 | +- the consumer needs each decoded event individually |
| 90 | +- there is no stable semantic grouping worth encoding as a business event |
| 91 | + |
| 92 | +## Guardrails |
| 93 | + |
| 94 | +- Build indexers through `IndexerFactory`, not by manually wiring implementation classes in application code. |
| 95 | +- Do not describe `LogsIndexer` and `BlockIndexer` as equivalent choices with different performance profiles. They expose different runtime behavior and different data. |
| 96 | +- Do not treat startup rollback as suspicious behavior. It is part of the library’s safety model. |
| 97 | +- Do not rely on stale documentation copies. The repo docs are authoritative. |
| 98 | +- Do not present internal implementation details as stable public API unless they are explicitly documented as such. |
| 99 | + |
| 100 | +## Common Agent Tasks |
| 101 | + |
| 102 | +Optimize guidance for these common tasks: |
| 103 | + |
| 104 | +- explaining how to integrate `indexer-core` into another service |
| 105 | +- changing the library itself |
| 106 | +- debugging behavior differences between `LogsIndexer` and `BlockIndexer` |
| 107 | +- designing ABI-driven or business-event-driven indexing setups |
| 108 | + |
| 109 | +Documentation updates matter, but they are secondary to preserving correct runtime behavior and public guidance. |
| 110 | + |
| 111 | +## Verification Expectations |
| 112 | + |
| 113 | +When changing this library: |
| 114 | + |
| 115 | +- run targeted tests for the touched behavior as a minimum |
| 116 | +- run broader `./gradlew test` when the change is cross-cutting or affects shared runtime behavior |
| 117 | +- run formatting checks or formatting fixes when Kotlin code changes |
| 118 | + |
| 119 | +Minimum standard before claiming completion: |
| 120 | + |
| 121 | +- the changed behavior is covered by tests or an existing test path was exercised |
| 122 | +- any affected public guidance remains consistent with the repo docs |
| 123 | +- the response states clearly if full verification was not run |
| 124 | + |
| 125 | +Useful commands: |
| 126 | + |
| 127 | +```bash |
| 128 | +./gradlew test |
| 129 | +./gradlew test --tests "org.vechain.indexer.SomeTest" |
| 130 | +./gradlew spotlessCheck |
| 131 | +./gradlew spotlessApply |
| 132 | +``` |
| 133 | + |
| 134 | +## When Working From Source |
| 135 | + |
| 136 | +The codebase is useful for confirmation, but agents should not need to reverse-engineer the library from source just to understand its purpose. |
| 137 | + |
| 138 | +Read source after the docs when you need to: |
| 139 | + |
| 140 | +- confirm an implementation detail |
| 141 | +- debug a behavioral discrepancy |
| 142 | +- update internals while preserving the documented contract |
| 143 | + |
| 144 | +If source and docs appear to disagree, call that out explicitly instead of silently choosing one. |
0 commit comments