72 Commits
Author SHA1 Message Date
pnoker 66aab58f20 build: standardize repository tooling and quality gates 2026-09-02 20:51:10 +08:00
pnoker eae86b58fc refactor(storage)!: unify platform persistence on reactive postgresql
- migrate auth, manager, data, and agentic persistence to R2DBC
- hard cut pagination, facade, gateway, web, and CLI contracts
- remove legacy database and TSDB adapters and document validation gates

BREAKING CHANGE: platform persistence now requires PostgreSQL 18 with TimescaleDB and the new reactive API contracts.
2026-09-01 22:03:16 +08:00
pnoker 1fa2d6f0cf docs(comments): fill the real comment gaps across the repository
A comment-health audit driven by an AST scanner (regex scanners kept
false-positiving on annotation-separated javadoc; the AST pass with
constructor and @Override-implementation exemptions is what produced a
trustworthy worklist) ended with a much smaller true gap than the raw
numbers suggested: class-level javadoc is already at 100% repository-wide.

What actually gets filled here:

- AnalyticsModel: all 30 nested records of the S19 analytics facet get
  maintainer-voice javadoc (the @Schema descriptions serve the API side;
  these serve code readers).
- The whole entity/ext family (29 files, 47 nested classes): every
  Content/Ui/Validation/Security/AppliesTo/Template/Dedup/... schema
  class states what it actually holds — read from the fields, not
  templated.
- Adapter families: the @Bean methods of all six MQ adapters, all four
  TSDB adapters and the three DB dialect adapters get one-line
  maintainer docs (what binds to what, what is overridable).
- Nested support types across data/agentic/constant/public/facade:
  NotifyBindKey, CacheTuning, Credential, dashboard VOs' Item/BucketVO,
  ExpireListener (plus its null-doc placeholder javadoc replaced with a
  real contract), agentic chat/stream VOs' choice/delta/usage shapes,
  tool-context records, RequestHeader envelopes, FleetSummary,
  visualization Type/Scale codes.
- PointValueSampleConverter's boundary methods now state the port-side
  contract (quality default injection point, batch order preservation).

Comment drift fixed: the class javadoc of the can/mqtt/opc-da driver
skeletons claimed "see TODO markers in method bodies" — those markers
do not exist; the claims are corrected to plain work-in-progress notes.
The genuine TODOs (zigbee API verification, lwm2m lookup, ethernet-ip
CIP framing, CAN JNI) stay: they mark real unimplemented behavior.

Vendored-code boundary: the opc-da module carries a ported
org.openscada library (46 files, package org.openscada.*). Its trivial
accessors stay bare on purpose — filler comments on get/set pairs are
exactly the kind of noise this pass exists to remove — but the
non-obvious JIStruct wire-decoder methods (getStruct/fromStruct
FILETIME + three DO wrappers) now document the COM bridge shape.

Gates: full-repo compile green; data/model/constant/agentic/public
test suites green.
2026-08-24 21:23:39 +08:00
pnoker 51f0efd2d9 style(javadoc): document non-override public methods 2026-08-19 00:05:58 +08:00
hongyuan.zhang 6b37cb5ccd docs(readme): refresh module documentation 2026-08-11 22:58:30 +08:00
pnoker 50c6de9438 docs: rewrap project guides and README files
Prose rewrapping and table reflow from a project-wide markdown pass;
no content changes. Also reverts two formatter mistakes: restores
MD5(password) in dc3-web/AGENTS.md and drops spurious spaces after
CJK punctuation in README.zh.md / README.ja.md.

Covers root guides (AGENTS/CONTRIBUTING/SECURITY/README.*), module
READMEs across dc3-api/center/common/driver/e2e/gateway, the nginx
guide, dc3/doc/{README,TITLE}.md, and dc3-web docs.
2026-08-09 18:44:55 +08:00
Henry ZhangandClaude Fable 5 7c643a8e80 fix(api): dc3-api contract overhaul (auth JWT, history, presence, decision enum) (#193)
* fix(api): correct inverted enable_flag comment and document time unit

- tenant.proto enable_flag comment said "1 enabled, 0 disabled" but the
  actual EnableFlagEnum is ENABLE=0, DISABLE=1 — callers reading the
  comment would invert the flag. Correct it.
- base.proto create_time/operate_time are epoch milliseconds
  (LocalDateTimeUtil/Instant.toEpochMilli); document the unit so callers
  don't guess seconds vs millis.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(api): carry timestamp in point-value history; explicit bool presence

#5 Point-value history: the whole chain (proto -> gRPC server ->
PointValueService -> repository -> facades -> controller -> agentic tool)
returned List<String> and dropped create_time even though the DB row
already carried it. Switch to PointValueBO / FacadePointValueBO end to
end so callers receive each value with its timestamp.

#6 Field presence: GrpcR.ok and McpIntrospectDTO.active are now optional
bool, so "unset" is distinguishable from false on the wire.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(auth): unify JWT signing key, drop salt/password from token contract

The JWT signing key was per-principal — securityKey + ":" + salt, where
salt was the credential salt also carried through the gateway and the
token RPC. That makes the JWT key weak and widens salt exposure to every
gateway hop. Sign with the single configured securityKey (HS256) instead
and remove salt from the JWT path entirely:

- KeyUtil.generateToken/parserToken drop the salt parameter; the HMAC
  key is now just securityKey (must be >= 32 bytes for HS256).
- TokenService.generateToken/checkValid drop the salt parameter.
- token.proto GrpcLoginQuery drops salt and password — CheckValid only
  ever needed tenant, name and token.
- gateway FilterService, TokenGrpcFacade, TokenController adapted; the
  request header no longer feeds salt into validation.

The login-handshake salt (POST /token/salt, used to salt the password
client-side before verifyPassword) is unchanged — only the JWT signing
salt is removed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor(api): type MCP authorize decision as proto enum

The authorize-tool-call decision was a free-form string, so callers
could only compare it against literals with no compile-time check.
Introduce GrpcMcpDecision (MCP_DECISION_UNSPECIFIED / AUTHORIZED /
CONFIRM_REQUIRED / REJECTED) and type GrpcMcpToolAuthorizeDTO.decision
with it. Enum names match the existing auth-side literals, so the
mapping is a direct valueOf / name().

- McpRuntimeServer builds the enum via toGrpcDecision (unknown -> UNSPECIFIED).
- McpRuntimeGrpcFacade maps enum -> BO string via name().
- gateway unchanged: it receives the BO (string decision) through the facade.

The other string MCP fields (risk_level, status, grant_type,
principal_type) stay strings for now — their value sets are wider and
partly lowercase (OAuth grant_type), so they are a follow-up.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* fix(facade): align TokenLocalFacade with 3-arg checkValid (CI compile fix)

TokenLocalFacade (local impl) was missed when TokenFacade.checkValid
dropped salt; CI compiles facade-local-auth independently and caught
it. Align it + its test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-08-06 16:36:35 +08:00
pnokerandClaude Fable 5 24cfe977f4 fix(api): set size (not pages) when defaulting a null GrpcPage
buildPagesByGrpcPage built its fallback GrpcPage with setPages(PAGE_SIZE),
writing the per-page size into the total-pages field, while the code
below reads getSize(). The <1 guard masked any functional impact, but it
was a misleading no-op. Set the correct field: setSize(PAGE_SIZE).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-14 14:45:09 +08:00
pnokerandClaude 77a20466bc refactor(api): reorganize proto files from center to common package
- Move proto files from api/center/ to api/common/ for auth, data, manager modules
- Update java_package and java_outer_classname in moved proto files
- Add GrpcDriverQuery message to shared query.proto in dc3-common-api
- Move GrpcDriverQuery proto from common.driver to common package
- Update Java imports referencing relocated proto messages
- Remove redundant pom.xml metadata (developers, licenses, scm, version)
  from api submodules — inherited from parent

