Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7274ce3bfe
|
||
|
|
24e86ed598
|
||
|
|
1ec20174b7
|
||
|
|
2e317d3a0f
|
||
|
|
f7c606984f | ||
|
|
9617b86a26
|
||
|
|
224e5d0530 | ||
|
|
5f81ae386b
|
||
|
|
d2caa6de97 |
@@ -3,6 +3,7 @@
|
|||||||
^\.Rproj\.user$
|
^\.Rproj\.user$
|
||||||
^_pkgdown\.yml$
|
^_pkgdown\.yml$
|
||||||
^docs$
|
^docs$
|
||||||
|
^pm$
|
||||||
^Meta$
|
^Meta$
|
||||||
^doc$
|
^doc$
|
||||||
^pkgdown$
|
^pkgdown$
|
||||||
|
|||||||
@@ -39,5 +39,17 @@ jobs:
|
|||||||
echo "PAT_GH is unset -- add it under Settings > Actions > Secrets." >&2
|
echo "PAT_GH is unset -- add it under Settings > Actions > Secrets." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
# On a tag-triggered run, checkout materializes refs/tags/<tag> as a
|
||||||
|
# LIGHTWEIGHT tag at the commit SHA -- the annotated tag object Gitea
|
||||||
|
# holds is never fetched. Mirroring that strips the annotation, and the
|
||||||
|
# NEXT run on main (which does fetch the real object) is then rejected
|
||||||
|
# with "already exists" trying to correct it, because git will not
|
||||||
|
# clobber an existing tag. That is why v0.4.0 failed to mirror.
|
||||||
|
#
|
||||||
|
# Re-fetch canonical tag objects from Gitea first. --force here rewrites
|
||||||
|
# LOCAL tag refs only; it is not a force push and does not weaken the
|
||||||
|
# non-force guarantee on main documented above.
|
||||||
|
git fetch --tags --force origin
|
||||||
|
|
||||||
git push "https://x-access-token:${PAT_GH}@github.com/civilytics/uscogdata.git" \
|
git push "https://x-access-token:${PAT_GH}@github.com/civilytics/uscogdata.git" \
|
||||||
HEAD:refs/heads/main --tags
|
HEAD:refs/heads/main --tags
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
# Explain the mirror contribution flow on every incoming pull request.
|
||||||
|
#
|
||||||
|
# This repository is a MIRROR. A PR opened here is landed on the canonical Gitea
|
||||||
|
# repository and syncs back; because the merge preserves the contributor's
|
||||||
|
# commits at their original SHAs, GitHub marks the PR "Merged" on its own as
|
||||||
|
# soon as the mirror syncs -- with nobody visibly clicking Merge.
|
||||||
|
#
|
||||||
|
# Without this comment, that reads as a rejection: the contributor sees their PR
|
||||||
|
# close with no review, no merge button pressed, and no explanation. It is
|
||||||
|
# actually the successful outcome. Say so up front, before it happens.
|
||||||
|
#
|
||||||
|
# WHY pull_request_target AND NOT pull_request:
|
||||||
|
# a `pull_request` run from a fork gets a read-only token, so it cannot post a
|
||||||
|
# comment -- which is exactly the case this workflow exists to serve.
|
||||||
|
# `pull_request_target` runs in the context of the BASE repo and gets a writable
|
||||||
|
# token. That is only safe because this job never checks out or executes the
|
||||||
|
# contributor's code; it posts a fixed string. Do not add a checkout of
|
||||||
|
# `github.event.pull_request.head.sha` here -- that combination is the standard
|
||||||
|
# pull_request_target privilege-escalation hole.
|
||||||
|
name: Explain the mirror flow
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
types: [opened]
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
comment:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Post the contribution-flow explainer
|
||||||
|
uses: actions/github-script@v7
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const body = [
|
||||||
|
"Thanks for this — and one thing worth knowing before it happens.",
|
||||||
|
"",
|
||||||
|
"**This repository is a mirror.** Development happens on Gitea at",
|
||||||
|
"`gitea.civilytics.org/Civilytics/uscogdata`. Your pull request will be fetched",
|
||||||
|
"from here, landed there, and synced back.",
|
||||||
|
"",
|
||||||
|
"Because that merge preserves your commits at their original SHAs, **GitHub will",
|
||||||
|
"mark this pull request \"Merged\" on its own** — without anyone visibly clicking",
|
||||||
|
"the Merge button, and possibly without a review comment on this page first.",
|
||||||
|
"",
|
||||||
|
"> If your pull request closes as \"Merged\" and nobody appears to have merged it,",
|
||||||
|
"> that is the normal, successful outcome — not a rejection.",
|
||||||
|
"",
|
||||||
|
"If it is *not* going to be merged, you will get an actual reply saying so.",
|
||||||
|
"",
|
||||||
|
"Substantial contributions get a `ctb` entry in `DESCRIPTION`, which surfaces in",
|
||||||
|
"`citation(\"uscogdata\")`. There is no CLA and no DCO sign-off.",
|
||||||
|
"",
|
||||||
|
"Full details: [CONTRIBUTING.md](https://github.com/civilytics/uscogdata/blob/main/CONTRIBUTING.md).",
|
||||||
|
].join("\n");
|
||||||
|
|
||||||
|
await github.rest.issues.createComment({
|
||||||
|
owner: context.repo.owner,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
issue_number: context.payload.pull_request.number,
|
||||||
|
body,
|
||||||
|
});
|
||||||
@@ -4,6 +4,10 @@
|
|||||||
.Ruserdata
|
.Ruserdata
|
||||||
*.Rproj
|
*.Rproj
|
||||||
inst/doc
|
inst/doc
|
||||||
|
# pkgdown output. Compass used to keep its files in docs/pm/ and
|
||||||
|
# docs/decisions/, which forced this to be written as children with two
|
||||||
|
# re-includes -- git cannot re-include anything beneath an excluded directory.
|
||||||
|
# Compass lives in pm/ now, so the whole directory can be excluded again.
|
||||||
docs/
|
docs/
|
||||||
/doc/
|
/doc/
|
||||||
/Meta/
|
/Meta/
|
||||||
@@ -12,3 +16,6 @@ docs/
|
|||||||
|
|
||||||
# SDD working artifacts (ledger, briefs, review packages) — plans/ stays tracked
|
# SDD working artifacts (ledger, briefs, review packages) — plans/ stays tracked
|
||||||
.superpowers/sdd/
|
.superpowers/sdd/
|
||||||
|
.compass-cache/
|
||||||
|
# roborev snapshots
|
||||||
|
/.roborev/
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
# roborev configuration, initialised by compass.
|
||||||
|
# Reviews are queued to a background daemon -- they never block a commit.
|
||||||
|
|
||||||
|
post_commit_review = 'commit'
|
||||||
|
excluded_commit_patterns = ['WIP', 'chore:', 'chore(', 'docs:', 'Merge ']
|
||||||
|
|
||||||
|
review_guidelines = '''
|
||||||
|
# --- compass:begin (generated -- edit the sources, not this) ---
|
||||||
|
- Prefer returning new values to mutating arguments in place. A function that edits
|
||||||
|
its caller's object is a bug waiting for a second caller.
|
||||||
|
- Validate at system boundaries -- user input, API responses, file contents, config.
|
||||||
|
Fail fast with a message naming the field and the file.
|
||||||
|
- Never swallow an error. Handle it or let it propagate; a bare catch that continues
|
||||||
|
is worse than a crash.
|
||||||
|
- No hardcoded secrets, tokens, or credentials, and no secrets in log output or error
|
||||||
|
messages.
|
||||||
|
- Parameterise every query. String-built SQL is a defect even when the input looks safe.
|
||||||
|
- Keep functions under roughly 50 lines and files under roughly 400. Flag nesting
|
||||||
|
deeper than four levels.
|
||||||
|
- No magic numbers or hardcoded paths -- name them as constants or read them from config.
|
||||||
|
- New behaviour needs a test. A bug fix needs a test that fails without the fix.
|
||||||
|
- Prose a person reads -- an issue title or body, a journal entry, a decision record,
|
||||||
|
the narrative on the status board -- names the action or the thing, not the shape of
|
||||||
|
the machinery. Flag "gate", "seam", "surface area", "load-bearing", "first-class",
|
||||||
|
"primitive", "blast radius". A project's own defined vocabulary is not the target.
|
||||||
|
- Use the native pipe `|>`, not magrittr `%>%`.
|
||||||
|
- snake_case for objects and functions; UPPER_SNAKE for constants. Never use `.` as a
|
||||||
|
word separator in a function name -- it collides with S3 dispatch.
|
||||||
|
- Validate arguments at the top of exported functions with `stopifnot()` or an explicit
|
||||||
|
check, and say which argument was wrong.
|
||||||
|
- Never `setDT()`, `set()`, or otherwise modify by reference a data.table the caller
|
||||||
|
still owns. `as.data.table()` copies; use it.
|
||||||
|
- Prefer `vapply()` to `sapply()` -- `sapply()` silently returns a list when the type
|
||||||
|
varies, which turns a type error into a downstream mystery.
|
||||||
|
- Use `seq_len(n)` / `seq_along(x)`, never `1:n`, which iterates backwards when n is 0.
|
||||||
|
- Compare strings with `==` only after checking for NA; use `identical()` for scalars
|
||||||
|
where NA would be wrong.
|
||||||
|
- Do not call `library()` inside package or module files; attach packages in scripts and
|
||||||
|
test helpers only.
|
||||||
|
- Namespace-qualify calls into other packages (`stats::sd`) in code that is sourced.
|
||||||
|
- Every exported function needs roxygen with `@param` for each argument (type, meaning,
|
||||||
|
and why the default is what it is) and `@return`. Add `@examples` for exported API.
|
||||||
|
- Declare dependencies in DESCRIPTION. Prefer base R or an existing dependency over
|
||||||
|
adding a new one; a package with zero hard deps is worth keeping that way.
|
||||||
|
- Signal errors with `stop()` carrying a condition class, so callers can catch the kind
|
||||||
|
rather than matching on message text.
|
||||||
|
- Keep internals internal. Export only what a user needs; an accidentally exported
|
||||||
|
helper becomes an API you have to keep.
|
||||||
|
- Tests use testthat edition 3. Each test is self-sufficient -- no reliance on state
|
||||||
|
left by an earlier test or on a fixture built elsewhere in the file.
|
||||||
|
- Prefer duplication in tests over a helper that hides what is being asserted.
|
||||||
|
- Every verb calls .ensure_session() first, then queries via DBI::dbGetQuery().
|
||||||
|
- A verb's return value is always a tbl_df carrying a provenance attribute.
|
||||||
|
- govid inputs always go through .coerce_govid_input(); it accepts a character vector or a data frame.
|
||||||
|
- SQL has two layers: view definitions are numbered .sql files in inst/sql/ registered by .register_views(); query construction is inline sprintf() in R. Add a view as a file; build a query in R.
|
||||||
|
- No arrow dependency -- DuckDB reads parquet natively.
|
||||||
|
- withr is Suggests-only and must appear in tests alone.
|
||||||
|
- Tests must pass offline against the bundled fixture; tests/testthat/setup.R sets USCOGDATA_URL for that.
|
||||||
|
# --- compass:end ---
|
||||||
|
'''
|
||||||
+10
-2
@@ -101,5 +101,13 @@ but "usually" is not a release gate.
|
|||||||
variables set. This is the only check that catches a
|
variables set. This is the only check that catches a
|
||||||
corpus-unreachable defect, and its absence is why 0.3.0 needed fixing.
|
corpus-unreachable defect, and its absence is why 0.3.0 needed fixing.
|
||||||
8. Bump `Version` and add a `NEWS.md` section.
|
8. Bump `Version` and add a `NEWS.md` section.
|
||||||
9. Tag, then update the r-universe registry pin at
|
9. Tag on **Gitea** (`git tag -a vX.Y.Z && git push origin vX.Y.Z`). The mirror
|
||||||
`github.com/civilytics/civilytics.r-universe.dev`.
|
workflow carries tags to GitHub on its own — confirm the tag appears at
|
||||||
|
`github.com/civilytics/uscogdata/tags` before continuing.
|
||||||
|
10. Update the r-universe registry pin at
|
||||||
|
`github.com/civilytics/civilytics.r-universe.dev` — edit `packages.json`'s
|
||||||
|
`branch` to the new tag. **r-universe will not pick up a release until this
|
||||||
|
is edited**: the pin is a tag, deliberately, so a mid-refactor `main` is
|
||||||
|
never published as a release. `"branch": "*release"` would track releases
|
||||||
|
automatically, but it needs a GitHub *Release* object and the mirror pushes
|
||||||
|
tags only — so it would silently never update.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# uscogdata
|
# uscogdata
|
||||||
|
|
||||||
<!-- badges: start -->
|
<!-- badges: start -->
|
||||||
|
[](https://github.com/civilytics/uscogdata/actions/workflows/R-CMD-check.yaml)
|
||||||
[](https://civilytics.r-universe.dev/uscogdata)
|
[](https://civilytics.r-universe.dev/uscogdata)
|
||||||
[](LICENSE.md)
|
[](LICENSE.md)
|
||||||
<!-- badges: end -->
|
<!-- badges: end -->
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,14 @@
|
|||||||
|
# Project journal
|
||||||
|
|
||||||
|
Append-only, newest first. **Entries are never edited** — the value of this file is
|
||||||
|
that it records what was believed at the time, including the parts that turned out
|
||||||
|
wrong. Where things stand *today* is in `STATUS.md`, which is generated.
|
||||||
|
|
||||||
|
Four lines per entry. The analysis belongs in the issue or the decision record; this
|
||||||
|
file carries the reasoning and the pointers.
|
||||||
|
|
||||||
|
- **Why** — the driver. The one line git cannot reconstruct later.
|
||||||
|
- **Obligates** — issues this change created elsewhere. Numbers, not prose.
|
||||||
|
- **Refs** — commits, issues, decision records.
|
||||||
|
|
||||||
|
---
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
# Project status
|
||||||
|
|
||||||
|
> Between the compass markers is generated. Edit the sources, not this.
|
||||||
|
|
||||||
|
<!-- compass:begin -->
|
||||||
|
<!-- compass:board -->
|
||||||
|
|
||||||
|
## Where this stands
|
||||||
|
|
||||||
|
uscogdata is at 0.4.0 and its public surface is settled: the query verbs, the cohort
|
||||||
|
predicates added in this release, and the provenance contract every verb returns.
|
||||||
|
|
||||||
|
The six open issues split cleanly. Two are API work carried out of the #9 review pass
|
||||||
|
and deliberately deferred there rather than fixed in that branch. Three concern the
|
||||||
|
corpus layer, and the largest of them, partition-level caching, was named the single
|
||||||
|
highest-leverage change on the remote path before being deferred. One, the
|
||||||
|
data-correction intake (#52), is a decision rather than a task: it was parked during
|
||||||
|
the 0.3.0 design, and the API announcement waits on it, because without it the corpus
|
||||||
|
cannot make the "traceable and correctable" claim that most distinguishes it from
|
||||||
|
Census's own files.
|
||||||
|
|
||||||
|
Nothing here is blocked on anything else, so the ordering is a judgement about value
|
||||||
|
rather than a dependency graph.
|
||||||
|
|
||||||
|
Compass's own files moved out of `docs/` this session. They were sitting inside
|
||||||
|
pkgdown's output directory, and `pkgdown::clean_site()` deletes every top-level entry
|
||||||
|
there except `CNAME` and `dev` — asked directly, it listed `docs/pm` and
|
||||||
|
`docs/decisions` among the 28 it would remove, with the guard that would have stopped
|
||||||
|
it satisfied by `docs/pkgdown.yml`. They are in `pm/` now. Nothing was lost: the
|
||||||
|
journal had no entries and there were no decision records yet, which made this the
|
||||||
|
cheapest moment to move. The `.gitignore` workaround that re-included two children of
|
||||||
|
an excluded `docs/` is gone with it.
|
||||||
|
|
||||||
|
## Ready to work on next
|
||||||
|
|
||||||
|
- **#34** cog_revenue() offers expenditure recipes as suggestions: scope the candidate query by category_type · `ws/api` — nothing is blocking it; something is currently wrong
|
||||||
|
- **#36** n_units_reporting is category-conditional and cannot be read as a response rate · `ws/corpus` — nothing is blocking it; owed work from an earlier change
|
||||||
|
- **#2** Extend population data to be households as an alternate spending denominator · `ws/corpus` — nothing is blocking it
|
||||||
|
- **#33** Decompose .build_suggestions() (106 lines) into named helpers · `ws/api` — nothing is blocking it
|
||||||
|
- **#52** Release 11/11: design the data-correction intake (deferred; gates the API announcement) · `ws/corpus` — nothing is blocking it
|
||||||
|
- **#64** Partition-level caching: R/cache.R is still a stub, and the remote path pays for it every session · `ws/corpus` — nothing is blocking it
|
||||||
|
|
||||||
|
## Workstreams
|
||||||
|
|
||||||
|
| Stream | Commits since | Open | Debt | Owes docs |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| Query verbs and results | 77 | 2 | 0 | no |
|
||||||
|
| Corpus, mirror, provenance | 39 | 4 | 1 | no |
|
||||||
|
| Vignettes and guides | 34 | 0 | 0 | **yes** |
|
||||||
|
|
||||||
|
## CI
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Dependency graph and detail</summary>
|
||||||
|
|
||||||
|
_Nothing blocks anything else, so there is no graph to draw._
|
||||||
|
|
||||||
|
- Marker: `none` (no journal entry yet)
|
||||||
|
- Commits since: 165
|
||||||
|
- Open issues: 6
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<!-- compass:end -->
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
[project]
|
||||||
|
name = "uscogdata"
|
||||||
|
forge = "Civilytics/uscogdata"
|
||||||
|
|
||||||
|
# Three strands that go stale independently: what the verbs return, what the
|
||||||
|
# corpus is and how it is mounted, and how both are explained to a reader.
|
||||||
|
|
||||||
|
[[workstream]]
|
||||||
|
id = "api"
|
||||||
|
title = "Query verbs and results"
|
||||||
|
paths = [
|
||||||
|
"R/revenue.R", "R/spending.R", "R/balances.R", "R/peers.R", "R/search.R",
|
||||||
|
"R/categories.R", "R/recipes.R", "R/rollup.R", "R/explain.R", "R/basket.R",
|
||||||
|
"R/suggestions.R", "R/suppression.R", "R/complete.R", "R/cohort.R",
|
||||||
|
"R/basis.R", "R/adjust.R", "R/pagination.R",
|
||||||
|
]
|
||||||
|
docs = ["vignettes/*.Rmd", "README.md"]
|
||||||
|
|
||||||
|
[[workstream]]
|
||||||
|
id = "corpus"
|
||||||
|
title = "Corpus, mirror, provenance"
|
||||||
|
paths = [
|
||||||
|
"R/manifest.R", "R/mirror.R", "R/cache.R", "R/session.R", "R/provenance.R",
|
||||||
|
"R/coverage.R", "R/config.R", "R/views.R", "R/series_breaks.R",
|
||||||
|
"R/balance_caveats.R", "R/zzz.R", "data-raw/**", "inst/sql/**",
|
||||||
|
]
|
||||||
|
docs = ["vignettes/*.Rmd", "NEWS.md"]
|
||||||
|
|
||||||
|
[[workstream]]
|
||||||
|
id = "docs"
|
||||||
|
title = "Vignettes and guides"
|
||||||
|
paths = ["vignettes/**", "README.md", "_pkgdown.yml", "NEWS.md"]
|
||||||
|
docs = []
|
||||||
|
|
||||||
|
[roborev]
|
||||||
|
project_guidelines = [
|
||||||
|
"Every verb calls .ensure_session() first, then queries via DBI::dbGetQuery().",
|
||||||
|
"A verb's return value is always a tbl_df carrying a provenance attribute.",
|
||||||
|
"govid inputs always go through .coerce_govid_input(); it accepts a character vector or a data frame.",
|
||||||
|
"SQL has two layers: view definitions are numbered .sql files in inst/sql/ registered by .register_views(); query construction is inline sprintf() in R. Add a view as a file; build a query in R.",
|
||||||
|
"No arrow dependency -- DuckDB reads parquet natively.",
|
||||||
|
"withr is Suggests-only and must appear in tests alone.",
|
||||||
|
"Tests must pass offline against the bundled fixture; tests/testthat/setup.R sets USCOGDATA_URL for that.",
|
||||||
|
]
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# Decisions
|
||||||
|
|
||||||
|
One file per decision, numbered and immutable. A decision that changes is superseded
|
||||||
|
by a new record, never edited in place — the old reasoning is the point.
|
||||||
|
|
||||||
|
The table below is **generated** by `compass:decide`. Do not hand-edit it.
|
||||||
|
|
||||||
|
<!-- compass:begin decisions -->
|
||||||
|
| # | Date | Decision | Status |
|
||||||
|
|---|---|---|---|
|
||||||
|
| — | — | *No decisions recorded yet.* | — |
|
||||||
|
<!-- compass:end decisions -->
|
||||||
Reference in New Issue
Block a user