ENS integration: versioned ENSJobPages hooks, view interfaces, replayable ENS state, and config validation#149
Conversation
…, 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).
There was a problem hiding this comment.
💡 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".
| const validationMask = await ensJobPages.validateConfiguration(); | ||
| console.log("validateConfiguration mask:", validationMask.toString()); | ||
| if (validationMask !== 0n) { | ||
| throw new Error(`ENSJobPages validateConfiguration failed with bitmask ${validationMask.toString()}`); |
There was a problem hiding this comment.
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 👍 / 👎.
| 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; |
There was a problem hiding this comment.
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 👍 / 👎.
Motivation
Description
IENSJobPagesHooksV1and a manager view interfaceIAGIJobManagerPrimeViewV1and wire both sides to use versioned payloads when available (AGIJobManagerPrime._callEnsJobPagesHook/ENSJobPages.handleHook).getJobCore,getJobSpecURI,getJobCompletionURI, andensJobManagerViewInterfaceVersion) and makeAGIJobManagerPrimeimplement it for safe pull/compat checks.EnsHookCallResultevents,syncEnsForJobowner replay, retained replay state for cancelled jobs, and optionaluseEnsJobTokenURIto prefer ENS-issuedens://URIs when minting completion NFTs.ENSJobPagesby addingvalidateConfiguration(),isWrappedRootReady(), root-name/namehash verification (_namehash), stricter job-label prefix defaults (changed default prefix fromagijobtoagijob-), and explicit compatibility checks for job manager interface versions.IPublicResolver.textto the resolver interface and update mocks, tests, docs, and tooling: newIENSJobPagesHooksV1.sol,IAGIJobManagerPrimeViewV1.sol, updatedENSJobPages.sol, updatedAGIJobManagerPrime.sol, updated mocks undercontracts/test/, updated deploy script (hardhat/scripts/deploy-ens-job-pages.js) to callvalidateConfiguration(), and doc updates to reflect naming/prefix and operational guidance.Testing
test/prime.ens-pages.test.jsexercising hook push semantics, replay/repair (syncEnsForJob), ENS-issued URIs, legacy migration compatibility, and non-versioned target behavior; the suite was executed withtruffle testand passed.MockENSJobPagesandMockAGIJobManagerViewtest doubles to validate both versioned and legacy interaction paths during the test run, and all assertions succeeded.Codex Task