mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-10 12:37:55 +01:00
test(evals): distinguish deployment credential purpose from recipients
Normalize only the bound deployment key and its display name before named-recipient checks; retain foreign consumer rejection and saved-binding gates. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
1 parent
1d1589ce89
commit
9e087f06dc
2 files changed
+4
-3
No files matched your search
@@ -29,7 +29,7 @@ it("actual company act admits its safe question before private human entry",asyn
|
||||
await expect(companySecretExternalCases[0]!.act!(ctx,{currentPersonId:"person"})).rejects.toThrow("NEXT_REAL_HUMAN_PHASE");expect(reached).toBe(true);
|
||||
});
|
||||
it("accepts Done and completed-setup Yes without repeating the already-bound consumer",()=>{
|
||||
for(const label of ["Done","Yes","Done, ready to continue","Done for deployment"]){const row=question();row.payload.questionSet!.questions[0]!.options![0]!.label=label;expect(companySecretQuestionHandoff(row,binding)).toMatchObject({optionId:"yes"});}
|
||||
for(const label of ["Done","Yes","Done, ready to continue","Done for deployment","Done for DEPLOYMENT_API_KEY","Done for the Deployment API key"]){const row=question();row.payload.questionSet!.questions[0]!.options![0]!.label=label;expect(companySecretQuestionHandoff(row,binding)).toMatchObject({optionId:"yes"});}
|
||||
});
|
||||
it("rejects prospective Yes and negative or other-owner completion choices",()=>{
|
||||
const prospective=question();prospective.payload.questionSet!.questions[0]!.prompt="Would you like me to configure this?";prospective.payload.questionSet!.questions[0]!.options![0]!.label="Yes";expect(companySecretQuestionHandoff(prospective,binding)).toBeUndefined();
|
||||
@@ -37,7 +37,7 @@ it("rejects prospective Yes and negative or other-owner completion choices",()=>
|
||||
});
|
||||
|
||||
it("keeps an explicit Morgan acknowledgement and rejects other named completion recipients",()=>{
|
||||
for(const [recipient,accepted] of [["Morgan",true],["CEO",false],["Jordan",false]] as const){
|
||||
for(const [recipient,accepted] of [["Morgan",true],["CEO",false],["Jordan",false],["CEO’s DEPLOYMENT_API_KEY",false]] as const){
|
||||
const row=question();row.payload.questionSet!.questions[0]!.options![0]!.label=`Done for ${recipient}`;
|
||||
expect(!!companySecretQuestionHandoff(row,binding)).toBe(accepted);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,8 @@ export function companySecretQuestionHandoff(value:unknown,b:SecretQuestionBindi
|
||||
const completedPrompt=/\b(?:have you|did you)\b[^?]*\b(?:saved|added|entered|bound|configured|completed|finished)\b/i.test(q.prompt);
|
||||
const choices=q.options!.filter(o=>{
|
||||
const answer=`${o.label} ${o.description??""}`;
|
||||
const recipients=[...answer.matchAll(/\b(?:[Ff]or|[Tt]o)\s+(?:the\s+)?(?:[Aa]gent\s+([A-Za-z][A-Za-z0-9_-]*)|([A-Z][A-Za-z0-9_-]*)|([Cc][Ee][Oo]))\b/g)];
|
||||
const recipientText=answer.replace(/\b(?:DEPLOYMENT_API_KEY|Deployment API key)\b/g,"credential");
|
||||
const recipients=[...recipientText.matchAll(/\b(?:[Ff]or|[Tt]o)\s+(?:the\s+)?(?:[Aa]gent\s+([A-Za-z][A-Za-z0-9_-]*)|([A-Z][A-Za-z0-9_-]*)|([Cc][Ee][Oo]))\b/g)];
|
||||
return (/\b(?:saved|added|entered|done)\b/i.test(answer)||(completedPrompt&&/^yes[.!\s]*$/i.test(answer.trim())))
|
||||
&&recipients.every(match=>/^Morgan$/i.test(match[1]??match[2]??match[3]??""))
|
||||
&&!/\b(?:not|never|cannot|can't|didn.t|haven.t|hasn.t|yet|need|later|will|would|Riley|another|their)\b|someone else/i.test(answer);
|
||||
|
||||
Reference in new issue
Block a user