Repository navigation
fix: resolve issues #538 #511 #468 assigned to solomon35-stack - #645
Merged
dzekojohn4 merged 2 commits intoSep 29, 2026
Merged
dzekojohn4 merged 2 commits into
dzekojohn4 merged 2 commits into
Conversation
…assigned to solomon35-stack - UnityChainxx#468: operation-labeled invariant tests for interleaved admin mutations (add/move/retire/set_question_per_level) including get_question_in_level enumeration and a drained-level case; fixes the broken lib.rs build by appending the missing Error variants QuestionRetired=15 and WrongQuestion=16 and aligning test discriminants (UnityChainxx#14 was SchemaVersionMismatch). - UnityChainxx#511: admin puzzle-submission form now persists through the backend draft API (create/update/publish), reports per-field validation errors, preserves content on failure; adds puzzleDraftService and vitest coverage. - UnityChainxx#538: already satisfied on main by the extracted config schema; the fail-closed STELLAR_MODE=live default is documented and asserted by config-validation.spec.ts. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@solomon35-stack Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #538
Closes #511
Closes #468
Supersedes the failing parts of the onchain test build and wires the admin draft form to the backend. #529 is intentionally not claimed here — see "Issue #529 status" below.
Issue #468 — contract-level invariant tests for interleaved admin mutations
Adds to
onchain/contracts/stellar_hunts/src/test.rs:assert_index_invariant— a harness asserting the formally documented index invariant fromlib.rs(Replace ad-hoc QuestionsByLevel index surgery in update_question and retire_question #464):QuestionPerLevelIndex(level)equals the number of live entries, each live id appears exactly once across the indices, no id appears in a foreign level, and the first slot past the live window is cleared.test_index_invariant_holds_after_each_interleaved_admin_operation— a deterministic sequence ofadd_question/update_questionlevel-moves /retire_question/set_question_per_levelwith the invariant checked after every operation, a move followed by enumeration viaget_question_in_level, and a final full enumeration of each level.test_index_invariant_when_a_level_is_drained_by_retirements— drains a level one retirement at a time, asserts a failed retirement (unknown id) leaves the indices untouched and the level count at 0.after step N (retire_question(2)): ...), per the acceptance criteria.Build fix required by the acceptance criterion
cargo test --workspace --lockedpassing: upstreammaindid not compile —lib.rsreferencesError::QuestionRetiredandError::WrongQuestion, which were never added to the enum. This PR appendsQuestionRetired = 15andWrongQuestion = 16(at the end, so existing discriminants stay stable) and aligns four test assertions that had been written against wrong discriminants (#14isSchemaVersionMismatch; the retirement guard is#15, the cursor guard#16). Before this PR the crate could not compile at all, so these tests had never actually run.Verified locally:
cargo test --workspace --locked→ 41 passed (stellar-hunts, incl. the 2 new tests), 13 passed (nft), 0 failed.Issue #511 — persist puzzle draft and submission forms to the backend
frontend/services/puzzleDraftService.js:createDraft(POST/drafts),updateDraft(PATCH/drafts/:id),publishDraft(POST/drafts/:id/publish), plusextractFieldErrors(maps class-validator message arrays from the global ValidationPipe onto per-field errors) andbuildDraftPayload(maps the form onto the backendCreateDraftDtocontract; parses the NFT-metadata JSON client-side so a malformed blob never reaches the wire).frontend/app/admin/puzzle-submission/page.jsxno longer posts to the non-existent/admin/puzzlesendpoint. It now: saves as draft and switches to update mode (draftIdstate); exposes Publish through the backend publish endpoint and distinguishes "saved as draft" from "published"; renders per-field validation errors; never clears entered content on a failed save/publish (reset happens only after a successful publish); surfaces errors through the shareduseApiMutationhook; authorization remains server-side (JwtAuthGuard + RolesGuard admin-only) with no client-side pretense.frontend/tests/admin-puzzle-submission.test.jsxcovering the three required cases — successful save (+update, +publish), validation failure with preserved content, failed publish with preserved draft — plus invalid-metadata-JSON rejection before any request.Note:
npm cifails on this repo'smainindependently of this PR (frontendpackage-lock.jsonis out of sync withpackage.json, e.g. tailwindcss 3.4.19 vs 4.3.3), so the vitest suite could not be executed in this environment. The tests are written against the repo's existing vitest + Testing Library conventions; maintainers runningnpm testafter a lockfile refresh will exercise them.Issue #538 — duplicate NODE_ENV key / STELLAR_MODE default
Resolved on
mainby the earlier config-schema work (#492): the schema was extracted tobackend/src/config/config.validation.ts(single importable definition, imported by bothapp.module.tsand the spec), contains no duplicate keys (the spec's "declares each key exactly once" asserts this), and the spec pins theSTELLAR_MODEdefault againstSTELLAR_MODE_DEFAULT, README.md andbackend/.env.example.Justification of the fail-closed
livedefault (acceptance criterion): a deployment that omitsSTELLAR_MODEwithout Soroban credentials fails at startup with every missing key named, instead of booting inmockmode whereStellarHandlerServicereturns synthetic success for NFT claims — a silent data-integrity failure in a rewards product, strictly worse than a boot error. The dangerous direction is additionally closed at the provider (mockis refused whenNODE_ENV=production), so production startup withSTELLAR_MODEunset cannot silently enter mock mode. Local development opts in viaSTELLAR_MODE=mock, which both docs state explicitly.Issue #529 status (not closed by this PR)
~45 DTO files still lack decorators on
main. The response-only DTOs (e.g.*-response.dto.ts,*stats.dto.ts) must be excluded, and the ~28 request DTOs need domain-derived rules derived from entities and existing manual checks — done hastily,whitelist: trueflips from silently accepting bodies to rejecting legitimate traffic. TheforbidNonWhitelistedposture (pipe spec assertstrue,main.tsuses unset) also has to be settled once for the whole sweep. This deserves its own reviewed PR; I'll follow up with one rather than bundling a risky sweep here.Verification summary
cargo test --workspace --lockedconfig-validation.spec.tson mainnpm test(vitest)🤖 Generated with Codebuff
Co-Authored-By: Codebuff noreply@codebuff.com