Co-Authored-By: Claude <noreply@anthropic.com>
2026-07-09 12:43:48 +08:00
Vickey d2c897846c refactor(common): split ResponseEnum into SuccessCode/ErrorCode and align body code with HTTP status
Replace the mixed-purpose ResponseEnum with a ResponseCode interface implemented
by SuccessCode (OK/ADD/DELETE/UPDATE) and ErrorCode (NOT_FOUND/UNAUTHORIZED/
TOKEN_INVALID/IP_INVALID/FORBIDDEN/PASSWORD_*/VALIDATION/OUT_OF_RANGE/FAILURE),
each carrying its HTTP status so the envelope body code and transport status no
longer diverge.

- Introduce abstract BusinessException carrying an ErrorCode; all 23 business
  exceptions extend it and bind a fixed code. ExceptionConfig reads the carried
  code to set both body code and HTTP status (404->R404, 401->R401, 422->R422).
- Add GrpcRFactory (ok/fail/notFound) and remove the hand-written GrpcR builder
  boilerplate across 19 gRPC servers.
- Drop the dead @EnumValue index and ofIndex/ofCode/ofName lookups; OUT_OF_RANGE
  is now carried by OutRangeException.
- Update R factory methods to accept ResponseCode; migrate 90+ controllers,
  11 gRPC facades, OpenAPI specs and README to the split enums.

Also fix several pre-existing red tests surfaced by the full suite:
- OAuthMcpRuntimeServiceImplTest: setUp set @Value fields refactored into
  OAuthProperties; inject the properties object instead.
- DriverReadServiceImplTest: reset leaked ConnectionBackoff static state via a
  new clear() in @BeforeEach.
- modbus-rtu/tcp: make the static modbusFactory non-final so tests can swap it.
- ble: override no-arg health() to report OFFLINE before initialization.
- PlcS7/facade-local tests: expect the thrown exception / use the single-arg
  overload matching production behaviour.
- Remove a duplicate dc3-common-constant dependency in dc3-common-data/pom.xml.
2026-06-18 23:53:41 +08:00
Vickey 918b3d5e8e feat: update pom version to 2026.5.22 2026-05-26 00:30:11 +08:00
Vickey dedb03fe74 feat: add command/event attribute configuration system
Introduce CommandAttribute/EventAttribute with config variants:
- REST controllers, MyBatis mappers, services, and DAL managers
- gRPC client/server builders and proto message definitions
- DTOs, BOs, DOs, VOs for type-safe data transfer layer

fix: add explicit ::text casts in json_build_object parameters

PostgreSQL cannot infer parameter types inside json_build_object()
calls. Add ::text casts to #{stateExtType} and #{stateDescription}
to resolve "could not determine data type of parameter $10" errors.

refactor: restructure driver gRPC client and metadata layer

- Rename GrpcStubConfig to DriverClientStubConfig with dedicated DTOs
- Extract attribute builders from inline gRPC conversion logic
- Consolidate driver metadata, register service, and command handling
- Update device state heartbeat and command result event handling

docs: add multilingual architecture diagram and sync READMEs

- Translate architecture SVG into zh, ja, vi variants
- Update README architecture image references per language
- Add missing service-level shortcut sections to ja/vi READMEs
2026-05-25 00:00:00 +08:00
Vickey aa5c4ddf8e feat: add Command and Event model with full CRUD stack and facade layer
Phase 2 — Command & Event 模型定义闭环:
- 5 new enums: CommandTypeFlag, CallTypeFlag, ParamDirectionFlag, EventTypeFlag, EventLevelFlag
- 4 Ext types: CommandExt, CommandParamExt, EventExt, EventParamExt
- 4 entity stacks (DO/BO/VO/Query/Builder): Command, CommandParam, Event, EventParam
- Mapper/XML with device JOIN support, Manager, Service with tenant validation
- 4 REST controllers, 2 gRPC servers, proto definitions (entity, query, page, service)

Phase 3 — Facade + Agentic 工具:
- Facade API: CommandFacade, EventFacade with tenant-scoped defaults
- gRPC Facade: CommandGrpcFacade, EventGrpcFacade with hand-rolled builders
- Local Facade: CommandLocalFacade, EventLocalFacade with MapStruct mappers
- GrpcStubConfig: register CommandApi and EventApi blocking stubs
- Agentic tools: CommandTool and EventTool (5 @Tool methods each)
2026-05-23 18:05:15 +08:00
pnoker 60cebd179e docs(gateway,api,quartz,repository): improve class-level Javadoc 2026-05-21 01:25:51 +08:00
pnoker 7f5da1a0f8 chore: bump version to 2026.5.18 across all modules 2026-05-18 00:24:22 +08:00
pnoker 994ccba991 docs: update READMEs and project documentation
Refresh module READMEs, AGENTS.md, CONTRIBUTING.md, and dc3/doc/
guides to reflect the unified Dockerfile, consolidated compose stacks,
and updated build instructions.
2026-05-17 19:03:21 +08:00
pnoker 996518186a build: bump version to 2026.5.17
Update parent version and dc3.version from 2026.5.5 to 2026.5.17
across all Maven modules.
2026-05-17 19:01:44 +08:00
pnoker 7c853ac8bc chore: correct @since tag to project inception date
Update @since from 2022.1.0 to 2016.10.1 and @version from 2026.5.5
to 2026.5.17 across all Java source files to reflect the actual
project start date.
2026-05-17 19:01:28 +08:00
pnoker ca0393ae7b feat(agentic): expand platform tool capabilities 2026-05-14 23:45:30 +08:00
pnoker 1bc0b74d4d style: reorganize POM dependencies with consistent category comments
Group dependencies in each module POM using a standard category order:
Spring Boot → Spring Cloud → gRPC → Data Access → Messaging → IoT → AI
→ Serialization → Utility → Security → Observability → DC3 API → DC3 Common

