Skip to content

ENS integration: versioned ENSJobPages hooks, view interfaces, replayable ENS state, and config validation#149

Open
MontrealAI wants to merge 1 commit into
mainfrom
codex/develop-ens-integration-for-agijobmanager-1qtisb
Open

ENS integration: versioned ENSJobPages hooks, view interfaces, replayable ENS state, and config validation#149
MontrealAI wants to merge 1 commit into
mainfrom
codex/develop-ens-integration-for-agijobmanager-1qtisb

Conversation

@MontrealAI

Copy link
Copy Markdown
Owner

Motivation

  • Make ENS integration robust and observable by shifting to a versioned hook interface and explicit compatibility checks so ENS side-effects remain best-effort and repairable.
  • Preserve settlement independence while enabling manager-driven push hooks, token URI issuance from ENS when available, and deterministic operator roll-forward/rollback workflows.
  • Harden ENS config correctness by validating root name / namehash consistency and NameWrapper readiness before cutover.

Description

  • Add a versioned ENS hook interface IENSJobPagesHooksV1 and a manager view interface IAGIJobManagerPrimeViewV1 and wire both sides to use versioned payloads when available (AGIJobManagerPrime._callEnsJobPagesHook / ENSJobPages.handleHook).
  • Expose a lightweight manager view API (getJobCore, getJobSpecURI, getJobCompletionURI, and ensJobManagerViewInterfaceVersion) and make AGIJobManagerPrime implement it for safe pull/compat checks.
  • Implement best-effort, observable ENS calls with EnsHookCallResult events, syncEnsForJob owner replay, retained replay state for cancelled jobs, and optional useEnsJobTokenURI to prefer ENS-issued ens:// URIs when minting completion NFTs.
  • Harden ENSJobPages by adding validateConfiguration(), isWrappedRootReady(), root-name/namehash verification (_namehash), stricter job-label prefix defaults (changed default prefix from agijob to agijob-), and explicit compatibility checks for job manager interface versions.
  • Add IPublicResolver.text to the resolver interface and update mocks, tests, docs, and tooling: new IENSJobPagesHooksV1.sol, IAGIJobManagerPrimeViewV1.sol, updated ENSJobPages.sol, updated AGIJobManagerPrime.sol, updated mocks under contracts/test/, updated deploy script (hardhat/scripts/deploy-ens-job-pages.js) to call validateConfiguration(), and doc updates to reflect naming/prefix and operational guidance.

Testing

  • Added a Truffle-style test suite test/prime.ens-pages.test.js exercising hook push semantics, replay/repair (syncEnsForJob), ENS-issued URIs, legacy migration compatibility, and non-versioned target behavior; the suite was executed with truffle test and passed.
  • Updated and used MockENSJobPages and MockAGIJobManagerView test doubles to validate both versioned and legacy interaction paths during the test run, and all assertions succeeded.

Codex Task

…, readiness, observability)

### Motivation
- Make ENS job-page issuance deterministic and operator-safe by switching from fragile pull-based selectors to a versioned push-hook interface and by making canonical future labels `agijob-<jobId>...`.
- Ensure ENS side effects remain best-effort but fully observable and repairable, and prevent silent mis-wiring by adding runtime compatibility and root-namehash validation.
- Expose stable read getters from the manager so ENS pages can validate and repair state without relying on unavailable internal shapes.
- Provide deployment guardrails and docs so a mainnet cutover can be validated, rolled forward, and rolled back safely.

