Skip to content

feat: add Codex Hubble development environment#746

Open
imbajin wants to merge 2 commits into
apache:masterfrom
hugegraph:cdx/add-codex-hubble-environment
Open

feat: add Codex Hubble development environment#746
imbajin wants to merge 2 commits into
apache:masterfrom
hugegraph:cdx/add-codex-hubble-environment

Conversation

@imbajin

@imbajin imbajin commented Jul 21, 2026

Copy link
Copy Markdown
Member

Summary

Add a repository-managed Codex environment for local Hubble development.

Before After
Developers manually coordinate Hubble processes and local HStore setup across worktrees. Codex actions provide deterministic frontend ports, shared backend ownership, optional HStore profiles, and fast/full verification.
Hubble local-development documentation has no Codex entry point. The Hubble README links to the optional Codex worktree workflow.

Scope

  • Adds only repository-scoped environment scripts and Compose overlays.
  • Keeps runtime ownership files under ~/.codex/run/; no secrets or runtime artifacts are tracked.
  • Low-memory HStore starts with local latest images and does not pull automatically.

Verification

  • bash .codex/tests/environment_test.sh
  • docker compose ... config --quiet for low-memory and balanced profiles
  • git diff --check

@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. enhancement New feature or request hubble hugegraph-hubble labels Jul 21, 2026
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 32.87%. Comparing base (b066b80) to head (5214f5b).
⚠️ Report is 196 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (b066b80) and HEAD (5214f5b). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (b066b80) HEAD (5214f5b)
2 1
Additional details and impacted files
@@              Coverage Diff              @@
##             master     #746       +/-   ##
=============================================
- Coverage     62.49%   32.87%   -29.63%     
+ Complexity     1903     1562      -341     
=============================================
  Files           262      264        +2     
  Lines          9541    14310     +4769     
  Branches        886     1743      +857     
=============================================
- Hits           5963     4704     -1259     
- Misses         3190     9074     +5884     
- Partials        388      532      +144     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dosubot dosubot Bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:XL This PR changes 500-999 lines, ignoring generated files. labels Jul 21, 2026

@imbajin imbajin left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: yes. Summary: The new environment has clean-worktree startup, lifecycle ownership, image refresh, storage persistence, and local exposure issues that should be fixed before merge. Evidence: six independent review lanes; bash syntax, ShellCheck, environment tests, Compose expansion/dry-run, and Docker image metadata.

Comment thread .codex/scripts/hubble.sh
classpath="${RUNTIME_DIR}/hubble-be.classpath"
echo "[hubble] compiling BE with Java 11 + ${runner}"
(
cd "${WORKTREE}/hugegraph-hubble"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

‼️ A clean Codex worktree cannot start this BE action. This build only includes hubble-be, while that module depends on the current hugegraph-loader/client artifacts and loader_home() later requires an ignored hugegraph-loader/apache-hugegraph-loader-* distribution. setup.sh only installs frontend dependencies, so a fresh clone has neither prerequisite (the existing Hubble CI explicitly installs client+loader first). Please build/install the required reactor modules and produce/select the current Loader distribution deterministically, or provision a declared artifact, and cover be-start from a clean checkout.

Comment thread .codex/scripts/hubble.sh
echo "Use the 'Hubble BE Switch' action to replace it." >&2
return 1
fi
rm -f "${owner}"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

‼️ The switch path drops ownership before the service has actually stopped. kill_tree() only sends TERM; this loop waits for the wrapper shell PID, not the Java listener/descendants, so a slow graceful shutdown leaves an unowned listener and the subsequent port check rejects the switch. stop_current() has the same ownership-loss pattern without any wait. Please retain the owner until the captured process tree and port have exited (with a bounded timeout and non-zero failure), and add a delayed-TERM lifecycle test.

Comment thread .codex/scripts/infra.sh
compose_files low "${server_repo}"
echo "[infra] explicitly updating latest images"
TOOLCHAIN_CODEX_DIR="${CODEX_DIR}" HUGEGRAPH_VERSION=latest \
docker compose "${COMPOSE_ARGS[@]}" pull

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Infrastructure Pull currently skips every image because the low-memory overlay sets pull_policy: never. On this head, docker compose ... --dry-run pull reports Skipped for server/store/PD, while adding --policy always reports the expected pulls. Please explicitly override the service policy here (for example, pull --policy always) and test that this action really refreshes the images.

- "--"
- /opt/toolchain-low-memory/patch-server-config.sh
environment:
PASSWORD: ${HUBBLE_SERVER_PASSWORD:-pa}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This known default administrator password is combined with ports published on every host interface. The merged Compose config has no host_ip for 8080, 8520, or 8620, so the documented admin/pa Server and the Store/PD management endpoints are reachable from the developer's LAN. Please bind the necessary Server port to loopback, avoid publishing Store/PD to the host by default, and require or safely generate a local password.

Comment thread .codex/scripts/infra.sh
compose_files low "${server_repo}"
echo "[infra] stopping Compose services; named volumes are preserved"
TOOLCHAIN_CODEX_DIR="${CODEX_DIR}" HUGEGRAPH_VERSION=latest \
docker compose "${COMPOSE_ARGS[@]}" down

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ This down does not preserve the Server state as documented. hugegraph/server:latest declares VOLUME /hugegraph-server, but the merged Compose model does not attach a named volume there; removing the container leaves an anonymous volume that the next up will not reuse, including the initialization marker and local configuration. Please declare a stable named Server volume (and let reset remove it), or use docker compose stop for the preserving operation, with a stop/start persistence test.

--add-exports=java.base/sun.nio.ch=ALL-UNNAMED
volumes:
- type: bind
source: ${TOOLCHAIN_CODEX_DIR}/infra/patch-server-config.sh

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ The shared HStore service persists beyond worktree cleanup, but this bind mount points into the worktree that launched it. Once that temporary checkout is deleted, a container restart/recreation can no longer mount or execute the patch script. Please copy the script to a stable runtime location such as ~/.codex/run/..., or package it in a stable image/volume, before starting the persistent service.

grep -qx 'batch.max_write_threads=16' "${missing_yaml}/rest-server.properties"
}

