Datasets:
File size: 14,521 Bytes
cb5c03a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | # Labelling guide — ModuleMap-Bench
**Version 2.1** (2026-11-13). Supersedes `ANNOTATION_GUIDELINES.md` 1.1; every
rule of 1.1 is kept, reordered, and marks are now labelled. A label records
`guideline_version`; a change to this file that can change a label raises the
version.
## 1. Unit and sources
One **top-level Java type** (class, abstract class, interface, enum, record,
annotation type) in a module's `src/main/java`, at the project's pinned commit.
Nested types belong to their outer type. Test code is out of scope.
Decide from the **source code**: the type's file first; then, when a rule below
asks for it, its supertypes, implementations, subclasses, users and the
module's `pom.xml`. **Never** read the output of a tool that assigns roles or
marks — agentkit's Maps, `AGENTS.md`, `.agentkit/`, `--dump-features`, its JSON
traces — and never run one.
Each label has: one **role**, a list of **marks** (possibly empty), a
**confidence** (`sure` or `unsure`) and a one-sentence **rationale** that cites
the line of code it rests on (`L12: @FeignClient(name = "pay-server")`).
## 2. Decision order
Take the first step that decides; rule numbers refer to section 4.
1. **Always `none`** (section 3.8) — exceptions, enums, constants, annotation
types, builders and factories, validators, DTOs/VOs/forms, converters,
`package-info`. Stop. A *utility* is `none` only when no step below
describes what it does: a `*Util` whose main job is a remote call is a
`client` (rule 4.1, what it does beats its name).
2. **Invoked by a framework as the start of a unit of work** → `entry`
(rule 4.2 lets it beat any role below).
3. **Is persisted data** → `domain` (beats `event`, rule 4.3).
4. **Reads or writes the application's own store** → `persistence`.
5. **Calls another system over the network** as its main purpose → `client`
(HTTP, but also SSH/SCP/SFTP, an LDAP or mail server, a broker connection
the class opens itself; section 3.2).
6. **Is an event** (a message saying something happened) → `event`.
7. **Configures the application** → `config`.
8. **Holds business logic** → `service`.
9. **Interface or abstract class**: take the role its implementations or
subclasses agree on (rules 4.4, 4.5); with none, `none`.
10. Otherwise `none`.
Then decide the **marks** (section 5) independently of the role.
## 3. Roles
### 3.1 `entry` — invoked by a framework as the start of a unit of work
Examples:
- `OrderController` with `@RestController` and `@GetMapping("/orders/{id}")`.
- `PaymentListener` with `@KafkaListener(topics = "payments")`, or a
`@RocketMQMessageListener`, `@RabbitListener`, Redis Stream listener.
- `ApprovalDelegate implements JavaDelegate` (BPMN service task), an
`ExecutionListener`/`TaskListener`, an external-task handler or Camunda 8 job worker.
- `CleanupJob` with `@Scheduled(cron = …)`, a Quartz `Job`, an xxl-job handler.
- The `@SpringBootApplication` class; a `CommandLineRunner`/`ApplicationRunner`;
a `SpringBootServletInitializer`; a JAX-RS `@Path` resource; a gRPC service
implementation, servlet, WebSocket endpoint, GraphQL resolver.
- A class whose main method is an `@EventListener` or that implements
`ApplicationListener`, or subscribes to a domain-event bus.
Counter-examples:
- `GlobalExceptionHandler` with `@RestControllerAdvice` → `none` (it handles
errors of a unit of work, it does not start one).
- A servlet filter, `HandlerInterceptor` or gateway filter → `none`.
- A `@Controller` with no request mapping → by its other evidence, usually `none`.
- An LLM tool callback or a parse-time hook → `none`.
### 3.2 `client` — calls another system over the network
Examples:
- `PayApi` with `@FeignClient(name = "pay-server")`.
- An interface with `@HttpExchange` methods (Spring HTTP interface).
- `SmsSender`, a class whose main job is calling a remote HTTP API through a
`RestTemplate`, `WebClient` or `OkHttpClient` field.
- `NacosRulePublisher`, a reader or writer of a remote configuration store.
- `SftpFileClient`, `ScpClientUtil`, `ExecuteShellUtil`: a class that opens a
connection to another host itself (SFTP, SCP, SSH) to do its work.
- `KafkaAdapter` creating a `KafkaConsumer` and polling it in its own loop, or
an MQTT client it connects and subscribes itself: the class drives the
remote call, no framework invokes it (a `@KafkaListener` would be `entry`).
Counter-examples:
- `PayApiFallbackFactory` → `none` (fallback, not the call).
- A class that wraps an in-process engine (`RuntimeService` of an embedded
Camunda) → `service` or `none`, not `client`.
- A storage adapter writing to the application's own database → `persistence`.
### 3.3 `service` — holds business logic
Business logic means decisions about the application's own business data
(orders, users, configurations of the product): what to create, change,
allow or refuse. Technical machinery — parsing, resolving, caching,
decorating, validating input, mapping errors, cross-cutting aspects — is
`none` even when it is a `@Component` and its methods contain conditions.
Examples:
- `OrderServiceImpl` with `@Service` and business methods.
- `OrderService`, an interface implemented by a `@Service` (rule 4.5).
- A use case, application service, command or query handler (`CourseCreator`,
`SendMoneyService`); a stateless domain service (`CourseFinder`).
- A message publisher that decides what to publish.
- In infrastructure products: a class doing the product's own work on request
(`*Cmd` of an engine, the core manager of a server).
- A class annotated `@Service` (or `@DubboService`, a service-framework bean)
**is `service` even when it only delegates to its mapper or repository**:
the mapper, DAO or repository holding the queries is `persistence`, the
`@Service` over it is the service layer (`LitemallOrderService`).
Counter-examples:
- A thin adapter around a framework (`RedisTemplate` wrapper with no rules) → `none`.
- `DateUtils`, `JsonHelper` → `none`.
- `@Aspect` releasing a lock, a `PermissionValidator`, a text-to-change-set
resolver, a caching decorator, a failure-to-exception resolver → `none`
(technical machinery, even with conditions inside).
- A strategy interface whose implementations generate codes or numbers
(`IFillRuleHandler`) → `none` unless the implementations decide on business
data; an `@Service` implementation of it would make it `service` (rule 4.5).
### 3.4 `domain` — persisted business data
Examples:
- `UserDO` with `@TableName("system_users")` (MyBatis-Plus); a JPA `@Entity`,
`@Embeddable`, `@MappedSuperclass` or base entity; a Mongo `@Document`.
- `LitemallGoods`, a plain class a MyBatis mapper XML or generator maps to a table.
- A value object stored as a field or column of a stored aggregate (`CourseId`,
`Money` of a stored account, `TrackingId` kept as `tracking_id`,
`PatronHolds` of a stored `Patron`). **Look at who holds it** (the users
listed beside the code): when a stored aggregate keeps it, it is `domain`,
even without any mapping annotation on the value object itself.
- A record stored in a configuration or rule store.
- A persisted notification, even when named `*Event` (rule 4.3).
Counter-examples:
- `UserRespVO`, `OrderCreateReqDTO`, a page or projection object → `none`,
even when it mirrors the entity field for field.
- A criteria or specification object that is not stored → `none`.
### 3.5 `persistence` — reads or writes the application's own store
Examples:
- `UserMapper extends BaseMapperX<UserDO>` (MyBatis/MyBatis-Plus).
- `OrderRepository extends JpaRepository<Order, Long>`; a DAO.
- `CourseRepository`, a domain repository interface, and
`MySqlCourseRepository`, its implementation (any store, also in memory).
- In infrastructure products: a `*Manager` or `*Dao` over the product's own tables.
Counter-examples:
- `GoodsExample`, a generator criteria class → `none`.
- `UserConvert` (MapStruct "mapper") or an Excel mapper → `none`.
### 3.6 `event` — is an event, not its handler
Examples:
- `OrderPaidEvent extends ApplicationEvent`.
- `CourseCreatedDomainEvent` published on a domain-event bus.
- `KafkaPaymentDto`, a plain object published to a broker as the message that
something happened, whatever its name.
Counter-examples:
- `OrderPaidListener` handling the event → `entry`.
- A persisted `Notification` record → `domain`.
### 3.7 `config` — configures the application
Examples:
- `RedisConfig` with `@Configuration` and `@Bean` methods.
- `PayAutoConfiguration` with `@AutoConfiguration`.
- `SmsProperties` with `@ConfigurationProperties(prefix = "sms")`.
Counter-examples:
- A `@Component` that validates settings or customises error output → `none`.
- `UploadConfig`, a plain value class named `*Config` → `none`.
- A `@Configuration` whose main method is an `@EventListener` → `entry` (rule 4.2).
### 3.8 `none` — none of the above
Examples: DTOs, VOs, forms, requests, responses; enums and constants in any
package; exceptions; annotation types; utilities; builders and factories;
validators; converters and assemblers; interceptors and filters; framework SPI
adapters; the plumbing of a bus (the bus, its registry, serializer, middleware);
command and query messages; parsers, caches and internal data structures of
an infrastructure product; test fixtures shipped in main code.
Counter-examples:
- An enum stored as a table → still `none` (enums are always `none`).
- A `*Helper` that runs business rules → `service` (rule 4.1).
## 4. When two roles seem to apply
1. **What it does at run time beats what it is called.** `KongAdapterService`
calling the Kong admin API is a `client`; `JobRegistryHelper` running
registry logic on its own thread is a `service`.
2. **Being invoked by the framework wins.** A `@Service` or `@Configuration`
whose main method is an `@EventListener` is an `entry`.
3. **Persisted data beats event.** A stored notification is `domain`.
4. **An abstract base takes the role of its subclasses** when they are all one
thing (an abstract stream listener is an `entry`).
5. **An interface takes the role of its implementations** when they agree; an
input port implemented by a service is a `service`, an output port
implemented by a persistence adapter is `persistence`; with no
implementation and no other evidence, `none`.
6. Still undecided: choose the closer role, mark the label `unsure`, and name
the runner-up in the rationale.
## 5. Marks
Marks say **who relies on the type**, not what it does; they are decided
separately and may sit beside any role, `none` included.
### 5.1 `api` — part of its module's contract with the other modules
The type is public and the **main code of another module of the same reactor**
imports or uses it (test code and modules outside the reactor do not count),
and it is not in an `internal` or `impl` package.
Examples:
- `PayApi` (`client`) in `pay-api`, imported by `order-server`: `client` + `api`.
- `RedisService` (`service`) in `mall-common`, imported by `mall-admin`: `service` + `api`.
- `ApiErrorLogCreateReqDTO` (`none`) imported by three modules: `none` + `api`.
Counter-examples:
- A type imported only by another module's tests → no `api`.
- A public class in `…internal…` imported by another module → no `api`
(it leaks, it is not a contract); say so in the rationale.
### 5.2 `ext` — an extension point
An interface or abstract class with **two or more implementations or
subclasses in the reactor**, meant to be implemented.
Examples:
- `PayClient`, an interface with `AlipayPayClient` and `WxPayClient`.
- `AbstractStreamListener` with several concrete listeners (`entry` + `ext`).
- A strategy interface with one implementation per channel.
Counter-examples:
- A service interface with a single `*Impl` → no `ext`.
- An interface implemented only by framework proxies or by code outside the
reactor → no `ext`.
## 6. Cases that come up often
| Case | Label |
|---|---|
| Service interface without annotation, whose single implementation is `@Service` | `service` (4.5); `api` if another module imports the interface; no `ext` |
| Feign client imported by another module | `client` + `api` |
| Class wrapping `RestTemplate`/`WebClient` to call a remote API | `client`; if it only builds the template bean → `config` |
| Data class in a `model` package that is not stored (no mapping, no repository saves it) | `none`; check mapper XML and repositories first (step 3 of 2) |
| BPMN delegate (`JavaDelegate`), execution/task listener | `entry` |
| Scheduled job (`@Scheduled`, Quartz, xxl-job) | `entry` |
| Event listener (`@EventListener`, `ApplicationListener`, broker listener) | `entry` |
| Event payload published to a broker | `event` |
| `@ControllerAdvice`, filters, interceptors | `none` |
| Enum, exception, constant class, utility | `none` |
| Generated `*Example`, `*Column` enum | `none` |
**When is it `none`?** When no role of section 3 describes what the type does
when the application runs — it carries data that is not stored, converts,
validates, helps, or is plumbing. `none` is a label, not a failure to decide:
mark it `unsure` only when a real role was close.
## 7. Confidence and rationale
- `sure`: the cited line settles it under the rules above.
- `unsure`: a rule of section 4 was needed and the evidence was thin, two
roles were close, or a file the decision needed could not be read.
- The rationale is one sentence, cites a line (`L<n>: …`) of the type's file or
names the other file read, and names the runner-up when there is one.
## 8. Changes
- **2.1** (2026-11-13), from the second-annotator pass over the 1145 dev types
(κ 0.936; lowest: client 0.80, service 0.88): business logic defined and
technical machinery made `none` (3.3); a `@Service` over a mapper stays
`service`; non-HTTP remote connections opened by the class are `client`
(3.2); a utility's name never beats what it does (step 1); a value object
kept by a stored aggregate is `domain` — look at who holds it (3.4).
- **2.0** (2026-11-13): marks labelled (section 5); confidence; rationale
cites a line; examples and counter-examples per role; decision order made
explicit. Role rules unchanged from 1.1.
- **1.1** (2026-11-10/11): domain-driven, entry points beyond Spring MVC, data
without annotations, infrastructure products (`ANNOTATION_GUIDELINES.md` §6).
- **1.0** (2026-11-08): roles only.
|