### Description
- Replaced the brittle pull/selector hook with a typed versioned push interface `IENSJobPagesHooksV1` and implemented typed handlers on `ENSJobPages` (`onJobCreated`, `onJobAssigned`, `onJobCompletionRequested`, `onJobRevoked`, `onJobLocked`) while preserving best-effort semantics and legacy `handleHook` compatibility paths.
- Updated `AGIJobManagerPrime` to implement `IAGIJobManagerPrimeViewV1` and added stable read getters `getJobCore`, `getJobSpecURI`, `getJobCompletionURI`, plus `syncEnsForJob` and a typed `_callEnsJobPagesHook` that emits `EnsHookCallResult` for observability.
- Hardened `ENSJobPages` with canonical default prefix `jobLabelPrefix = "agijob-"`, enforced `namehash(rootName) == jobsRootNode`, added readiness/status surfaces `isFullyConfigured()`, `isWrappedRootReady()`, `validateConfiguration()` (bitmask), `jobEnsPreview()`, `jobEnsIssued()`, and `jobEnsStatus()` for per-job diagnostics, and added manager compatibility checks before accepting `setJobManager()`.
- Added wrapper/NameWrapper readiness checks, atomic subname creation where applicable, best-effort resolver/text/auth writes emitting `ENSHookBestEffortFailure` when they fail, and preserved legacy migration (`migrateLegacyWrappedJobPage`) behavior.
- Made completion NFT tokenURI behavior conditional and observable: `AGIJobManagerPrime.setUseEnsJobTokenURI` is emitted and when enabled the manager will static-query `ENSJobPages.jobEnsIssued/jobEnsURI` and use `ens://...` only if issued; otherwise fall back to completion URI.
- Added new events and admin hardening: `EnsJobPagesUpdated`, `UseEnsJobTokenURIUpdated`, `EnsHookCallResult`, `ENSHookProcessed`/`ENSHookSkipped` remain in ENSJobPages.
- Updated test mocks (`MockENSJobPages`, `MockAGIJobManagerView`) and added `test/prime.ens-pages.test.js` covering push-hook delivery, interface mismatch rejection, owner repair replay (`syncEnsForJob`), and ENS-backed NFT URI behavior.
- Updated deployment scripts and docs to require `validateConfiguration() == 0` before cutover, changed operator docs/examples from unhyphenated `agijob0` style to canonical `agijob-0`, and added short architecture/security notes and a mainnet cutover guidance tweak in the Hardhat deploy script.

### Testing
- Ran compilation and targeted unit tests: `npx truffle compile` (succeeds) and `npx truffle test test/prime.ens-pages.test.js --network test` (2 tests passed).
- Ran static Node check on the deploy helper `node -c hardhat/scripts/deploy-ens-job-pages.js` and `npx hardhat compile` for the Hardhat script (succeeds); `git diff --check` run with no blocking issues.
- Tests executed locally in the repo test harness passed (observed logs show the two new ENS-focused tests passed).

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3d68fec262

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +149 to +152
const validationMask = await ensJobPages.validateConfiguration();
console.log("validateConfiguration mask:", validationMask.toString());
if (validationMask !== 0n) {
throw new Error(`ENSJobPages validateConfiguration failed with bitmask ${validationMask.toString()}`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Defer validateConfiguration until after wrapper approval

In the normal wrapped-root rollout, validateConfiguration() cannot succeed until the wrapped-root owner has already granted NameWrapper.setApprovalForAll(newEnsJobPages, true); ENSJobPages.validateConfiguration() explicitly marks missing wrapper approval as a failure. Calling it immediately after deployment here, before the manual steps printed at lines 181-184, makes deploy-ens-job-pages.js abort on the standard replacement flow instead of guiding the operator through the required approval and cutover sequence.

Useful? React with 👍 / 👎.

Comment on lines 193 to 197
function setJobManager(address manager) external onlyOwner {
if (configLocked) revert ConfigLocked();
address old = jobManager;
if (manager == address(0) || manager.code.length == 0) revert InvalidParameters();
if (!_isCompatibleJobManager(manager)) revert InterfaceMismatch();
jobManager = manager;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep setJobManager compatible with deployed Prime managers

This compatibility gate makes the new ENSJobPages unusable with any AGIJobManagerPrime that was already deployed before this commit. Those contracts are immutable and do not expose ensJobManagerViewInterfaceVersion(), so setJobManager(existingPrime) now reverts with InterfaceMismatch even though the rest of the required view surface (getJobCore, getJobSpecURI, getJobCompletionURI) is the same. That breaks the additive ENSJobPages replacement path unless the manager itself is redeployed too.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant