Repository navigation
fix(import): publish the learning import --from-mr extracts (#823) - #825
Conversation
|
No findings. The PR description includes a representative real-CLI end-to-end verification, so it satisfies the runtime-change testing requirement. Reviewed only the specified diff; no tests or PR code were executed. |
d31c026 to
5db2158
Compare
The PR description includes sufficient representative real-CLI end-to-end verification. No PR code or tests were executed. |
…t#823) `import --from-mr` wrote its learning into the teamai-learnings worktree, then pushed with autoPushViaMR, which commits `.` in repo.localPath: the knowledge clone, another checkout. That found nothing to commit, so the learning stayed untracked on this machine and never reached the team, while the command still reported the push step as done. The draft now goes into the contribution queue, and a "Publish learning" step calls publishQueuedLearnings, the path `teamai contribute` uses: it commits and pushes the queue on teamai-learnings and drops an entry once it is on origin. When publishing fails the learning stays queued, the step says so, and the next `teamai pull` publishes it. As in contribute, the queued file takes contribute's name (a random suffix keeps two learnings with the same title and day apart), the recall index is rebuilt after the publish attempt, the supersede check also reads the queue, and a read-only (HTTP) source is refused up front instead of queueing a learning nothing can publish; --dry-run and --output still work there. "Push changes via MR" is left for the teamwiki update it was also for. The learning also lands where contribute puts it: resolveLearningsSubdir (now exported) picks learnings/<namespace>/ when exactly one active project declares a learnings namespace, else the shared root. It used to go to the root, where every project's members recall it. Also, from the same follow-up issue: - wiki slug: the main checkout's root takes its repo's name too, so one opened through a differently named symlink writes the same evidence as its worktrees. Subdirectories keep their own name. - repo labels: a path is not qualified into a label a remote-form key already has (github.com/acme/api vs /x/acme/api), so the two no longer merge in `stats --by-repo`. The fallback is the repo's directory, so a bare repo's keys still share one row. - local-agent tests use a session id unique per run: the hint markers are machine-wide files in os.tmpdir() keyed by session id, and overlapping runs deleted each other's.
|
Re the P2 in #825 (comment): fixed in 91e11ce. The HTTP read-only line in |
5db2158 to
91e11ce
Compare
|
No findings. The earlier HTTP-mode documentation issue is resolved: both usage guides now clarify that publishing is unavailable while The PR description includes sufficient representative real-CLI end-to-end verification for the runtime changes. Reviewed only the specified diff; no PR code, tests, builds, or installs were executed. |
…ashboard; show the MR import prompt (Tencent#823) Three places that decide which learnings are found, and the MR import prompt. Recall index rebuild (item 12). When recall had to build a missing index, one unreadable roles.yaml or projects.yaml failed the whole build: deliveredIndexSources and resolveActiveLearningsNamespaces threw, the error went to log.debug, and recall said "No learnings available. Run `teamai pull` first", which pull does not fix. Each now runs in its own try. Learnings do not depend on the manifests and are always indexed: a broken projects.yaml leaves only the shared root, never every namespace. Docs, rules and skills get empty lists (undefined would index the whole trees), and one warning names the cause; a broken projects.yaml, which both read, gives one warning for both. The partial index is saved like any other, so later recalls stay quiet and the next pull rebuilds it whole. A skills collision with no index to keep skills from indexed none silently; IndexedSkills' keep-indexed now carries the conflict line and recall shows it when there are no indexed skills to keep (no index, or an older one). Any other build failure is shown with its cause, not as "No learnings available". import --from-mr duplicate check (item 9). The scan listed only each root's top level, so learnings under learnings/<ns>/, where Tencent#825 files MR learnings, were never compared. Its result fed only a "marking as superseded" warning, and nothing stored or read LearningDraft.supersedes, so the claim was false. The scan (now findOverlappingLearnings) also walks the active project namespaces, as the index does (safe single segments, first root wins per relative path), and the warning becomes a possible-duplicate notice naming the files. `import` ran the extraction as a task, with the logger silenced, so importFromMR's warning never reached the terminal; the extraction now runs before the tasks (item 18), where the logger prints it. The namespaces are resolved first: a broken projects.yaml narrows the check to the shared root with a warning, as recall does, so --dry-run and --output keep working. LearningDraft.supersedes and SUPERSEDE_THRESHOLD are removed. The CI extractor still reads only the root (it has no LocalConfig). Dashboard knowledge report (item 16). Its fallback index, built when no search index exists, passed no learningsNamespaces, so project learnings were missing in both scopes; in user scope it read learningsRoots().read, which keeps another repository's learnings checkout in the write root (Tencent#808). It now uses indexableLearningsRoots in user scope, as project scope already did, and resolves the active namespaces with the paths. A broken projects.yaml leaves the shared root, with a warning when the report builds its own index. import --from-mr prompt (item 18). importFromMR, which asks "Accept learning? [Y/n]" on a readline, ran inside the first listr2 task. In a terminal the default renderer holds stdout back while a task runs, so only a spinner showed and the prompt appeared after it was answered. The extraction now runs before the task list, which starts at "Publish learning" with the extraction's result as its context.
…ashboard; show the MR import prompt (#823) (#834) * fix(learnings): find learnings despite a broken manifest and in the dashboard; show the MR import prompt (#823) Three places that decide which learnings are found, and the MR import prompt. Recall index rebuild (item 12). When recall had to build a missing index, one unreadable roles.yaml or projects.yaml failed the whole build: deliveredIndexSources and resolveActiveLearningsNamespaces threw, the error went to log.debug, and recall said "No learnings available. Run `teamai pull` first", which pull does not fix. Each now runs in its own try. Learnings do not depend on the manifests and are always indexed: a broken projects.yaml leaves only the shared root, never every namespace. Docs, rules and skills get empty lists (undefined would index the whole trees), and one warning names the cause; a broken projects.yaml, which both read, gives one warning for both. The partial index is saved like any other, so later recalls stay quiet and the next pull rebuilds it whole. A skills collision with no index to keep skills from indexed none silently; IndexedSkills' keep-indexed now carries the conflict line and recall shows it when there are no indexed skills to keep (no index, or an older one). Any other build failure is shown with its cause, not as "No learnings available". import --from-mr duplicate check (item 9). The scan listed only each root's top level, so learnings under learnings/<ns>/, where #825 files MR learnings, were never compared. Its result fed only a "marking as superseded" warning, and nothing stored or read LearningDraft.supersedes, so the claim was false. The scan (now findOverlappingLearnings) also walks the active project namespaces, as the index does (safe single segments, first root wins per relative path), and the warning becomes a possible-duplicate notice naming the files. `import` ran the extraction as a task, with the logger silenced, so importFromMR's warning never reached the terminal; the extraction now runs before the tasks (item 18), where the logger prints it. The namespaces are resolved first: a broken projects.yaml narrows the check to the shared root with a warning, as recall does, so --dry-run and --output keep working. LearningDraft.supersedes and SUPERSEDE_THRESHOLD are removed. The CI extractor still reads only the root (it has no LocalConfig). Dashboard knowledge report (item 16). Its fallback index, built when no search index exists, passed no learningsNamespaces, so project learnings were missing in both scopes; in user scope it read learningsRoots().read, which keeps another repository's learnings checkout in the write root (#808). It now uses indexableLearningsRoots in user scope, as project scope already did, and resolves the active namespaces with the paths. A broken projects.yaml leaves the shared root, with a warning when the report builds its own index. import --from-mr prompt (item 18). importFromMR, which asks "Accept learning? [Y/n]" on a readline, ran inside the first listr2 task. In a terminal the default renderer holds stdout back while a task runs, so only a spinner showed and the prompt appeared after it was answered. The extraction now runs before the task list, which starts at "Publish learning" with the extraction's result as its context. * fix(learnings): address review — write the partial recall index past the shrink guard (#823) With a manifest recall cannot read, the rebuild leaves docs, rules and skills out on purpose. Against an older-format index of a full corpus the result is under 20% of it, so buildIndex's shrink guard kept the old file and recall searched the entries its warning said were left out. The degraded rebuild now passes `partial`, which skips the guard; every other build keeps it. * fix(learnings): address review — skip the older recall index when the partial one cannot be written (#823) * fix(learnings): address review — show queued learnings in the dashboard's fallback index (#823) The dashboard's temporary index now reads the contribution queue, as recall's does; promotion and prune candidates keep to the published roots. The recall rule tells the agent to relay the skipped-older-index warning.
…t#823) (Tencent#825) `import --from-mr` wrote its learning into the teamai-learnings worktree, then pushed with autoPushViaMR, which commits `.` in repo.localPath: the knowledge clone, another checkout. That found nothing to commit, so the learning stayed untracked on this machine and never reached the team, while the command still reported the push step as done. The draft now goes into the contribution queue, and a "Publish learning" step calls publishQueuedLearnings, the path `teamai contribute` uses: it commits and pushes the queue on teamai-learnings and drops an entry once it is on origin. When publishing fails the learning stays queued, the step says so, and the next `teamai pull` publishes it. As in contribute, the queued file takes contribute's name (a random suffix keeps two learnings with the same title and day apart), the recall index is rebuilt after the publish attempt, the supersede check also reads the queue, and a read-only (HTTP) source is refused up front instead of queueing a learning nothing can publish; --dry-run and --output still work there. "Push changes via MR" is left for the teamwiki update it was also for. The learning also lands where contribute puts it: resolveLearningsSubdir (now exported) picks learnings/<namespace>/ when exactly one active project declares a learnings namespace, else the shared root. It used to go to the root, where every project's members recall it. Also, from the same follow-up issue: - wiki slug: the main checkout's root takes its repo's name too, so one opened through a differently named symlink writes the same evidence as its worktrees. Subdirectories keep their own name. - repo labels: a path is not qualified into a label a remote-form key already has (github.com/acme/api vs /x/acme/api), so the two no longer merge in `stats --by-repo`. The fallback is the repo's directory, so a bare repo's keys still share one row. - local-agent tests use a session id unique per run: the hint markers are machine-wide files in os.tmpdir() keyed by session id, and overlapping runs deleted each other's.
…ashboard; show the MR import prompt (Tencent#823) (Tencent#834) * fix(learnings): find learnings despite a broken manifest and in the dashboard; show the MR import prompt (Tencent#823) Three places that decide which learnings are found, and the MR import prompt. Recall index rebuild (item 12). When recall had to build a missing index, one unreadable roles.yaml or projects.yaml failed the whole build: deliveredIndexSources and resolveActiveLearningsNamespaces threw, the error went to log.debug, and recall said "No learnings available. Run `teamai pull` first", which pull does not fix. Each now runs in its own try. Learnings do not depend on the manifests and are always indexed: a broken projects.yaml leaves only the shared root, never every namespace. Docs, rules and skills get empty lists (undefined would index the whole trees), and one warning names the cause; a broken projects.yaml, which both read, gives one warning for both. The partial index is saved like any other, so later recalls stay quiet and the next pull rebuilds it whole. A skills collision with no index to keep skills from indexed none silently; IndexedSkills' keep-indexed now carries the conflict line and recall shows it when there are no indexed skills to keep (no index, or an older one). Any other build failure is shown with its cause, not as "No learnings available". import --from-mr duplicate check (item 9). The scan listed only each root's top level, so learnings under learnings/<ns>/, where Tencent#825 files MR learnings, were never compared. Its result fed only a "marking as superseded" warning, and nothing stored or read LearningDraft.supersedes, so the claim was false. The scan (now findOverlappingLearnings) also walks the active project namespaces, as the index does (safe single segments, first root wins per relative path), and the warning becomes a possible-duplicate notice naming the files. `import` ran the extraction as a task, with the logger silenced, so importFromMR's warning never reached the terminal; the extraction now runs before the tasks (item 18), where the logger prints it. The namespaces are resolved first: a broken projects.yaml narrows the check to the shared root with a warning, as recall does, so --dry-run and --output keep working. LearningDraft.supersedes and SUPERSEDE_THRESHOLD are removed. The CI extractor still reads only the root (it has no LocalConfig). Dashboard knowledge report (item 16). Its fallback index, built when no search index exists, passed no learningsNamespaces, so project learnings were missing in both scopes; in user scope it read learningsRoots().read, which keeps another repository's learnings checkout in the write root (Tencent#808). It now uses indexableLearningsRoots in user scope, as project scope already did, and resolves the active namespaces with the paths. A broken projects.yaml leaves the shared root, with a warning when the report builds its own index. import --from-mr prompt (item 18). importFromMR, which asks "Accept learning? [Y/n]" on a readline, ran inside the first listr2 task. In a terminal the default renderer holds stdout back while a task runs, so only a spinner showed and the prompt appeared after it was answered. The extraction now runs before the task list, which starts at "Publish learning" with the extraction's result as its context. * fix(learnings): address review — write the partial recall index past the shrink guard (Tencent#823) With a manifest recall cannot read, the rebuild leaves docs, rules and skills out on purpose. Against an older-format index of a full corpus the result is under 20% of it, so buildIndex's shrink guard kept the old file and recall searched the entries its warning said were left out. The degraded rebuild now passes `partial`, which skips the guard; every other build keeps it. * fix(learnings): address review — skip the older recall index when the partial one cannot be written (Tencent#823) * fix(learnings): address review — show queued learnings in the dashboard's fallback index (Tencent#823) The dashboard's temporary index now reads the contribution queue, as recall's does; promotion and prune candidates keep to the published roots. The recall rule tells the agent to relay the skipped-older-index warning.
Summary
teamai import --from-mrnever published its learning, although it reported the push as done. It now takesteamai contribute's path: queue, then publish onteamai-learnings, in the active project's learnings namespace when contribute would use one. Also #823's three Cleanup items.import --from-mr✔ Push changes via MR; learning untracked inlearnings-wt; nothing onteam.gitteamai-learnings; worktree cleanalphalearnings/root, recalled by every projectlearnings/alpha/, as contributeteamai pullpublishes itread-only HTTP sourceerror, nothing queued;--dry-runpreviewsaliasalias(its worktrees:my-repo)my-repogithub.com/acme/api,/x/acme/api,/y/other/apiacme/apitwice (onestats --by-reporow)acme/api,/x/acme/api,other/apilocal-agent.test.tsin overlapping runsType of Change
Test Plan
npx tsc --noEmitpassesnpx vitest runpasses: 307 files, 4781 passed, 1 skippedimport-mr-publish-823.test.ts(11 cases); unit cases inanchors.test.ts(slug) andsession-analytics.test.ts(labels, bare repo still one row);local-agent.test.tsuses a session id unique per runcodebase-extract-cli,repo-attribution-worktrees-809,multi-project,learnings-sync-704-705: 5 files, 29 passed. CI runs the rest.The e2e drives the built CLI: sandbox HOME, local bare team repo (provider
github), user scope, git mode, fakegh/claude.origin/main--dry-runcase passes on both), e.g.expected [] to have a length of 1 but got +0(nothing onteamai-learnings)expected [ 'learnings' ] to deeply equal [ 'learnings/alpha' ]Reverting any one of 13 parts and rebuilding fails a test: queue write, publish step, "saved locally" line, per-learning status, index rebuild, HTTP guard, its dry-run exemption, filename, namespace in the queue path, namespace in the status check, slug rule, remote-label rule, its directory fallback. Flake:
local-agent.test.ts, 4 in parallel × 4 rounds: 12 of 16 fail before, 0 after.Reproduced with the real CLI (git mode, sandbox HOME, fake gh/claude)
Read in the code, not run with the real CLI:
.gitignoreself-heal before the steps.learnings-wtstays there;teamai contribute --file <path>publishes it.Related Issues
Part of #823: items 1 and 6 and the three Cleanup items. Items 2-5 follow once #819 is merged.
Notes for Reviewers
publishQueuedLearningspublishes the whole queue, so an older queued contribution goes out with this one. The commit message and the namespace rule (resolveLearningsSubdir: zero or several active namespaces mean the shared root) are contribute's.os.tmpdir()keyed by session id (src/local-agent.ts:1117,:1192); the fixed id let overlapping runs delete each other's.rebuildIndexAfterContribute,generateFilenameandresolveLearningsSubdirare now exported.usage-guide{,.zh-CN}.md(--from-mrpublishing and its namespace, slug rule, HTTP read-only list), the--projecthelp, andcommands.mdregenerated.