DC3 Common dependencies sorted alphabetically within their group.
2026-05-08 00:28:44 +08:00
pnoker e47299a327 chore: remove format and format-check targets from Makefile 2026-05-07 23:55:32 +08:00
pnoker db456d61fe style: apply spring-javaformat 0.0.47 and fix checkstyle violations
- Apply Spring Java Format to all 1087 Java source files
- Fix star imports (java.lang.annotation, org.quartz, java.util.concurrent, etc.)
- Fix missing trailing newlines across codebase
- Fix redundant public modifiers on interface methods
- Fix multiple variable declarations
- Fix if-statements missing braces in JsonUtil, RegexUtil, RequestUtil
2026-05-07 16:53:16 +08:00
pnoker 95c40b2387 chore: bump version to 2026.5.5
Roll every pom, per-module README, Spring banner, and @version /
@since javadoc tag from 2026.4.30 to the new 2026.5.5 release line.
2026-05-05 00:56:09 +08:00
Vickey 200beeaa71 chore: update version to 2026.4.30 in multiple files 2026-04-30 16:06:30 +08:00
pnoker d0728dabf4 refactor: remove Netty dependency and unused transport classes from dc3-common-api
Netty is transitively available via grpc-netty (spring-grpc-spring-boot-starter).
The transport classes under center/transport/ are no longer used.
2026-04-30 01:35:25 +08:00
pnoker f2e531bf56 style: remove dangling Javadoc and clean up driver service comments
Remove dangling Javadoc comments between annotations and fields across
all driver modules. Strip redundant inline block comments from method
bodies that duplicate method-level Javadoc. Improve class-level Javadoc
and simplify verbose private method documentation. Convert traditional
switch to enhanced switch expression in Modbus TCP driver.
2026-04-30 01:29:31 +08:00
pnoker c5a9feeeb9 feat: add .env file for Docker Compose configuration and update usage instructions 2026-04-29 10:27:57 +08:00
pnoker ea17c86387 chore: update version to 2026.4.19 across all modules and adjust branch settings in codeql.yml 2026-04-19 13:45:21 +08:00
pnoker d102e18b00 chore: fix inceptionYear and scm connection in all pom.xml
- Fix <inceptionYear> from '2016-2022' to '2016' in 20 pom.xml files
- Fix <scm> connection/developerConnection to use scm:git: prefix in 22 pom.xml files
2026-04-18 01:31:07 +08:00
pnoker e57793ec5f chore: bump version to 2026.4.18.3 and optimize pom.xml dependencies
- Bump all module versions from 2025.11.1 to 2026.4.18.3
- Remove orphaned dc3-common-influx dependency and property from root pom.xml
- Standardize dependency comment style in dc3-common/pom.xml
- Merge gRPC dependency groups into single section in dc3-common-api
- Restructure Spring Integration MQTT and Eclipse Paho groups in dc3-common-mqtt
- Fix incorrect comment 'DC3 Common Exception' to 'DC3 Common Related' in dc3-common-postgres
- Add missing blank line before </dependencies> in dc3-common-driver
- Remove stray blank line in root pom.xml dependencyManagement
2026-04-18 01:05:30 +08:00
zzi666 7c6b9e3ea3 Merge branch 'develop' of github.com:pnoker/iot-dc3 into develop 2025-12-31 10:07:38 +08:00
Vickey 0e419bab05 feat: update pom 2025-11-11 13:22:24 +08:00
zzi666 eafe3e14a4 refactor: standardize and translate comments across Protobuf files and environment script for clarity and consistency 2025-11-06 16:37:35 +08:00
zzi666 5589c24448 refactor: standardize and translate comments in Protobuf files for improved clarity and consistency across modules 2025-11-06 16:37:18 +08:00
zzi666 ff3fc9e521 refactor: standardize and translate comments across Protobuf files, Java services, and configuration classes for consistency and clarity 2025-10-27 19:43:19 +08:00
zzi666 73fe41091e refactor: standardize descriptions, comments, and documentation across POM files and Protobuf definitions 2025-10-24 20:07:28 +08:00
zzi666 518d2a8b7d refactor: update Java docs, README files, and Protobuf comments for consistent language and formatting 2025-10-24 16:51:40 +08:00
zzi666 989a931c2f fix: standardize comment language in POM files 2025-10-24 15:45:02 +08:00
Vickey a9e8d05631 feat: update version 2025-10-05 17:16:37 +08:00
Vickey 7302107c56 chore: bump all module versions to 2025.9.2 2025-09-11 17:02:24 +08:00
Vickey 2051d42847 refactor(common): remove hutool dependency and replace usages with native utilities 2025-09-11 14:57:02 +08:00
Vickey 8cc7365293 build: bump all module versions to 2025.6.6 and update compose image tags 2025-08-26 22:38:53 +08:00
Vickey 022bab4fbd chore: switch license declaration from Apache-2.0 to AGPL-3.0 across all poms 2025-08-26 22:16:35 +08:00
Vickey a39d2fb533 chore: migrate license headers from Apache 2.0 to AGPL-3.0 across all source files 2025-08-26 22:01:24 +08:00
Vickey f415207088 build: bump project version to 2025.6.5 across all modules 2025-07-15 14:58:51 +08:00
Vickey 31a6a275ed build: bump project version to 2025.6.4 across all modules 2025-07-15 12:01:43 +08:00
Vickey 886b212793 build: bump project version to 2025.6.1 across all modules 2025-06-21 16:21:18 +08:00
Vickey 877be41317 build: bump project version to 2025.6.0 and remove unused job/register dependencies 2025-06-09 15:48:22 +08:00
Vickey e86d3629bd revert(common): revert timestamp type change in DO models and gRPC builder 2025-05-08 21:35:04 +08:00
Vickey 2e5f3f9002 refactor(model): migrate timestamp fields to LocalDateTime across all DO classes 2025-05-07 22:06:23 +08:00