Commit Graph
319 Commits
Author SHA1 Message Date
pnoker d18bf4d03d style: fix table alignment and whitespace in README files 2026-06-26 13:17:38 +08:00
pnoker abd826bf6e docs(api): correct gRPC RPC names, import paths, and missing services
Align the four api READMEs with the actual protos: Select*->Get*/List*
per the CRUD verb convention, fix api/common->api/center import paths
for auth/data, drop the fabricated manager SelectByServiceName RPC, and
document the previously omitted auth/data/manager services.
2026-06-22 16:49:07 +08:00
pnoker b80909565e refactor(auth): remove legacy scanner-sourced x-dc3-ai path end-to-end 2026-06-19 01:07:13 +08:00
Vickey a94b2464a4 feat(mcp): authorize high-risk tool calls and harden auth lifecycle
Tool authorization (HIGH-risk confirmation):
- add AuthorizeToolCall RPC; the gateway calls it before tool execution
- sign/consume confirmation tickets with idempotency-key dedup
- propagate x-dc3-ai metadata (riskLevel/destructive/openWorld/idempotent) from the scan through the registry to the tool catalog

OAuth hardening:
- rotate refresh tokens and revoke the authorization on replay via previous_refresh_token_hash

Password lifecycle:
- require password change on login when flagged or expired (R20303/R20304)
- expose a public POST /token/change_password endpoint

OpenAPI aggregation:
- switch McpOpenApiAggregator to classpath static snapshots, dropping the runtime fetch and McpAggregatorProperties
2026-06-18 14:08:05 +08:00
pnoker 8ea0c0faf3 refactor(mcp): route runtime calls through facade 2026-06-12 22:38:30 +08:00
pnoker 7dacc47056 docs(auth): document principal and mcp architecture
Update auth, gateway, architecture, quickstart, changelog, and superpowers design documents for the Principal identity model and OAuth-backed MCP server.
2026-06-12 21:20:41 +08:00
pnoker 35dc46e95f feat(auth): introduce principal identity model
Replace legacy user-login and role-user binding runtime with Principal, LocalCredential, TenantMembership, ServiceAccount, and RolePrincipalBind.

Switch gateway/backend identity propagation to X-Auth-Principal and align agentic/controller security context types with PrincipalHeader.
2026-06-12 21:18:54 +08:00
pnoker fe766350b9 fix(auth): enforce cross-service permissions 2026-06-10 20:36:58 +08:00
Vickey b3ee76f893 refactor(data): unify command history status/type/source to enum index
Align CommandHistory/PointCommandHistory with the EventHistory pattern:
DB stores the enum index (SMALLINT via @EnumValue), gRPC carries int32,
JSON keeps enum name. Removes the lone string-code outlier in the schema.

- DO status/type/source: String code -> enum types
- VO type/source: String -> enum (status already enum); JSON stays name
- Builder: drop ofCode @AfterMapping (DO and VO now share enum type)
- RabbitMQ DTOs (CommandCall/PointCommandResult): status/source -> enum
- driver sendResult signatures: String status -> PointCommandStatusEnum
- gRPC command_history.proto status/source: string -> int32; server uses
  getIndex()/ofIndex() to match EventHistoryServer
- tests updated to assert enum values
2026-06-09 18:05:40 +08:00
pnoker 5730f7c137 feat: update pom version 2026-06-06 13:00:39 +08:00
pnoker b5ef7a8501 fix(pom): clean up dependency management and plugin configuration
- Replace obsolete nexus-staging-maven-plugin with central-publishing-
  maven-plugin in dc3-api and dc3-common
- Remove 20 redundant version declarations from dc3-coverage dependencies
- Fix snmp4j version from non-existent 3.8.3 to available 3.7.4
2026-06-06 00:40:18 +08:00
pnoker a7b19611a3 refactor: rename proto RPCs and facade methods to follow conventions
Proto RPC renames:
- command_history.proto: Call→CallCommand, List→ListByPage
- event_history.proto: Report→ReportEvent, List→ListByPage
- point_value.proto: LastValue→GetLastValue, HistoryValue→ListHistoryValues

Facade interface renames:
- StatusHealthFacade: selectDeviceStatusesByIds→listDeviceStatusesByIds,
  selectDeviceStatusesByProfileId→listDeviceStatusesByProfileId,
  selectDriverStatusesByIds→listDriverStatusesByIds

Update all gRPC server implementations, client stubs, and test files.
2026-06-06 00:03:20 +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
pnoker 3b378e854b refactor: align data history models and constants 2026-05-24 01:07:02 +08:00
pnoker 150ba33244 feat: add custom command call API, event report API with RabbitMQ and gRPC
- Add dc3_command_record and dc3_event_record DTOs, DOs, mappers, managers
- Implement CommandRecordService: call flow with validation, RabbitMQ dispatch,
  result/dead receivers, full lifecycle (PENDING→SENT→SUCCESS/FAILED/TIMEOUT/DEAD)
- Implement EventReportService: report flow with validation and persistence
- Add REST controllers: /command_record (call/get/list), /event_report (report/get/list)
- Add RabbitMQ exchanges/queues/bindings for command dispatch, result, dead letter
- Add event exchange for driver→center event reporting
- Add gRPC CommandRecordApi and EventReportApi with proto definitions and servers
- Fix PointCommandValidator parameter type (String→PointExt)
2026-05-23 18:26:28 +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 9007cbc22c style: apply consistent code formatting across all modules and docs 2026-05-22 00:24:22 +08:00
pnoker e38c7d432a feat(driver,manager): broadcast driver metadata events and let drivers refresh on demand
Extends the existing point/device metadata refresh flow to drivers:

- MetadataEvent gains an optional targetServices set so manager-side
  publishers can scope a metadata event to specific driver services
  instead of broadcasting to every listener.
- New DRIVER value on MetadataTypeEnum, plus a new GetById RPC on
  driver_driver.proto so drivers can re-fetch their registered metadata
  without going through the full registration handshake again.
- DriverClient.refreshMetadata(driverId) calls the new RPC and reapplies
  the returned device ids and attribute maps via a shared applyMetadata
  helper.
- MetadataReceiver now handles MetadataTypeEnum.DRIVER:
    DELETE  -> clear DriverMetadata, DeviceMetadata, and PointMetadata
              caches and flip status to OFFLINE
    ADD/UPDATE -> driverClient.refreshMetadata(id)
- Manager-side MetadataEventListener forwards events to RabbitMQ keyed by
  the target services in the event, falling back to broadcast when none
  are specified.
- DeviceServiceImpl, DriverAttributeServiceImpl, PointAttributeServiceImpl,
  and PointServiceImpl populate targetServices using the relevant driver
  service names so changes only wake the drivers that own the affected
  entity.
- DriverDriverServer.getById exposes the new RPC; new DriverDriverServerTest
  covers it.
- MetadataReceiverTest gains driverUpdate / driverDelete cases;
  MetadataEventListenerTest covers the per-service routing.
2026-05-21 15:02:09 +08:00
pnoker 5a3ab1440a test: improve backend test coverage governance 2026-05-19 18:19:12 +08:00
Vickey 476799e513 refactor(api): rename gRPC SelectBy* RPCs to GetBy*/ListBy*
Apply the new naming convention to .proto contracts so the verb on
each RPC reflects the cardinality of its result:

  - get*  for single-record returns (RPCs returning a single DTO)
  - list* for multi-record returns (RPCs returning a Page or List DTO)

23 RPCs renamed across 9 .proto files. Returns-single -> Get*:
  user.proto                 SelectById        -> GetById
  user_login.proto           SelectByName      -> GetByName
  tenant.proto               SelectByCode      -> GetByCode
  driver_device.proto        SelectById        -> GetById
  driver_point.proto         SelectById        -> GetById
  manager_point.proto        SelectById        -> GetById
  manager_device.proto       SelectByDeviceId  -> GetByDeviceId
  manager_driver.proto       SelectByDriverId  -> GetByDriverId
  manager_driver.proto       SelectByDeviceId  -> GetByDeviceId
  manager_profile.proto      SelectByProfileId -> GetByProfileId

Returns-multi -> List*:
  driver_device.proto        SelectByPage         -> ListByPage
  driver_point.proto         SelectByPage         -> ListByPage
  manager_device.proto       SelectByPage         -> ListByPage
  manager_device.proto       SelectByDriverId     -> ListByDriverId
  manager_device.proto       SelectByProfileId    -> ListByProfileId
  manager_device.proto       SelectByDeviceIds    -> ListByDeviceIds
  manager_driver.proto       SelectByPage         -> ListByPage
  manager_driver.proto       SelectByDriverIds    -> ListByDriverIds
  manager_point.proto        SelectByPage         -> ListByPage
  manager_point.proto        SelectByIds          -> ListByIds
  manager_profile.proto      SelectByPage         -> ListByPage
  manager_profile.proto      SelectByProfileIds   -> ListByProfileIds
  manager_profile.proto      SelectByDeviceId     -> ListByDeviceId

This is a wire-level breaking change: gRPC clients and servers must
upgrade in lockstep. Server impls, facade clients, and Java callers
are aligned in subsequent commits.
2026-05-18 19:19:40 +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 20bb57df17 refactor(agentic): split chat orchestration and structure tool results 2026-05-16 16:23:48 +08:00
pnoker ca0393ae7b feat(agentic): expand platform tool capabilities 2026-05-14 23:45:30 +08:00
pnoker df06264f9c fix(facade,manager): harden grpc calls and add bulk lookups 2026-05-09 18:49:51 +08:00
pnoker 0434d5b033 fix(facade): preserve unset enable flag in grpc queries 2026-05-09 18:49:51 +08:00
pnoker e47299a327 chore: remove format and format-check targets from Makefile 2026-05-07 23:55:32 +08:00
pnoker eefe411bd7 chore(build): upgrade spring-javaformat to 0.0.47 and add Checkstyle integration
- Add maven-checkstyle-plugin with spring-javaformat-checkstyle rules
- Add custom checkstyle.xml excluding overly strict rules for existing codebase
- Exclude third-party driver code (serotonin, openscada, nodave) from checks
- Configure plugins in dc3-common and dc3-api POMs for full module coverage
- Add .springjavaformatconfig placeholder
2026-05-07 16:46:17 +08:00
pnoker 6992c20e5e feat(api): expand point_value.proto with HistoryValue, ReadCommand, and WriteCommand RPCs
Add three new RPC methods to PointValueApi: HistoryValue for querying
historical point values, ReadCommand and WriteCommand for device control.
Define corresponding request/response message types.
2026-05-07 00:09:08 +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 706917dd2e feat(auth): add api_group to cluster endpoints by owning controller
Thread a new api_group field end-to-end through the scanner, gRPC/local
facade, proto, auth entity layer, and registry sync service. Populated
from handler.getBeanType().getSimpleName() (e.g. ApiController), this is
the foundation for the forthcoming resource-tree hierarchy grouping
sibling endpoints under their controller.
2026-05-01 17:30:02 +08:00
pnoker ddac60f4f7 refactor(auth): drop tenant from registry resources 2026-05-01 16:33:17 +08:00
Vickey fb9ee53781 feat: auto-register center API endpoints to auth resource tables
Adds a startup-time registrar that scans the local WebFlux handler mappings
of each center service and reconciles the discovered endpoints against
dc3_api and dc3_resource (insert-if-missing, update-if-drifted, soft-delete-
if-orphaned), so the permission model is no longer hand-maintained.

Wiring:
- dc3-common-resource-registrar (new module): scanner, diff runner, Spring
  Boot AutoConfiguration. Activates on ApplicationReadyEvent.
- dc3-common-facade-api: ResourceRegistryFacade + BOs define a transport-
  neutral sync contract.
- dc3-common-facade-local / dc3-common-facade-grpc: two implementations
  selected via dc3.facade.mode. center-auth/single use local; manager/data
  call auth via gRPC.
- dc3-common-auth: biz-side ResourceRegistrySyncService performs the three-
  way diff inside a transaction guarded by pg_advisory_xact_lock(hashtext
  (serviceName)); exposes ResourceRegistryApi gRPC server.
- dc3-api-auth: new resource_registry.proto contract.
- ApiDO/BO/VO/Query gain a serviceName field so each service's endpoints
  can be located with a single indexed lookup.

Deployment-visible changes:
- api_code format is the human-readable serviceName:METHOD:/path
- dc3_resource.resource_code format is api:serviceName:METHOD:/path
  (prefixed namespace reserved for future resource types)
- center-auth application.yml sets dc3.facade.mode=local
- 4 center pom.xml files pull in the registrar (auth also gets facade-local)
2026-04-30 21:40:45 +08:00
Vickey 200beeaa71 chore: update version to 2026.4.30 in multiple files 2026-04-30 16:06:30 +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 a1514061b4 fix: revert proto package to api.common.* to fix build breakage
Proto3 type resolution walks up the package hierarchy. After changing
package api.common.auth/data/manager to api.center.*, unqualified
references like GrpcR/GrpcBase (defined in api.common) can no longer
be resolved, causing PROTOC compile errors.

Revert package declarations to api.common.auth/data/manager while
keeping java_package as io.github.pnoker.api.center.* — java_package
is independent from proto package and controls Java output only.
2026-04-18 02:05:36 +08:00
pnoker 0833a88115 fix: complete dc3-api proto optimization
1. manager_point.proto: add missing SelectById RPC and GrpcRPointDTO
   response message to match driver_point.proto symmetry

2. Rename java_outer_classname to include module prefix to avoid
   confusion between driver and manager modules:
   - driver: DeviceProto→DriverDeviceProto, DriverProto→DriverRegistrationProto,
     EntityProto→DriverEntityProto, PointProto→DriverPointProto,
     QueryProto→DriverQueryProto, QueryPageProto→DriverQueryPageProto
   - manager: DeviceProto→ManagerDeviceProto, DriverProto→ManagerDriverProto,
     PointProto→ManagerPointProto, QueryProto→ManagerQueryProto,
     QueryPageProto→ManagerQueryPageProto

3. Reorganize proto files into subdirectories matching proto package:
   - auth:    src/main/protobuf/api/center/auth/
   - data:    src/main/protobuf/api/center/data/
   - driver:  src/main/protobuf/api/common/driver/
   - manager: src/main/protobuf/api/center/manager/
   Update all intra-module imports to use full absolute paths
2026-04-18 01:51:07 +08:00
pnoker 4ebde7cec0 fix: optimize dc3-api pom element order and proto files
- dc3-api/pom.xml: move <profiles> to after <build> per Maven POM
  standard element ordering; move <dependencyManagement> before
  <dependencies>
- driver_device.proto: rename driverConfigs/pointConfigs to
  driver_configs/point_configs (proto3 snake_case convention)
- auth/data/manager protos: align package declaration from
  api.common.xxx to api.center.xxx to match java_package option
- driver_entity.proto, driver_query.proto, driver_query_page.proto,
  manager_query_page.proto: remove trailing blank lines
2026-04-18 01:41:47 +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 e38b5e6b64 refactor: optimize root, dc3-common and dc3-api pom.xml
- Consolidate 19+ individual DC3 module version properties into single <dc3.version>
- Remove redundant <scope>compile</scope> from DC3 Api dependencyManagement entries
- Reorder elements: modules before properties, profiles after dependencyManagement
- Fix <scm> connection/developerConnection to use scm:git: protocol prefix
- Fix <inceptionYear> from range '2016-2022' to correct single year '2016'
2026-04-18 01:15:20 +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
Vickey 78a612c4ac feat: add JavaDoc comments and enhance field naming consistency across project 2026-01-07 17:07:46 +08:00
Vickey 025a7b348f chore: update copyright headers and minor proto field comments across modules 2026-01-07 15:19:43 +08:00
Vickey 8a22940eb9 Merge remote-tracking branch 'origin/develop' into develop
# Conflicts:
#	dc3-common/dc3-common-constant/src/main/java/io/github/pnoker/common/constant/common/PrefixConstant.java
#	dc3-common/dc3-common-constant/src/main/java/io/github/pnoker/common/constant/common/QueryWrapperConstant.java
#	dc3-common/dc3-common-constant/src/main/java/io/github/pnoker/common/constant/common/RequestConstant.java
#	dc3-common/dc3-common-constant/src/main/java/io/github/pnoker/common/constant/common/SuffixConstant.java
#	dc3-common/dc3-common-constant/src/main/java/io/github/pnoker/common/constant/common/SymbolConstant.java
#	dc3-common/dc3-common-constant/src/main/java/io/github/pnoker/common/constant/common/TimeConstant.java
#	dc3-common/dc3-common-constant/src/main/java/io/github/pnoker/common/enums/DeviceEventTypeEnum.java
#	dc3-common/dc3-common-constant/src/main/java/io/github/pnoker/common/enums/DeviceStatusEnum.java
#	dc3-common/dc3-common-constant/src/main/java/io/github/pnoker/common/enums/EnableFlagEnum.java
2026-01-07 15:19:02 +08:00
zzi666 578739f338 refactor(proto): simplify proto comments, remove redundant README files, and unify format 2025-12-31 14:15:29 +08:00
zzi666 7c6b9e3ea3 Merge branch 'develop' of github.com:pnoker/iot-dc3 into develop 2025-12-31 10:07:38 +08:00
Vickey 557152226c docs(api): add README files for auth, data, and driver API modules 2025-12-28 19:23:20 +08:00