Skip to content

refactor(doc): move constant fields out of Settings into domain constants - #392

Merged
linearcombination merged 5 commits into
WycliffeAssociates:doc-dev.walink.orgfrom
linearcombination:DOC/fm/doc-settings-constants-out-of-settings
Nov 4, 2026
Merged

linearcombination merged 5 commits into
WycliffeAssociates:doc-dev.walink.orgfrom
linearcombination:DOC/fm/doc-settings-constants-out-of-settings

Conversation

@linearcombination

@linearcombination linearcombination commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Closes #385. Please let developer handle merge.

Intent

Create a PR for step 1 only of the DOC globals and defaulted-settings refactor: move the constant fields out of the Settings object into plain module constants. The other steps stay on hold.

Context: a scout surveyed the DOC backend (report: data/doc-globals-defaults-pattern-scout/report.md, sections 3.2 P5, 4 G2 and 5 M3). It found 14 Settings fields (about 51 default-parameter sites in about 40 functions) that are rendering constants or domain tables rather than deployment config, such as PREFERRED_RESOURCES, GATEWAY_LANGUAGES, USFM_RESOURCE_TYPES, RESOURCE_TYPE_CODES_AND_NAMES, the *_FMT_STR strings, HR and the other HTML fragments. None of them appears in the committed .env. Step 1 moves them out of Settings into immutable Final constants next to their domain, with no behavior change.

What Changed

  • Removed 14 constant fields from Settings in backend/doc/config.py: PREFERRED_RESOURCES, GATEWAY_LANGUAGES, USFM_RESOURCE_TYPES, RESOURCE_TYPE_CODES_AND_NAMES, the *_FMT_STR strings, HR and the other HTML fragments. They now live as module-level Final constants in the new backend/doc/domain/constants.py.
  • Updated the consumers to use the new constants instead of Settings defaults or attributes. These are the assembly strategies, document_generator, model, parsing, resource_lookup and tw_utils in doc, plus the passages and stet generators and stet resource lookup.
  • Updated the e2e test conftest.py and test_randomized_combinatoric.py to import the constants from their new location. The values themselves are unchanged.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: Mechanical relocation of constants into Final module constants with all call sites updated and no leftover Settings references; no behavior change.

Testing

I compared the 14 relocated constants against their old Settings values (identical, and removed from Settings), confirmed no code still reads them from settings, and imported every touched module. The developer ran both backend and frontend tests with success.

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Loaded the base config.py and the new doc.domain.constants and compared all 14 moved values. All are equal, and none is still an attribute of Settings.
  • grep for leftover settings.<MOVED_NAME> uses in backend and tests. Only two commented-out lines remain.
  • Imported every touched module (doc, passages and stet document generators, resource lookup, tw_utils, parsing, model, assembly strategies). All import cleanly.
  • pytest tests/unit on the target commit and again on the base commit.
- `Developer ran backend and frontend test suites with success`
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Move the Reviewer's Guide survey files to backend/passages/data/en_rg,
define their location and key table in passages, drop the runtime copy
hook, Dockerfile COPY lines and shared_en_rg volume, key the rg filter
on resource type, and cache the language-independent parse by path and
mtime.
…g slug, safe stet file name

generate_docx changes the rendered HTML so it is now Hashed. The passages
key caps the language slug with slug_group/MAX_LANGS_SLUG_LEN. The stet file
name is built with slug_group and request_key instead of raw language codes.
Move the 14 rendering-constant and domain-table fields (HTML fragments,
format strings, HR, PREFERRED_RESOURCES, GATEWAY_LANGUAGES,
USFM_RESOURCE_TYPES, RESOURCE_TYPE_CODES_AND_NAMES) out of Settings into
immutable Final module constants. Values are unchanged; mappings are
MappingProxyType and USFM_RESOURCE_TYPES is a tuple. Defaulted
parameters now bind the constants directly, so signatures and call
sites are unchanged.
@linearcombination
linearcombination merged commit 6efad7f into WycliffeAssociates:doc-dev.walink.org Nov 4, 2026
8 checks passed
@linearcombination
linearcombination deleted the DOC/fm/doc-settings-constants-out-of-settings branch November 4, 2026 23:42
@github-project-automation github-project-automation Bot moved this from In progress to Done in DOC Project Management Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants