Implement analytics outcomes, admin APIs, export fields, and analysis tools#9
Open
Spbd1 wants to merge 1 commit into
Conversation
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.
Motivation
Description
packages/engine/src/outcomes.tsand exported them from the engine index to compute per-round and per-server metrics (informalCooperationRate, contractReliability, productiveInvestmentShare, publicContributionShare, exitRate, safeAssetShare, lobbyingShare, totalOutput, treasuryBalance, activePlayers, finalWealthGini, initialParcelQualityGini, formalContractShare, averageWealth, medianWealth, and contract counts).apps/web/lib/services/adminAnalytics.tsthat loads Prisma rows, maps to engine inputs, and returnsrounds,latest,players, andparcelspayloads; addedGET /api/admin/servers/:serverId/analyticsatapps/web/app/api/admin/servers/[serverId]/analytics/route.tsand expandedGET /api/admin/analytics/overviewatapps/web/app/api/admin/analytics/overview/route.tsto include analytics summaries.apps/web/app/admin/servers/[serverId]/analytics/page.tsxto show treatment condition badges, current round stats, line charts (productive investment share, public contribution share, informal cooperation rate, contract reliability, exit rate), a bar chart (formal vs informal contracts), a histogram of final wealth, a parcel quality map, and a round outcomes table.apps/web/lib/services/researchExport.tsto reuse engine outcome calculations and include the new outcome fields inround_outcomes.csvandserver_summary.csv.packages/analysis/scripts/estimate_effects.pythat reads exported CSVs (or ZIP) and runs quick OLS regressions of the formoutcome ~ high_inequality + uncertainty + interaction, writing a Markdown report, and addeddocs/analysis-plan.mddocumenting outcomes, treatment design, regression model, clustering warning, and limitations.Testing
git diff --checkwith no problems reported.python3 -m py_compile packages/analysis/scripts/estimate_effects.pyand executedpython3 packages/analysis/scripts/estimate_effects.py <temp-csv-dir> -o <temp-csv-dir>/report.mdto produce a sample Markdown report (succeeded).pnpm --filter @parcel-society/engine typecheckandpnpm --filter @parcel-society/web typecheck) but they could not complete in this environment because workspace Node dependencies were unavailable andpnpm installfailed due to external registry access restrictions (npm 403), so full TS checks were not run here.Codex Task