test_environment_toml

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

‼️ This new contract suite is not wired into any CI job. Repository workflows do not invoke environment_test.sh, and hubble-ci.yml does not watch .codex/**; the current green Hubble job ran because the README changed and never executed these tests. Please add a workflow/step triggered by .codex/** that runs this suite, shell/static checks, and both layered docker compose config validations, including the BE and infrastructure lifecycle cases above.

python3 - "${CODEX_DIR}/environments/environment.toml" <<'PY'
import pathlib
import sys
import tomllib

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ The advertised bash .codex/tests/environment_test.sh command is not runnable with the target Mac's default Python: /usr/bin/python3 3.9.6 fails here with ModuleNotFoundError: No module named 'tomllib', while setup neither provisions nor checks Python 3.11+. Please use a compatible parser/fallback, or explicitly provision and validate Python 3.11+ in setup, documentation, and CI.

Comment thread .codex/scripts/hubble.sh
owner_identity_matches "${file}" || return 1
pid=$(read_field "${file}" pid)
port=$(read_field "${file}" port)
listener=$(lsof -tiTCP:"${port}" -sTCP:LISTEN 2>/dev/null | head -1 || true)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Missing lsof is silently treated as 'no listener'; similarly, kill_tree() swallows a missing pgrep. On a host without these undeclared tools, the script can claim an occupied port or stop only the wrapper and orphan Java/Node children. Please validate these required commands during setup/start with an actionable error, or provide reliable portable fallbacks instead of converting command-not-found into an empty result.

@imbajin
imbajin requested a review from Copilot July 22, 2026 08:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Adds a repository-managed Codex environment to make local Hubble development deterministic across worktrees, including optional HStore Compose profiles and verification actions.

Changes:

  • Document optional Codex worktree workflow in the Hubble README.
  • Add Codex environment definition plus setup/verify/dev-service management scripts.
  • Add Compose overlays + server config patching script, with a shell test for key environment behaviors.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
hugegraph-hubble/README.md Adds documentation entry point to the Codex environment guide.
.codex/README.md Documents runtime model, ownership, HStore profiles, and safety notes.
.codex/environments/environment.toml Defines Codex setup/cleanup plus FE/BE/infra/verify actions.
.codex/scripts/setup.sh Installs FE deps and validates local toolchain (Node/Java/mvnd).
.codex/scripts/verify.sh Adds fast/full verification entrypoints for FE + BE.
.codex/scripts/hubble.sh Implements FE stable ports, BE ownership switching, and status/stop actions.
.codex/scripts/infra.sh Adds HStore start/status/stop/reset/pull helpers and compose layering.
.codex/infra/compose.low-memory.yml Provides low-memory Compose overrides and server entrypoint patching.
.codex/infra/compose.balanced.yml Provides a “balanced” (less constrained) Compose override profile.
.codex/infra/patch-server-config.sh Patches server configs for low-memory defaults before container entrypoint.
.codex/tests/environment_test.sh Adds a bash test validating env TOML, port stability, compose args, and patching.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .codex/scripts/verify.sh
Comment on lines +27 to +37
if [[ -n "${JAVA11_HOME:-}" ]] && [[ -x "${JAVA11_HOME}/bin/java" ]]; then
JAVA_HOME=${JAVA11_HOME}
elif [[ -x /usr/libexec/java_home ]]; then
JAVA_HOME=$(/usr/libexec/java_home -v 11)
elif command -v java >/dev/null 2>&1 && \
java -version 2>&1 | head -1 | grep -Eq 'version "11\.'; then
JAVA_HOME=$(cd "$(dirname "$(command -v java)")/.." && pwd)
else
echo "ERROR: Java 11 is required; set JAVA11_HOME" >&2
exit 1
fi
Comment on lines +42 to +45
python3 - "${CODEX_DIR}/environments/environment.toml" <<'PY'
import pathlib
import sys
import tomllib
Comment thread .codex/scripts/hubble.sh
Comment on lines +30 to +32
hash_text() {
printf '%s' "$1" | LC_ALL=C shasum -a 256 | awk '{print substr($1, 1, 12)}'
}
Comment thread .codex/scripts/setup.sh
Comment on lines +50 to +53
command -v yarn >/dev/null || {
echo "ERROR: yarn is not available with Node 18.20.8" >&2
exit 1
}
Comment thread .codex/scripts/infra.sh
Comment on lines +101 to +106
if [[ -z "${container}" || "${project}" != hugegraph-single || \
"${service}" != "${expected_container#hg-}" || \
"${mapping}" != *":${port}"* ]]; then
echo "ERROR: port ${port} is owned by non-Compose pid ${listener}" >&2
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request hubble hugegraph-hubble size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants