Updated latest changes#74
Conversation
Reviewer's GuideRefactors and partially de-obfuscates the core licensing/runtime code while adding support for GLOBAL_API_KEY activation, improves license-related HTTP routing and static asset gating, wires versioning through build and runtime (including Docker and GitHub Actions), tweaks WhatsApp link preview behavior, and adds project governance files like issue templates and trademark/notice docs. Sequence diagram for runtime license activation with GLOBAL_API_KEYsequenceDiagram
participant app as InitializeRuntime
participant db as RuntimeConfigDB
participant licSrv as LicensingServer
app->>db: _8ftv()
db-->>app: RuntimeData or error
alt saved license found
app->>licSrv: _2a2d(rc, version)
licSrv-->>app: HTTP 200 active
app->>db: _nk7y(RuntimeData)
else no saved license and GLOBAL_API_KEY set
app->>licSrv: _2a2d(rc, version)
licSrv-->>app: success or error
alt activation success
app->>db: _nk7y(RuntimeData)
else activation failed
app->>app: _p3()
end
else no license and no GLOBAL_API_KEY
app->>app: _p3()
end
Flow diagram for version propagation through build and licensingflowchart LR
VERSION_FILE["VERSION file"]
GH_ACTIONS["GitHub Actions: Read version step"]
DOCKER_META["Docker meta tags (VERSION, latest)"]
DOCKER_BUILD["docker/build-push-action with build-arg VERSION"]
GO_MAIN["cmd/evolution-go main.version (ldflags or VERSION)"]
LIC_HTTP["_2a2d / _b1h send version to licensing server"]
VERSION_FILE --> GH_ACTIONS
GH_ACTIONS --> DOCKER_META
DOCKER_META --> DOCKER_BUILD
DOCKER_BUILD --> GO_MAIN
GO_MAIN --> LIC_HTTP
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- In the licensing HTTP helpers and routes (e.g.,
/v1/register/init,/v1/register/exchange,/v1/activate),json.NewDecoder(...).Decode(...)errors are ignored; consider checking and handling these errors explicitly before using the decoded structs to avoid panics or misleading responses when the licensing server returns malformed JSON. - The static asset allowlist in
GateMiddlewarenow includes a long set of hard-coded extensions; consider centralizing this list or using a helper (e.g.,isStaticAsset(path)) so future asset types can be added in one place and the gate logic remains easier to read and maintain.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the licensing HTTP helpers and routes (e.g., `/v1/register/init`, `/v1/register/exchange`, `/v1/activate`), `json.NewDecoder(...).Decode(...)` errors are ignored; consider checking and handling these errors explicitly before using the decoded structs to avoid panics or misleading responses when the licensing server returns malformed JSON.
- The static asset allowlist in `GateMiddleware` now includes a long set of hard-coded extensions; consider centralizing this list or using a helper (e.g., `isStaticAsset(path)`) so future asset types can be added in one place and the gate logic remains easier to read and maintain.
## Individual Comments
### Comment 1
<location path="cmd/evolution-go/main.go" line_range="71-74" />
<code_context>
var devMode = flag.Bool("dev", false, "Enable development mode")
-var version = "dev"
+var version = "0.0.0"
func init() {
- if version == "dev" {
+ // ldflags -X main.version= sets this at compile time.
+ // If not set (or still default), try reading from VERSION file.
+ if version == "0.0.0" {
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Reading VERSION via relative path can break when working directory differs from binary location
This logic relies on `VERSION` being in the current working directory, which only holds in your container setup. In other contexts (different CWD, systemd units, tests) it will silently stay at `0.0.0`. To make this robust, either embed the VERSION value at build time, or resolve the file relative to the binary path (e.g. via `os.Executable()` + `filepath.Dir`).
Suggested implementation:
```golang
func init() {
// ldflags -X main.version= sets this at compile time.
// If not set (or still default), try reading from VERSION file located
// alongside the executable (rather than the current working directory).
if version == "0.0.0" {
if exePath, err := os.Executable(); err == nil {
versionPath := filepath.Join(filepath.Dir(exePath), "VERSION")
if v, err := os.ReadFile(versionPath); err == nil {
if trimmed := strings.TrimSpace(string(v)); trimmed != "" {
version = trimmed
}
}
}
}
}
```
Ensure that `path/filepath` is imported in `cmd/evolution-go/main.go`, for example by adding:
```go
import (
// existing imports...
"path/filepath"
)
```
if it is not already present.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| var version = "0.0.0" | ||
|
|
||
| func init() { | ||
| if version == "dev" { | ||
| // ldflags -X main.version= sets this at compile time. |
There was a problem hiding this comment.
suggestion (bug_risk): Reading VERSION via relative path can break when working directory differs from binary location
This logic relies on VERSION being in the current working directory, which only holds in your container setup. In other contexts (different CWD, systemd units, tests) it will silently stay at 0.0.0. To make this robust, either embed the VERSION value at build time, or resolve the file relative to the binary path (e.g. via os.Executable() + filepath.Dir).
Suggested implementation:
func init() {
// ldflags -X main.version= sets this at compile time.
// If not set (or still default), try reading from VERSION file located
// alongside the executable (rather than the current working directory).
if version == "0.0.0" {
if exePath, err := os.Executable(); err == nil {
versionPath := filepath.Join(filepath.Dir(exePath), "VERSION")
if v, err := os.ReadFile(versionPath); err == nil {
if trimmed := strings.TrimSpace(string(v)); trimmed != "" {
version = trimmed
}
}
}
}
}Ensure that path/filepath is imported in cmd/evolution-go/main.go, for example by adding:
import (
// existing imports...
"path/filepath"
)if it is not already present.
Description
Related Issue
Closes #(issue_number)
Type of Change
Testing
Screenshots (if applicable)
Checklist
Additional Notes
Summary by Sourcery
Improve licensing/runtime context handling, add proper versioning and release metadata, and enhance GitHub workflows and templates for project maintenance.
New Features:
Bug Fixes:
Enhancements:
Build:
CI:
Documentation:
Chores: